Search in sources :

Example 6 with CompositeIndex

use of org.jboss.as.server.deployment.annotation.CompositeIndex 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.getServiceName(), sessionBean);
            break;
        case Stateful:
            sessionBeanDescription = new StatefulComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnit.getServiceName(), 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.getServiceName(), 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) EjbJarDescription(org.jboss.as.ejb3.deployment.EjbJarDescription) AbstractDeploymentUnitProcessor.getEjbJarDescription(org.jboss.as.ejb3.deployment.processors.AbstractDeploymentUnitProcessor.getEjbJarDescription) 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 7 with CompositeIndex

use of org.jboss.as.server.deployment.annotation.CompositeIndex in project wildfly by wildfly.

the class EjbResourceInjectionAnnotationProcessor method deploy.

public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
    final List<AnnotationInstance> resourceAnnotations = index.getAnnotations(EJB_ANNOTATION_NAME);
    PropertyReplacer propertyReplacer = EJBAnnotationPropertyReplacement.propertyReplacer(deploymentUnit);
    for (AnnotationInstance annotation : resourceAnnotations) {
        final AnnotationTarget annotationTarget = annotation.target();
        final EJBResourceWrapper annotationWrapper = new EJBResourceWrapper(annotation, propertyReplacer);
        if (annotationTarget instanceof FieldInfo) {
            processField(deploymentUnit, annotationWrapper, (FieldInfo) annotationTarget, moduleDescription);
        } else if (annotationTarget instanceof MethodInfo) {
            processMethod(deploymentUnit, annotationWrapper, (MethodInfo) annotationTarget, moduleDescription);
        } else if (annotationTarget instanceof ClassInfo) {
            processClass(deploymentUnit, annotationWrapper, (ClassInfo) annotationTarget, moduleDescription);
        }
    }
    final List<AnnotationInstance> ejbsAnnotations = index.getAnnotations(EJBS_ANNOTATION_NAME);
    for (AnnotationInstance annotation : ejbsAnnotations) {
        final AnnotationTarget annotationTarget = annotation.target();
        if (annotationTarget instanceof ClassInfo) {
            final AnnotationValue annotationValue = annotation.value();
            final AnnotationInstance[] ejbAnnotations = annotationValue.asNestedArray();
            for (AnnotationInstance ejbAnnotation : ejbAnnotations) {
                final EJBResourceWrapper annotationWrapper = new EJBResourceWrapper(ejbAnnotation, propertyReplacer);
                processClass(deploymentUnit, annotationWrapper, (ClassInfo) annotationTarget, moduleDescription);
            }
        } else {
            throw EjbLogger.ROOT_LOGGER.annotationOnlyAllowedOnClass(EJBs.class.getName(), annotation.target());
        }
    }
}
Also used : AnnotationTarget(org.jboss.jandex.AnnotationTarget) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EJBs(javax.ejb.EJBs) AnnotationValue(org.jboss.jandex.AnnotationValue) PropertyReplacer(org.jboss.metadata.property.PropertyReplacer) MethodInfo(org.jboss.jandex.MethodInfo) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) AnnotationInstance(org.jboss.jandex.AnnotationInstance) FieldInfo(org.jboss.jandex.FieldInfo) ClassInfo(org.jboss.jandex.ClassInfo)

Example 8 with CompositeIndex

use of org.jboss.as.server.deployment.annotation.CompositeIndex in project wildfly by wildfly.

the class AbstractDeploymentUnitProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    // get hold of the deployment unit
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
        return;
    }
    final CompositeIndex compositeIndex = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
    if (compositeIndex == null) {
        EjbLogger.DEPLOYMENT_LOGGER.tracef("Skipping EJB annotation processing since no composite annotation index found in unit: %s", deploymentUnit);
    } else {
        if (MetadataCompleteMarker.isMetadataComplete(deploymentUnit)) {
            EjbLogger.DEPLOYMENT_LOGGER.trace("Skipping EJB annotation processing due to deployment being metadata-complete. ");
        } else {
            processAnnotations(deploymentUnit, compositeIndex);
        }
    }
    processDeploymentDescriptor(deploymentUnit);
}
Also used : CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 9 with CompositeIndex

use of org.jboss.as.server.deployment.annotation.CompositeIndex in project wildfly by wildfly.

the class JaxrsAnnotationProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (deploymentUnit.getParent() == null) {
        //register resource, provider and application as CDI annotation defining types
        deploymentUnit.addToAttachmentList(INJECTION_TARGET_DEFINING_ANNOTATIONS, JaxrsAnnotations.PROVIDER.getDotName());
        deploymentUnit.addToAttachmentList(INJECTION_TARGET_DEFINING_ANNOTATIONS, JaxrsAnnotations.PATH.getDotName());
    }
    final CompositeIndex index = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
    for (final JaxrsAnnotations annotation : JaxrsAnnotations.values()) {
        if (!index.getAnnotations(annotation.getDotName()).isEmpty()) {
            JaxrsDeploymentMarker.mark(deploymentUnit);
            phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS, Services.JBOSS_MODULE_INDEX_SERVICE);
            return;
        }
    }
}
Also used : JaxrsAnnotations(org.jboss.as.jaxrs.JaxrsAnnotations) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 10 with CompositeIndex

use of org.jboss.as.server.deployment.annotation.CompositeIndex in project wildfly by wildfly.

the class CompensationsDependenciesDeploymentProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit unit = phaseContext.getDeploymentUnit();
    final CompositeIndex compositeIndex = unit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
    if (compositeIndex == null) {
        return;
    }
    if (isCompensationAnnotationPresent(compositeIndex)) {
        addCompensationsModuleDependency(unit);
    }
}
Also used : CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)38 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)29 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)17 AnnotationInstance (org.jboss.jandex.AnnotationInstance)17 ClassInfo (org.jboss.jandex.ClassInfo)12 HashSet (java.util.HashSet)6 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)6 AnnotationTarget (org.jboss.jandex.AnnotationTarget)6 DotName (org.jboss.jandex.DotName)6 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)5 EEModuleClassDescription (org.jboss.as.ee.component.EEModuleClassDescription)5 PropertyReplacer (org.jboss.metadata.property.PropertyReplacer)5 Module (org.jboss.modules.Module)5 HashMap (java.util.HashMap)4 WarMetaData (org.jboss.as.web.common.WarMetaData)4 AnnotationValue (org.jboss.jandex.AnnotationValue)4 ModuleDependency (org.jboss.as.server.deployment.module.ModuleDependency)3 MethodInfo (org.jboss.jandex.MethodInfo)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2