private void processMessageDrivenBeanMetaData(
     final DeploymentUnit deploymentUnit, final MessageDrivenBeanMetaData mdb)
     throws DeploymentUnitProcessingException {
   final EjbJarDescription ejbJarDescription = getEjbJarDescription(deploymentUnit);
   final String beanName = mdb.getName();
   final String beanClassName = mdb.getEjbClass();
   String messageListenerInterface = mdb.getMessagingType();
   if (messageListenerInterface == null || messageListenerInterface.trim().isEmpty()) {
     // TODO: This isn't really correct to default to MessageListener
     messageListenerInterface = MessageListener.class.getName();
   }
   final Properties activationConfigProps =
       getActivationConfigProperties(mdb.getActivationConfig());
   final String defaultResourceAdapterName =
       this.getDefaultResourceAdapterName(deploymentUnit.getServiceRegistry());
   final MessageDrivenComponentDescription mdbComponentDescription =
       new MessageDrivenComponentDescription(
           beanName,
           beanClassName,
           ejbJarDescription,
           deploymentUnit.getServiceName(),
           messageListenerInterface,
           activationConfigProps,
           defaultResourceAdapterName,
           mdb);
   mdbComponentDescription.setDeploymentDescriptorEnvironment(
       new DeploymentDescriptorEnvironment("java:comp/env/", mdb));
   addComponent(deploymentUnit, mdbComponentDescription);
 }
  @Override
  protected MessageDrivenBeanMetaData assertFullMDB(
      String ejbName, IEnterpriseBeansMetaData<?, ?, ?, ?> enterpriseBeansMetaData, Mode mode) {
    MessageDrivenBeanMetaData mdb = assertMDB(ejbName + "EjbName", enterpriseBeansMetaData);
    assertId(ejbName, mdb);
    if (mode == Mode.SPEC) {
      assertMappedName(ejbName, mdb.getMappedName());
      assertEquals(ejbName + "MessagingType", mdb.getMessagingType());
      assertNamedMethod(ejbName + "TimeoutMethod", 2, mdb.getTimeoutMethod());
      assertEquals(TransactionManagementType.CONTAINER, mdb.getTransactionType());
      assertEquals(ejbName + "MessageDestinationType", mdb.getMessageDestinationType());
      assertEquals(ejbName + "MessageDestinationLink", mdb.getMessageDestinationLink());
      assertAroundInvokes(ejbName, 2, mdb.getAroundInvokes());
      assertEnvironment(ejbName, mdb.getJndiEnvironmentRefsGroup(), true, mode);
      assertContainerTransactions(ejbName, 6, 6, mdb.getContainerTransactions());
      assertMethodPermissions(
          ejbName, ejbName + "MethodPermission", 3, 3, mdb.getMethodPermissions());
      assertExcludeList(ejbName, 5, 5, mdb.getExcludeList());
      assertSecurityIdentity(ejbName, "SecurityIdentity", mdb.getSecurityIdentity(), true, mode);
    } else {
      assertNull(mdb.getMappedName());
      assertNull(mdb.getMessagingType());
      assertNull(mdb.getTimeoutMethod());
      assertNull(mdb.getTransactionType());
      assertNull(mdb.getMessageDestinationType());
      assertNull(mdb.getMessageDestinationLink());
      assertNull(mdb.getAroundInvokes());
      assertEnvironment(ejbName, mdb.getJndiEnvironmentRefsGroup(), false, mode);
      assertNull(mdb.getContainerTransactions());
      assertNull(mdb.getMethodPermissions());
      assertNull(mdb.getExcludeList());
      assertSecurityIdentity(ejbName, "SecurityIdentity", mdb.getSecurityIdentity(), false, mode);
    }
    assertActivationConfig(ejbName, mdb.getActivationConfig(), mode);

    return mdb;
  }
  private void processMessageBeans(
      final DeploymentUnit deploymentUnit,
      final Collection<AnnotationInstance> messageBeanAnnotations,
      final CompositeIndex compositeIndex)
      throws DeploymentUnitProcessingException {
    if (messageBeanAnnotations.isEmpty()) return;

    final EjbJarDescription ejbJarDescription = getEjbJarDescription(deploymentUnit);
    final ServiceName deploymentUnitServiceName = deploymentUnit.getServiceName();
    DeploymentDescriptorEnvironment deploymentDescriptorEnvironment = null;

    for (final AnnotationInstance messageBeanAnnotation : messageBeanAnnotations) {
      final AnnotationTarget target = messageBeanAnnotation.target();
      final ClassInfo beanClassInfo = (ClassInfo) target;
      if (!assertMDBClassValidity(beanClassInfo)) {
        continue;
      }
      final String ejbName = beanClassInfo.name().local();
      final AnnotationValue nameValue = messageBeanAnnotation.value("name");
      final String beanName =
          nameValue == null || nameValue.asString().isEmpty() ? ejbName : nameValue.asString();
      final MessageDrivenBeanMetaData beanMetaData =
          getEnterpriseBeanMetaData(deploymentUnit, beanName, MessageDrivenBeanMetaData.class);
      final String beanClassName;
      final String messageListenerInterfaceName;
      boolean replacement =
          deploymentUnit.getAttachment(Attachments.EJB_ANNOTATION_PROPERTY_REPLACEMENT);
      final Properties activationConfigProperties =
          getActivationConfigProperties(messageBeanAnnotation, replacement);
      final String messagingType;
      if (beanMetaData != null) {
        beanClassName = override(beanClassInfo.name().toString(), beanMetaData.getEjbClass());
        deploymentDescriptorEnvironment =
            new DeploymentDescriptorEnvironment("java:comp/env/", beanMetaData);

        if (beanMetaData instanceof MessageDrivenBeanMetaData) {
          // It may actually be GenericBeanMetadata instance
          final MessageDrivenBeanMetaData mdb = (MessageDrivenBeanMetaData) beanMetaData;
          messagingType = mdb.getMessagingType();
          final ActivationConfigMetaData activationConfigMetaData = mdb.getActivationConfig();
          if (activationConfigMetaData != null) {
            final ActivationConfigPropertiesMetaData propertiesMetaData =
                activationConfigMetaData.getActivationConfigProperties();
            if (propertiesMetaData != null) {
              for (final ActivationConfigPropertyMetaData propertyMetaData : propertiesMetaData) {
                activationConfigProperties.put(
                    propertyMetaData.getKey(), propertyMetaData.getValue());
              }
            }
          }
        } else if (beanMetaData instanceof JBossGenericBeanMetaData) {
          // TODO: fix the hierarchy so this is not needed
          final JBossGenericBeanMetaData mdb = (JBossGenericBeanMetaData) beanMetaData;
          messagingType = mdb.getMessagingType();
          final ActivationConfigMetaData activationConfigMetaData = mdb.getActivationConfig();
          if (activationConfigMetaData != null) {
            final ActivationConfigPropertiesMetaData propertiesMetaData =
                activationConfigMetaData.getActivationConfigProperties();
            if (propertiesMetaData != null) {
              for (final ActivationConfigPropertyMetaData propertyMetaData : propertiesMetaData) {
                activationConfigProperties.put(
                    propertyMetaData.getKey(), propertyMetaData.getValue());
              }
            }
          }
        } else {
          messagingType = null;
        }
        messageListenerInterfaceName =
            messagingType != null
                ? messagingType
                : getMessageListenerInterface(compositeIndex, messageBeanAnnotation);

      } else {
        beanClassName = beanClassInfo.name().toString();
        messageListenerInterfaceName =
            getMessageListenerInterface(compositeIndex, messageBeanAnnotation);
      }
      final String defaultResourceAdapterName =
          this.getDefaultResourceAdapterName(deploymentUnit.getServiceRegistry());
      final MessageDrivenComponentDescription beanDescription =
          new MessageDrivenComponentDescription(
              beanName,
              beanClassName,
              ejbJarDescription,
              deploymentUnitServiceName,
              messageListenerInterfaceName,
              activationConfigProperties,
              defaultResourceAdapterName,
              beanMetaData);
      beanDescription.setDeploymentDescriptorEnvironment(deploymentDescriptorEnvironment);

      addComponent(deploymentUnit, beanDescription);
    }

    EjbDeploymentMarker.mark(deploymentUnit);
  }