ejb3/src/main/java/org/jboss/as/ejb3/deployment/processors/EjbJarParsingDeploymentUnitProcessor.java
@Override
    public void deploy(DeploymentPhaseContext deploymentPhase) throws DeploymentUnitProcessingException {

        // get hold of the deployment unit.
        final DeploymentUnit deploymentUnit = deploymentPhase.getDeploymentUnit();

        // get the root of the deployment unit

        final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
        final EEApplicationClasses applicationClassesDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);

        final EjbJarMetaData ejbJarMetaData;
        final EjbJarMetaData specMetaData = parseEjbJarXml(deploymentUnit);
        final EjbJarMetaData jbossMetaData = parseJBossEjb3Xml(deploymentUnit);
        if (specMetaData == null) {
            if (jbossMetaData == null)
                return;
            ejbJarMetaData = jbossMetaData;
        } else if (jbossMetaData == null) {
            ejbJarMetaData = specMetaData;
        } else {
            ejbJarMetaData = jbossMetaData.createMerged(specMetaData);
        }

        // Mark it as an EJB deployment
        EjbDeploymentMarker.mark(deploymentUnit);
        if (!deploymentUnit.hasAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_DESCRIPTION)) {
            final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
            final EjbJarDescription ejbModuleDescription = new EjbJarDescription(moduleDescription, deploymentUnit.getName().endsWith(".war"));
            deploymentUnit.putAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_DESCRIPTION, ejbModuleDescription);
        }

        // attach the EjbJarMetaData to the deployment unit
        deploymentUnit.putAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA, ejbJarMetaData);

        // if the jboss-ejb3.xml has a distinct-name configured then attach it to the deployment unit
        if (jbossMetaData != null && jbossMetaData.getDistinctName() != null) {
            deploymentUnit.putAttachment(org.jboss.as.ee.structure.Attachments.DISTINCT_NAME, jbossMetaData.getDistinctName());
        }

        if (ejbJarMetaData.getModuleName() != null) {
            eeModuleDescription.setModuleName(ejbJarMetaData.getModuleName());
        }
        if (ejbJarMetaData.isMetadataComplete()) {
            MetadataCompleteMarker.setMetadataComplete(deploymentUnit, true);
        }
        if (!ejbJarMetaData.isEJB3x()) {
            //EJB spec 20.5.1, we do not process annotations for older deployments
            MetadataCompleteMarker.setMetadataComplete(deploymentUnit, true);
        }

        if(ejbJarMetaData.getEnterpriseBeans() != null) {
            //check for entity beans
            StringBuilder beans = new StringBuilder();
            boolean error = false;
            for (AbstractEnterpriseBeanMetaData bean : ejbJarMetaData.getEnterpriseBeans()) {
                if (bean.getEjbType() == EjbType.ENTITY) {
                    if (!error) {
                        error = true;
                    } else {
                        beans.append(", ");
                    }
                    beans.append(bean.getEjbName());
                }
            }
            if (error) {
                throw EjbLogger.ROOT_LOGGER.entityBeansAreNotSupported(beans.toString());
            }
        }

    }
@Override
    public void deploy(DeploymentPhaseContext deploymentPhase) throws DeploymentUnitProcessingException {

        // get hold of the deployment unit.
        final DeploymentUnit deploymentUnit = deploymentPhase.getDeploymentUnit();

        // get the root of the deployment unit

        final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
        final EEApplicationClasses applicationClassesDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);

        final EjbJarMetaData ejbJarMetaData;
        final EjbJarMetaData specMetaData = parseEjbJarXml(deploymentUnit);
        final EjbJarMetaData jbossMetaData = parseJBossEjb3Xml(deploymentUnit);
        if (specMetaData == null) {
            if (jbossMetaData == null)
                return;
            ejbJarMetaData = jbossMetaData;
        } else if (jbossMetaData == null) {
            ejbJarMetaData = specMetaData;
        } else {
            ejbJarMetaData = jbossMetaData.createMerged(specMetaData);
        }

        // Mark it as an EJB deployment
        EjbDeploymentMarker.mark(deploymentUnit);
        if (!deploymentUnit.hasAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_DESCRIPTION)) {
            final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
            final EjbJarDescription ejbModuleDescription = new EjbJarDescription(moduleDescription, deploymentUnit.getName().endsWith(".war"));
            deploymentUnit.putAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_DESCRIPTION, ejbModuleDescription);
        }

        // attach the EjbJarMetaData to the deployment unit
        deploymentUnit.putAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA, ejbJarMetaData);

        // if the jboss-ejb3.xml has a distinct-name configured then attach it to the deployment unit
        if (jbossMetaData != null && jbossMetaData.getDistinctName() != null) {
            deploymentUnit.putAttachment(org.jboss.as.ee.structure.Attachments.DISTINCT_NAME, jbossMetaData.getDistinctName());
        }

        if (ejbJarMetaData.getModuleName() != null) {
            eeModuleDescription.setModuleName(ejbJarMetaData.getModuleName());
        }
        if (ejbJarMetaData.isMetadataComplete()) {
            MetadataCompleteMarker.setMetadataComplete(deploymentUnit, true);
        }
        if (!ejbJarMetaData.isEJB3x()) {
            //EJB spec 20.5.1, we do not process annotations for older deployments
            MetadataCompleteMarker.setMetadataComplete(deploymentUnit, true);
        }

        if(ejbJarMetaData.getEnterpriseBeans() != null) {
            //check for entity beans
            StringBuilder beans = new StringBuilder();
            boolean error = false;
            for (AbstractEnterpriseBeanMetaData bean : ejbJarMetaData.getEnterpriseBeans()) {
                if (bean.getEjbType() == EjbType.ENTITY) {
                    if (!error) {
                        error = true;
                    } else {
                        beans.append(", ");
                    }
                    beans.append(bean.getEjbName());
                }
            }
            if (error) {
                throw EjbLogger.ROOT_LOGGER.entityBeansAreNotSupported(beans.toString());
            }
        }

    }
@ Override public void deploy ( DeploymentPhaseContext deploymentPhase ) throws DeploymentUnitProcessingException { // get hold of the deployment unit. final DeploymentUnit deploymentUnit = deploymentPhase . getDeploymentUnit ( ) ; // get the root of the deployment unit final EEModuleDescription eeModuleDescription = deploymentUnit . getAttachment ( org . jboss . as . ee . component . Attachments . EE_MODULE_DESCRIPTION ) ; final EEApplicationClasses applicationClassesDescription = deploymentUnit . getAttachment ( org . jboss . as . ee . component . Attachments . EE_APPLICATION_CLASSES_DESCRIPTION ) ; final EjbJarMetaData ejbJarMetaData ; final EjbJarMetaData specMetaData = parseEjbJarXml ( deploymentUnit ) ; final EjbJarMetaData jbossMetaData = parseJBossEjb3Xml ( deploymentUnit ) ; if ( specMetaData == null ) { if ( jbossMetaData == null ) return ; ejbJarMetaData = jbossMetaData ; } else if ( jbossMetaData == null ) { ejbJarMetaData = specMetaData ; } else { ejbJarMetaData = jbossMetaData . createMerged ( specMetaData ) ; } // Mark it as an EJB deployment EjbDeploymentMarker . mark ( deploymentUnit ) ; if ( ! deploymentUnit . hasAttachment ( EjbDeploymentAttachmentKeys . EJB_JAR_DESCRIPTION ) ) { final EEModuleDescription moduleDescription = deploymentUnit . getAttachment ( org . jboss . as . ee . component . Attachments . EE_MODULE_DESCRIPTION ) ; final EjbJarDescription ejbModuleDescription = new EjbJarDescription ( moduleDescription , deploymentUnit . getName ( ) . endsWith ( ".war" ) ) ; deploymentUnit . putAttachment ( EjbDeploymentAttachmentKeys . EJB_JAR_DESCRIPTION , ejbModuleDescription ) ; } // attach the EjbJarMetaData to the deployment unit deploymentUnit . putAttachment ( EjbDeploymentAttachmentKeys . EJB_JAR_METADATA , ejbJarMetaData ) ; // if the jboss-ejb3.xml has a distinct-name configured then attach it to the deployment unit if ( jbossMetaData != null && jbossMetaData . getDistinctName ( ) != null ) { deploymentUnit . putAttachment ( org . jboss . as . ee . structure . Attachments . DISTINCT_NAME , jbossMetaData . getDistinctName ( ) ) ; } if ( ejbJarMetaData . getModuleName ( ) != null ) { eeModuleDescription . setModuleName ( ejbJarMetaData . getModuleName ( ) ) ; } if ( ejbJarMetaData . isMetadataComplete ( ) ) { MetadataCompleteMarker . setMetadataComplete ( deploymentUnit , true ) ; } if ( ! ejbJarMetaData . isEJB3x ( ) ) { //EJB spec 20.5.1, we do not process annotations for older deployments MetadataCompleteMarker . setMetadataComplete ( deploymentUnit , true ) ; } if ( ejbJarMetaData . getEnterpriseBeans ( ) != null ) { //check for entity beans StringBuilder beans = new StringBuilder ( ) ; boolean error = false ; for ( AbstractEnterpriseBeanMetaData bean : ejbJarMetaData . getEnterpriseBeans ( ) ) { if ( bean . getEjbType ( ) == EjbType . ENTITY ) { if ( ! error ) { error = true ; } else { beans . append ( ", " ) ; } beans . append ( bean . getEjbName ( ) ) ; } } if ( error ) { throw EjbLogger . ROOT_LOGGER . entityBeansAreNotSupported ( beans . toString ( ) ) ; } } }
Finds an ejb-jar.xml (at WEB-INF of a .war or META-INF of a .jar) parses the file and creates
metadata out of it. The metadata is then attached to the deployment unit.

@param deploymentPhase
@throws DeploymentUnitProcessingException
Finds an ejb - jar . xml ( at WEB - INF of a . war or META - INF of a . jar ) parses the file and creates metadata out of it . The metadata is then attached to the deployment unit .