Search in sources :

Example 1 with EjbJarDescription

use of org.jboss.as.ejb3.deployment.EjbJarDescription in project wildfly by wildfly.

the class AbstractDeploymentUnitProcessor method getEjbJarDescription.

protected static EjbJarDescription getEjbJarDescription(final DeploymentUnit deploymentUnit) {
    EjbJarDescription ejbJarDescription = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_DESCRIPTION);
    final EEApplicationClasses applicationClassesDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    if (ejbJarDescription == null) {
        final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
        ejbJarDescription = new EjbJarDescription(moduleDescription, applicationClassesDescription, deploymentUnit.getName().endsWith(".war"));
        deploymentUnit.putAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_DESCRIPTION, ejbJarDescription);
    }
    return ejbJarDescription;
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) EjbJarDescription(org.jboss.as.ejb3.deployment.EjbJarDescription)

Example 2 with EjbJarDescription

use of org.jboss.as.ejb3.deployment.EjbJarDescription in project wildfly by wildfly.

the class AbstractDeploymentUnitProcessor method processDeploymentDescriptor.

protected void processDeploymentDescriptor(final DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException {
    // find the EJB jar metadata and start processing it
    final EjbJarMetaData ejbJarMetaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
    if (ejbJarMetaData == null) {
        return;
    }
    final SimpleSet<String> annotatedEJBs;
    if (appclient) {
        final List<ComponentDescription> additionalComponents = deploymentUnit.getAttachmentList(org.jboss.as.ee.component.Attachments.ADDITIONAL_RESOLVABLE_COMPONENTS);
        annotatedEJBs = new SimpleSet<String>() {

            @Override
            public boolean contains(Object o) {
                for (final ComponentDescription component : additionalComponents) {
                    if (component.getComponentName().equals(o)) {
                        return true;
                    }
                }
                return false;
            }
        };
    } else {
        final EjbJarDescription ejbJarDescription = getEjbJarDescription(deploymentUnit);
        annotatedEJBs = new SimpleSet<String>() {

            @Override
            public boolean contains(Object o) {
                return ejbJarDescription.hasComponent((String) o);
            }
        };
    }
    // process EJBs
    final EnterpriseBeansMetaData ejbs = ejbJarMetaData.getEnterpriseBeans();
    if (ejbs != null && !ejbs.isEmpty()) {
        for (final EnterpriseBeanMetaData ejb : ejbs) {
            final String beanName = ejb.getName();
            // the important bit is to skip already processed EJBs via annotations
            if (annotatedEJBs.contains(beanName)) {
                continue;
            }
            processBeanMetaData(deploymentUnit, ejb);
        }
    }
    EjbDeploymentMarker.mark(deploymentUnit);
}
Also used : ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EnterpriseBeansMetaData(org.jboss.metadata.ejb.spec.EnterpriseBeansMetaData) EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) EjbJarDescription(org.jboss.as.ejb3.deployment.EjbJarDescription) EnterpriseBeanMetaData(org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData)

Example 3 with EjbJarDescription

use of org.jboss.as.ejb3.deployment.EjbJarDescription in project wildfly by wildfly.

the class MessageDrivenComponentDescriptionFactory method processMessageBeans.

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 PropertyReplacer propertyReplacer = EJBAnnotationPropertyReplacement.propertyReplacer(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 (!EjbValidationsUtil.assertEjbClassValidity(beanClassInfo).isEmpty()) {
            continue;
        }
        final String ejbName = beanClassInfo.name().local();
        final AnnotationValue nameValue = messageBeanAnnotation.value("name");
        final String beanName = (nameValue == null || nameValue.asString().isEmpty()) ? ejbName : propertyReplacer.replaceProperties(nameValue.asString());
        final MessageDrivenBeanMetaData beanMetaData = getEnterpriseBeanMetaData(deploymentUnit, beanName, MessageDrivenBeanMetaData.class);
        final String beanClassName;
        final String messageListenerInterfaceName;
        final Properties activationConfigProperties = getActivationConfigProperties(messageBeanAnnotation, propertyReplacer);
        final String messagingType;
        if (beanMetaData != null) {
            beanClassName = override(beanClassInfo.name().toString(), beanMetaData.getEjbClass());
            deploymentDescriptorEnvironment = new DeploymentDescriptorEnvironment("java:comp/env/", beanMetaData);
            messagingType = beanMetaData.getMessagingType();
            final ActivationConfigMetaData activationConfigMetaData = beanMetaData.getActivationConfig();
            if (activationConfigMetaData != null) {
                final ActivationConfigPropertiesMetaData propertiesMetaData = activationConfigMetaData.getActivationConfigProperties();
                if (propertiesMetaData != null) {
                    for (final ActivationConfigPropertyMetaData propertyMetaData : propertiesMetaData) {
                        activationConfigProperties.put(propertyMetaData.getKey(), propertyMetaData.getValue());
                    }
                }
            }
            messageListenerInterfaceName = messagingType != null ? messagingType : getMessageListenerInterface(compositeIndex, messageBeanAnnotation, deploymentUnit);
        } else {
            beanClassName = beanClassInfo.name().toString();
            messageListenerInterfaceName = getMessageListenerInterface(compositeIndex, messageBeanAnnotation, deploymentUnit);
        }
        final String defaultResourceAdapterName = this.getDefaultResourceAdapterName(deploymentUnit.getServiceRegistry());
        final MessageDrivenComponentDescription beanDescription = new MessageDrivenComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnit, messageListenerInterfaceName, activationConfigProperties, defaultResourceAdapterName, beanMetaData, defaultMdbPoolAvailable);
        beanDescription.setDeploymentDescriptorEnvironment(deploymentDescriptorEnvironment);
        addComponent(deploymentUnit, beanDescription);
        final AnnotationValue mappedNameValue = messageBeanAnnotation.value("mappedName");
        if (mappedNameValue != null && !mappedNameValue.asString().isEmpty()) {
            EjbLogger.ROOT_LOGGER.mappedNameNotSupported(mappedNameValue != null ? mappedNameValue.asString() : "", ejbName);
        }
    }
    EjbDeploymentMarker.mark(deploymentUnit);
}
Also used : AnnotationTarget(org.jboss.jandex.AnnotationTarget) MessageDrivenBeanMetaData(org.jboss.metadata.ejb.spec.MessageDrivenBeanMetaData) ActivationConfigPropertyMetaData(org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData) ActivationConfigMetaData(org.jboss.metadata.ejb.spec.ActivationConfigMetaData) Properties(java.util.Properties) ActivationConfigPropertiesMetaData(org.jboss.metadata.ejb.spec.ActivationConfigPropertiesMetaData) ServiceName(org.jboss.msc.service.ServiceName) MessageDrivenComponentDescription(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription) DeploymentDescriptorEnvironment(org.jboss.as.ee.component.DeploymentDescriptorEnvironment) AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.getEjbJarDescription(org.jboss.as.ejb3.deployment.processors.AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.getEjbJarDescription) EjbJarDescription(org.jboss.as.ejb3.deployment.EjbJarDescription) AnnotationValue(org.jboss.jandex.AnnotationValue) PropertyReplacer(org.jboss.metadata.property.PropertyReplacer) AnnotationInstance(org.jboss.jandex.AnnotationInstance) ClassInfo(org.jboss.jandex.ClassInfo)

Example 4 with EjbJarDescription

use of org.jboss.as.ejb3.deployment.EjbJarDescription in project wildfly by wildfly.

the class SessionBeanComponentDescriptionFactory method processSessionBeanMetaData.

private void processSessionBeanMetaData(final DeploymentUnit deploymentUnit, final SessionBeanMetaData sessionBean) throws DeploymentUnitProcessingException {
    final EjbJarDescription ejbJarDescription = getEjbJarDescription(deploymentUnit);
    final CompositeIndex compositeIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
    final String beanName = sessionBean.getName();
    SessionType sessionType = sessionBean.getSessionType();
    if (sessionType == null && sessionBean instanceof GenericBeanMetaData) {
        final GenericBeanMetaData bean = (GenericBeanMetaData) sessionBean;
        if (bean.getEjbType() == EjbType.SESSION) {
            sessionType = determineSessionType(sessionBean.getEjbClass(), compositeIndex);
            if (sessionType == null) {
                throw EjbLogger.ROOT_LOGGER.sessionTypeNotSpecified(beanName);
            }
        } else {
            // it is not a session bean, so we ignore it
            return;
        }
    } else if (sessionType == null) {
        sessionType = determineSessionType(sessionBean.getEjbClass(), compositeIndex);
        if (sessionType == null) {
            throw EjbLogger.ROOT_LOGGER.sessionTypeNotSpecified(beanName);
        }
    }
    final String beanClassName = sessionBean.getEjbClass();
    final SessionBeanComponentDescription sessionBeanDescription;
    switch(sessionType) {
        case Stateless:
            sessionBeanDescription = new StatelessComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnit, sessionBean, defaultSlsbPoolAvailable);
            break;
        case Stateful:
            sessionBeanDescription = new StatefulComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnit, sessionBean);
            if (sessionBean instanceof SessionBean32MetaData && ((SessionBean32MetaData) sessionBean).isPassivationCapable() != null) {
                ((StatefulComponentDescription) sessionBeanDescription).setPassivationApplicable(((SessionBean32MetaData) sessionBean).isPassivationCapable());
            }
            break;
        case Singleton:
            sessionBeanDescription = new SingletonComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnit, sessionBean);
            break;
        default:
            throw EjbLogger.ROOT_LOGGER.unknownSessionBeanType(sessionType.name());
    }
    addComponent(deploymentUnit, sessionBeanDescription);
}
Also used : SessionType(org.jboss.metadata.ejb.spec.SessionType) StatelessComponentDescription(org.jboss.as.ejb3.component.stateless.StatelessComponentDescription) StatefulComponentDescription(org.jboss.as.ejb3.component.stateful.StatefulComponentDescription) AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.getEjbJarDescription(org.jboss.as.ejb3.deployment.processors.AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.getEjbJarDescription) EjbJarDescription(org.jboss.as.ejb3.deployment.EjbJarDescription) SessionBean32MetaData(org.jboss.metadata.ejb.spec.SessionBean32MetaData) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) GenericBeanMetaData(org.jboss.metadata.ejb.spec.GenericBeanMetaData) SingletonComponentDescription(org.jboss.as.ejb3.component.singleton.SingletonComponentDescription) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)

Example 5 with EjbJarDescription

use of org.jboss.as.ejb3.deployment.EjbJarDescription in project wildfly by wildfly.

the class AssemblyDescriptorProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    // get the deployment unit
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    // find the Jakarta Enterprise Beans jar metadata and start processing it
    final EjbJarMetaData ejbJarMetaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
    if (ejbJarMetaData == null) {
        return;
    }
    // process assembly-descriptor stuff
    final AssemblyDescriptorMetaData assemblyDescriptor = ejbJarMetaData.getAssemblyDescriptor();
    if (assemblyDescriptor != null) {
        // get hold of the ejb jar description (to which we'll be adding this assembly description metadata)
        final EjbJarDescription ejbJarDescription = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_DESCRIPTION);
        final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
        // process security-role(s)
        this.processSecurityRoles(assemblyDescriptor.getSecurityRoles(), ejbJarDescription);
        final MessageDestinationsMetaData destinations = assemblyDescriptor.getMessageDestinations();
        if (destinations != null) {
            processMessageDestinations(destinations, eeModuleDescription);
        }
    }
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) MessageDestinationsMetaData(org.jboss.metadata.javaee.spec.MessageDestinationsMetaData) EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) EjbJarDescription(org.jboss.as.ejb3.deployment.EjbJarDescription) AssemblyDescriptorMetaData(org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

EjbJarDescription (org.jboss.as.ejb3.deployment.EjbJarDescription)10 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)4 AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.getEjbJarDescription (org.jboss.as.ejb3.deployment.processors.AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.getEjbJarDescription)4 EjbJarMetaData (org.jboss.metadata.ejb.spec.EjbJarMetaData)4 Properties (java.util.Properties)2 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)2 DeploymentDescriptorEnvironment (org.jboss.as.ee.component.DeploymentDescriptorEnvironment)2 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)2 MessageDrivenComponentDescription (org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription)2 SessionBeanComponentDescription (org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)2 SingletonComponentDescription (org.jboss.as.ejb3.component.singleton.SingletonComponentDescription)2 StatefulComponentDescription (org.jboss.as.ejb3.component.stateful.StatefulComponentDescription)2 StatelessComponentDescription (org.jboss.as.ejb3.component.stateless.StatelessComponentDescription)2 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)2 AnnotationInstance (org.jboss.jandex.AnnotationInstance)2 AnnotationTarget (org.jboss.jandex.AnnotationTarget)2 AnnotationValue (org.jboss.jandex.AnnotationValue)2 ClassInfo (org.jboss.jandex.ClassInfo)2 EnterpriseBeanMetaData (org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData)2 EnterpriseBeansMetaData (org.jboss.metadata.ejb.spec.EnterpriseBeansMetaData)2