Search in sources :

Example 1 with AbstractEnterpriseBeanMetaData

use of org.jboss.metadata.ejb.spec.AbstractEnterpriseBeanMetaData in project wildfly by wildfly.

the class EjbJarParsingDeploymentUnitProcessor method deploy.

/**
     * 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
     *
     */
@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, applicationClassesDescription, 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());
        }
    }
}
Also used : AbstractEnterpriseBeanMetaData(org.jboss.metadata.ejb.spec.AbstractEnterpriseBeanMetaData) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) EjbJarDescription(org.jboss.as.ejb3.deployment.EjbJarDescription) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)1 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)1 EjbJarDescription (org.jboss.as.ejb3.deployment.EjbJarDescription)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 AbstractEnterpriseBeanMetaData (org.jboss.metadata.ejb.spec.AbstractEnterpriseBeanMetaData)1 EjbJarMetaData (org.jboss.metadata.ejb.spec.EjbJarMetaData)1