コード例 #1
0
  /**
   * Process the deployment unit and deploy appropriate MC beans (see details below) if it
   * corresponds to a no-interface view deployment.
   *
   * <p>If any beans in the unit are eligible for no-interface view, then internally this method
   * creates a {@link NoInterfaceViewJNDIBinderFacade} MC bean for the no-interface view.
   *
   * <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.
   */
  public void deploy(DeploymentUnit unit) throws DeploymentException {

    if (logger.isTraceEnabled()) {
      logger.trace("Deploying unit " + unit.getName());
    }
    // get processed metadata
    JBossMetaData metaData = unit.getAttachment(INPUT, JBossMetaData.class);
    if (metaData == null) {
      if (logger.isTraceEnabled()) logger.trace("No JBossMetadata for unit : " + unit.getName());
      return;
    }
    // work on the ejbs
    JBossEnterpriseBeansMetaData beans = metaData.getEnterpriseBeans();
    for (JBossEnterpriseBeanMetaData bean : beans) {
      if (bean.isSession()) {
        if (logger.isTraceEnabled()) {
          logger.trace(
              "Found bean of type session: " + bean.getEjbClass() + " in unit " + unit.getName());
        }
        // too bad
        if (bean instanceof JBossSessionBean31MetaData) {
          // Process for no-interface view
          deploy(unit, (JBossSessionBean31MetaData) bean);
        }
      }
    }
  }
コード例 #2
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());
  }