public void deploy(DeploymentUnit unit) throws DeploymentException {
    Set<? extends RubyEndpointMetaData> allMetaData =
        unit.getAllMetaData(RubyEndpointMetaData.class);

    if (allMetaData.size() == 0) {
      return;
    }

    log.debug("deploying for: " + unit);

    BeanMetaData busMetaData =
        unit.getAttachment(BeanMetaData.class + "$cxf.bus", BeanMetaData.class);

    RubyDynamicClassLoader classLoader = unit.getAttachment(RubyDynamicClassLoader.class);

    for (RubyEndpointMetaData endpointMetaData : allMetaData) {
      String beanName = getBeanName(unit, endpointMetaData.getName());
      BeanMetaDataBuilder builder =
          BeanMetaDataBuilder.createBuilder(beanName, RubyTypeSpace.class.getName());

      builder.addPropertyMetaData("rubyPath", "jboss/databinding/" + endpointMetaData.getName());
      builder.addPropertyMetaData("wsdlLocation", endpointMetaData.getWsdlLocation());
      builder.addPropertyMetaData("rubyDynamicClassLoader", classLoader);

      ValueMetaData busInjection = builder.createInject(busMetaData.getName());
      builder.addPropertyMetaData("bus", busInjection);

      BeanMetaData beanMetaData = builder.getBeanMetaData();
      unit.addAttachment(
          BeanMetaData.class.getName() + "$databinding." + endpointMetaData.getName(),
          beanMetaData,
          BeanMetaData.class);
    }
  }
  @Override
  protected void internalDeploy(DeploymentUnit unit) throws DeploymentException {
    if (!isJavaEEModule(unit)) return;

    // appName is either the name of the JavaEE application or null for a stand-alone JavaEE module
    String appName = informer.getApplicationName(unit);
    String moduleName = informer.getModuleName(unit);

    // create JavaEEModule bean
    String name = "jboss.naming:";
    if (appName != null) name += "application=" + appName + ",";
    name += "module=" + moduleName;
    BeanMetaDataBuilder builder =
        BeanMetaDataBuilderFactory.createBuilder(name, MCJavaEEModule.class.getName())
            //         .addAnnotation(annotation(DeploymentScope.class, moduleName))
            .addConstructorParameter(String.class.getName(), moduleName)
        //         .addAlias("java:module")
        ;
    if (appName != null) {
      //         builder.addAnnotation(annotation(ApplicationScope.class, appName));
      //         AbstractInjectionValueMetaData javaApp = new
      // AbstractInjectionValueMetaData("java:app");
      //         javaApp.setSearch(new ParentsLookupStrategy());
      AbstractInjectionValueMetaData javaApp =
          new AbstractInjectionValueMetaData("jboss.naming:application=" + appName);
      builder.addConstructorParameter(JavaEEApplication.class.getName(), javaApp);
    } else builder.addConstructorParameter(JavaEEApplication.class.getName(), (Object) null);
    builder.addPropertyMetaData("nameSpaces", builder.createInject("NameSpaces"));

    unit.addAttachment(BeanMetaData.class + "." + name, builder.getBeanMetaData());
  }
  /**
   * Creates a {@link NoInterfaceViewJNDIBinderFacade} MC bean for the no-interface view represented
   * by the <code>sessionBeanMetaData</code>. The {@link NoInterfaceViewJNDIBinderFacade} is created
   * only if the bean is eligible for a no-interface view as defined by the EJB3.1 spec
   *
   * <p>The {@link NoInterfaceViewJNDIBinderFacade}, thus created, will be dependent on the {@link
   * ControllerState#DESCRIBED} state of the container (endpoint) MC bean. This way, we ensure that
   * this {@link NoInterfaceViewJNDIBinderFacade} will be deployed only after the corresponding
   * container MC bean moves to {@link ControllerState#DESCRIBED} state.
   *
   * @param unit Deployment unit
   * @param sessionBeanMetaData Session bean metadata
   * @throws DeploymentException If any exceptions are encountered during processing of the
   *     deployment unit
   */
  private void deploy(DeploymentUnit unit, JBossSessionBean31MetaData sessionBeanMetaData)
      throws DeploymentException {
    try {
      if (!sessionBeanMetaData.isNoInterfaceBean()) {
        if (logger.isTraceEnabled()) {
          logger.trace(
              "Bean class "
                  + sessionBeanMetaData.getEjbClass()
                  + " is not eligible for no-interface view");
        }
        return;
      }
      Class<?> beanClass =
          Class.forName(sessionBeanMetaData.getEjbClass(), false, unit.getClassLoader());

      String containerMCBeanName = sessionBeanMetaData.getContainerName();
      if (logger.isTraceEnabled()) {
        logger.trace(
            "Container name for bean "
                + sessionBeanMetaData.getEjbName()
                + " in unit "
                + unit
                + " is "
                + containerMCBeanName);
      }
      if (containerMCBeanName == null) {
        // The container name is set in the metadata only after the creation of the container
        // However, this deployer does not have an dependency on the creation of a container,
        // so getting the container name from the bean metadata won't work. Need to do a
        // different/better way
        // String containerMCBeanName = sessionBeanMetaData.getContainerName();
        containerMCBeanName = getContainerName(unit, sessionBeanMetaData);
      }

      // Create the NoInterfaceViewJNDIBinder (MC bean) and add a dependency on the DESCRIBED
      // state of the container (endpoint) MC bean
      NoInterfaceViewJNDIBinderFacade noInterfaceViewJNDIBinderFacade =
          new NoInterfaceViewJNDIBinderFacade(new InitialContext(), beanClass, sessionBeanMetaData);
      String noInterfaceViewMCBeanName = unit.getName() + "$" + sessionBeanMetaData.getEjbName();
      BeanMetaDataBuilder builder =
          BeanMetaDataBuilder.createBuilder(
              noInterfaceViewMCBeanName, noInterfaceViewJNDIBinderFacade.getClass().getName());
      builder.setConstructorValue(noInterfaceViewJNDIBinderFacade);

      // add dependency
      AbstractInjectionValueMetaData injectMetaData =
          new AbstractInjectionValueMetaData(containerMCBeanName);
      // EJBTHREE-2166 - Depending on DESCRIBED state and then pushing to INSTALLED
      // through MC API, won't work. So for now, just depend on INSTALLED state.
      // injectMetaData.setDependentState(ControllerState.DESCRIBED);
      injectMetaData.setDependentState(ControllerState.INSTALLED);
      injectMetaData.setFromContext(FromContext.CONTEXT);

      // Too bad we have to know the field name. Need to do more research on MC to see if we can
      // add property metadata based on type instead of field name.
      builder.addPropertyMetaData("endpointContext", injectMetaData);

      // Add this as an attachment
      unit.addAttachment(
          BeanMetaData.class + ":" + noInterfaceViewMCBeanName, builder.getBeanMetaData());

      logger.debug(
          "No-interface JNDI binder for container "
              + containerMCBeanName
              + " has been created and added to the deployment unit "
              + unit);

    } catch (Throwable t) {
      DeploymentException.rethrowAsDeploymentException(
          "Could not create no-interface view for "
              + sessionBeanMetaData.getEjbClass()
              + " in unit "
              + unit.getName(),
          t);
    }
  }
Exemplo n.º 4
0
  @Override
  protected void internalDeploy(DeploymentUnit unit) throws DeploymentException {
    JBossEnterpriseBeanMetaData beanMetaData =
        unit.getAttachment(JBossEnterpriseBeanMetaData.class);
    if (beanMetaData == null) return;

    if (!beanMetaData.isSession()) return;

    JBossSessionBeanMetaData sessionBeanMetaData = (JBossSessionBeanMetaData) beanMetaData;

    String appName = getApplicationName(unit);
    String moduleName = getModuleName(unit);
    String componentName = getComponentName(unit);

    String javaCompName = "jboss.naming:";
    if (appName != null) javaCompName += "application=" + appName + ",";
    javaCompName += "module=" + moduleName + ",component=" + componentName;

    String sessionBeanTypeName = "jboss.ejb3:";
    if (appName != null) sessionBeanTypeName += "application=" + appName + ",";
    sessionBeanTypeName +=
        "module="
            + moduleName
            + ",component="
            + componentName
            + ",service="
            + SessionBeanTypeWrapper.class.getSimpleName();
    {
      BeanMetaDataBuilder builder =
          BeanMetaDataBuilderFactory.createBuilder(
              sessionBeanTypeName, SessionBeanTypeWrapper.class.getName());
      builder.addConstructorParameter(
          JBossSessionBeanMetaData.class.getName(), sessionBeanMetaData);
      builder.addConstructorParameter(ClassLoader.class.getName(), unit.getClassLoader());
      builder.addConstructorParameter(
          JavaEEComponent.class.getName(), builder.createInject(javaCompName));

      unit.getParent().addAttachment(sessionBeanTypeName, builder.getBeanMetaData());
    }

    String beanInstanceName = "jboss.ejb3:";
    if (appName != null) beanInstanceName += "application=" + appName + ",";
    beanInstanceName +=
        "module="
            + moduleName
            + ",component="
            + componentName
            + ",service="
            + EJBBinder.class.getSimpleName();
    BeanMetaDataBuilder builder =
        BeanMetaDataBuilderFactory.createBuilder(beanInstanceName, EJBBinder.class.getName());
    builder.addConstructorParameter(
        SessionBeanType.class.getName(), builder.createInject(sessionBeanTypeName));
    builder.addPropertyMetaData(
        "globalContext", builder.createInject("NameSpaces", "globalContext"));
    builder.addPropertyMetaData("proxyFactory", sessionBeanMetaData.isStateless() ? lazy : legacy);
    builder.setStart("bind");
    builder.setStop("unbind");

    for (DependencyBuilder db : builders) db.buildDependency(unit, builder);

    unit.getParent().addAttachment(beanInstanceName, builder.getBeanMetaData());
  }