Search in sources :

Example 46 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 47 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 48 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)

Example 49 with CompositeIndex

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

the class AbstractIntegrationProcessorJAXWS method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit unit = phaseContext.getDeploymentUnit();
    if (DeploymentTypeMarker.isType(DeploymentType.EAR, unit)) {
        return;
    }
    final CompositeIndex index = unit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
    if (index == null) {
        return;
    }
    final EEModuleDescription eeModuleDescription = unit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
    processAnnotation(unit, 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)

Example 50 with CompositeIndex

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

the class TransactionDependenciesProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit unit = phaseContext.getDeploymentUnit();
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    final ModuleSpecification moduleSpec = unit.getAttachment(Attachments.MODULE_SPECIFICATION);
    moduleSpec.addSystemDependency(new ModuleDependency(moduleLoader, TRANSACTION_API, false, false, true, false));
    moduleSpec.addSystemDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.fromString("org.wildfly.transaction.client"), false, false, true, false));
    final CompositeIndex compositeIndex = unit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
    if (compositeIndex == null) {
        return;
    }
    final List<AnnotationInstance> transactionalAnnotations = compositeIndex.getAnnotations(DotName.createSimple(Transactional.class.getName()));
    final List<AnnotationInstance> transactionScopedAnnotations = compositeIndex.getAnnotations(DotName.createSimple(TransactionScoped.class.getName()));
    if (!transactionalAnnotations.isEmpty() || !transactionScopedAnnotations.isEmpty()) {
        addJTSModuleDependencyToDeployment(unit);
    }
}
Also used : ModuleLoader(org.jboss.modules.ModuleLoader) ModuleDependency(org.jboss.as.server.deployment.module.ModuleDependency) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) AnnotationInstance(org.jboss.jandex.AnnotationInstance)

Aggregations

CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)53 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)37 AnnotationInstance (org.jboss.jandex.AnnotationInstance)23 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)20 ClassInfo (org.jboss.jandex.ClassInfo)17 HashSet (java.util.HashSet)11 DotName (org.jboss.jandex.DotName)10 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)9 AnnotationValue (org.jboss.jandex.AnnotationValue)8 Module (org.jboss.modules.Module)8 AnnotationTarget (org.jboss.jandex.AnnotationTarget)7 HashMap (java.util.HashMap)6 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)6 EEModuleClassDescription (org.jboss.as.ee.component.EEModuleClassDescription)6 WarMetaData (org.jboss.as.web.common.WarMetaData)6 PropertyReplacer (org.jboss.metadata.property.PropertyReplacer)6 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)4 ArrayList (java.util.ArrayList)3 ModuleDependency (org.jboss.as.server.deployment.module.ModuleDependency)3 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)3