@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());
  }
 /**
  * Determine whether the given deployment unit is a JavaEE module which needs a java:module name
  * space.
  *
  * @param unit
  * @return
  */
 protected boolean isJavaEEModule(DeploymentUnit unit) {
   // TODO: isn't this using too much inside information? It would be better to have the deployer
   // execute explicitly on naming meta data.
   JavaEEModuleInformer.ModuleType type = informer.getModuleType(unit);
   return type != null && type != JavaEEModuleInformer.ModuleType.JAVA;
 }
 public ModuleNamingDeployer(JavaEEModuleInformer informer) {
   this.informer = informer;
   setInputs(informer.getRequiredAttachments());
   //      addInput("java:app");
   setOutput(BeanMetaData.class);
 }