Search in sources :

Example 26 with CompositeIndex

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

the class JSFAnnotationProcessor method deploy.

public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final Map<Class<? extends Annotation>, Set<Class<?>>> instances = new HashMap<Class<? extends Annotation>, Set<Class<?>>>();
    final CompositeIndex compositeIndex = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
    if (compositeIndex == null) {
        // Can not continue without index
        return;
    }
    final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    if (module == null) {
        // Can not continue without module
        return;
    }
    final ClassLoader classLoader = module.getClassLoader();
    for (FacesAnnotation annotation : FacesAnnotation.values()) {
        final List<AnnotationInstance> annotationInstances = compositeIndex.getAnnotations(annotation.indexName);
        if (annotationInstances == null || annotationInstances.isEmpty()) {
            continue;
        }
        final Set<Class<?>> discoveredClasses = new HashSet<Class<?>>();
        instances.put(annotation.annotationClass, discoveredClasses);
        for (AnnotationInstance annotationInstance : annotationInstances) {
            final AnnotationTarget target = annotationInstance.target();
            if (target instanceof ClassInfo) {
                final DotName className = ClassInfo.class.cast(target).name();
                final Class<?> annotatedClass;
                try {
                    annotatedClass = classLoader.loadClass(className.toString());
                } catch (ClassNotFoundException e) {
                    throw new DeploymentUnitProcessingException(JSFLogger.ROOT_LOGGER.classLoadingFailed(className));
                }
                discoveredClasses.add(annotatedClass);
            } else {
                throw new DeploymentUnitProcessingException(JSFLogger.ROOT_LOGGER.invalidAnnotationLocation(annotation, target));
            }
        }
    }
    deploymentUnit.addToAttachmentList(ServletContextAttribute.ATTACHMENT_KEY, new ServletContextAttribute(FACES_ANNOTATIONS_SC_ATTR, instances));
}
Also used : AnnotationTarget(org.jboss.jandex.AnnotationTarget) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) DotName(org.jboss.jandex.DotName) Annotation(java.lang.annotation.Annotation) ServletContextAttribute(org.jboss.as.web.common.ServletContextAttribute) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) AnnotationInstance(org.jboss.jandex.AnnotationInstance) HashSet(java.util.HashSet) ClassInfo(org.jboss.jandex.ClassInfo)

Example 27 with CompositeIndex

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

the class EjbContextJndiBindingProcessor method deploy.

/**
     * {@inheritDoc} *
     */
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEResourceReferenceProcessorRegistry registry = deploymentUnit.getAttachment(Attachments.RESOURCE_REFERENCE_PROCESSOR_REGISTRY);
    //setup ejb context jndi handlers
    registry.registerResourceReferenceProcessor(new EjbContextResourceReferenceProcessor(EJBContext.class));
    registry.registerResourceReferenceProcessor(new EjbContextResourceReferenceProcessor(SessionContext.class));
    registry.registerResourceReferenceProcessor(new EjbContextResourceReferenceProcessor(EntityContext.class));
    registry.registerResourceReferenceProcessor(new EjbContextResourceReferenceProcessor(MessageDrivenContext.class));
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final Collection<ComponentDescription> componentConfigurations = eeModuleDescription.getComponentDescriptions();
    if (componentConfigurations == null || componentConfigurations.isEmpty()) {
        return;
    }
    for (ComponentDescription componentConfiguration : componentConfigurations) {
        final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
        if (index != null) {
            processComponentConfig(deploymentUnit, phaseContext, index, componentConfiguration);
        }
    }
}
Also used : EJBContext(javax.ejb.EJBContext) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EjbContextResourceReferenceProcessor(org.jboss.as.ejb3.context.EjbContextResourceReferenceProcessor) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) MessageDrivenContext(javax.ejb.MessageDrivenContext) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) SessionContext(javax.ejb.SessionContext) EntityContext(javax.ejb.EntityContext) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) EEResourceReferenceProcessorRegistry(org.jboss.as.ee.component.deployers.EEResourceReferenceProcessorRegistry)

Example 28 with CompositeIndex

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

the class ApplicationExceptionAnnotationProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (MetadataCompleteMarker.isMetadataComplete(deploymentUnit)) {
        return;
    }
    final CompositeIndex compositeIndex = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
    if (compositeIndex == null) {
        return;
    }
    List<AnnotationInstance> applicationExceptionAnnotations = compositeIndex.getAnnotations(DotName.createSimple(ApplicationException.class.getName()));
    if (applicationExceptionAnnotations == null || applicationExceptionAnnotations.isEmpty()) {
        return;
    }
    ApplicationExceptionDescriptions descriptions = new ApplicationExceptionDescriptions();
    deploymentUnit.putAttachment(EjbDeploymentAttachmentKeys.APPLICATION_EXCEPTION_DESCRIPTIONS, descriptions);
    for (AnnotationInstance annotationInstance : applicationExceptionAnnotations) {
        AnnotationTarget target = annotationInstance.target();
        if (!(target instanceof ClassInfo)) {
            throw EjbLogger.ROOT_LOGGER.annotationOnlyAllowedOnClass(ApplicationException.class.getName(), target);
        }
        String exceptionClassName = ((ClassInfo) target).name().toString();
        boolean rollback = false;
        AnnotationValue rollBackAnnValue = annotationInstance.value("rollback");
        if (rollBackAnnValue != null) {
            rollback = rollBackAnnValue.asBoolean();
        }
        // default "inherited" is true
        boolean inherited = true;
        AnnotationValue inheritedAnnValue = annotationInstance.value("inherited");
        if (inheritedAnnValue != null) {
            inherited = inheritedAnnValue.asBoolean();
        }
        descriptions.addApplicationException(exceptionClassName, rollback, inherited);
    }
}
Also used : AnnotationTarget(org.jboss.jandex.AnnotationTarget) ApplicationException(javax.ejb.ApplicationException) ApplicationExceptionDescriptions(org.jboss.as.ejb3.deployment.ApplicationExceptionDescriptions) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) AnnotationValue(org.jboss.jandex.AnnotationValue) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) AnnotationInstance(org.jboss.jandex.AnnotationInstance) ClassInfo(org.jboss.jandex.ClassInfo)

Example 29 with CompositeIndex

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

the class AroundTimeoutAnnotationParsingProcessor method deploy.

public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (MetadataCompleteMarker.isMetadataComplete(deploymentUnit)) {
        return;
    }
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
    final List<AnnotationInstance> aroundInvokes = index.getAnnotations(AROUND_TIMEOUT_ANNOTATION_NAME);
    for (AnnotationInstance annotation : aroundInvokes) {
        processAroundInvoke(annotation.target(), eeModuleDescription);
    }
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) AnnotationInstance(org.jboss.jandex.AnnotationInstance)

Example 30 with CompositeIndex

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

the class WebServiceAnnotationProcessor method deploy.

@SuppressWarnings({ "unchecked", "rawtypes" })
public final void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
    if (index == null || eeModuleDescription == null) {
        return;
    }
    for (final ClassAnnotationInformationFactory factory : factories) {
        final Map<String, ClassAnnotationInformation<?, ?>> data = factory.createAnnotationInformation(index, PropertyReplacers.noop());
        for (Map.Entry<String, ClassAnnotationInformation<?, ?>> entry : data.entrySet()) {
            EEModuleClassDescription clazz = eeModuleDescription.addOrGetLocalClassDescription(entry.getKey());
            clazz.addAnnotationInformation(entry.getValue());
        }
    }
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ClassAnnotationInformation(org.jboss.as.ee.metadata.ClassAnnotationInformation) ClassAnnotationInformationFactory(org.jboss.as.ee.metadata.ClassAnnotationInformationFactory) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) EEModuleClassDescription(org.jboss.as.ee.component.EEModuleClassDescription) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) Map(java.util.Map)

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