Search in sources :

Example 21 with CompositeIndex

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

the class DefaultModuleServiceProvider method getServices.

@Override
public Collection<Service> getServices(DeploymentUnit rootDeploymentUnit, DeploymentUnit deploymentUnit, Module module, ResourceRoot resourceRoot) {
    List<Service> services = new ArrayList<>();
    // ResourceInjectionServices
    // TODO I'm not quite sure we should use rootDeploymentUnit here
    services.add(new WeldResourceInjectionServices(rootDeploymentUnit.getServiceRegistry(), rootDeploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION), module, DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)));
    // ClassFileServices
    final CompositeIndex index = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
    if (index != null) {
        services.add(new WeldClassFileServices(index, module.getClassLoader()));
    }
    return services;
}
Also used : WeldClassFileServices(org.jboss.as.weld.discovery.WeldClassFileServices) ArrayList(java.util.ArrayList) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) Service(org.jboss.weld.bootstrap.api.Service) WeldResourceInjectionServices(org.jboss.as.weld.services.bootstrap.WeldResourceInjectionServices)

Example 22 with CompositeIndex

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

the class IndexUtils method createIndex.

static CompositeIndex createIndex(Object... resources) throws IOException {
    final ClassLoader classLoader = IndexUtils.class.getClassLoader();
    final Indexer indexer = new Indexer();
    for (Object resource : resources) {
        addResource(resource, indexer, classLoader);
    }
    final Index index = indexer.complete();
    return new CompositeIndex(Collections.singleton(index));
}
Also used : Indexer(org.jboss.jandex.Indexer) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) Index(org.jboss.jandex.Index)

Example 23 with CompositeIndex

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

the class HibernateSearchProcessor method addSearchDependency.

private void addSearchDependency(ModuleSpecification moduleSpecification, ModuleLoader moduleLoader, DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException {
    String searchModuleName = null;
    PersistenceUnitsInApplication persistenceUnitsInApplication = DeploymentUtils.getTopDeploymentUnit(deploymentUnit).getAttachment(PersistenceUnitsInApplication.PERSISTENCE_UNITS_IN_APPLICATION);
    for (PersistenceUnitMetadataHolder holder : persistenceUnitsInApplication.getPersistenceUnitHolders()) {
        for (PersistenceUnitMetadata pu : holder.getPersistenceUnits()) {
            String providerModule = pu.getProperties().getProperty(Configuration.HIBERNATE_SEARCH_MODULE);
            if (providerModule != null) {
                // one persistence unit specifying the Hibernate search module is allowed
                if (searchModuleName == null) {
                    searchModuleName = providerModule;
                } else // more than one persistence unit specifying different Hibernate search module names is not allowed
                if (!providerModule.equals(searchModuleName)) {
                    throw JpaLogger.ROOT_LOGGER.differentSearchModuleDependencies(deploymentUnit.getName(), searchModuleName, providerModule);
                }
            }
        }
    }
    if (NONE.equals(searchModuleName)) {
        // Hibernate Search module will not be added to deployment
        ROOT_LOGGER.debugf("Not adding Hibernate Search dependency to deployment %s", deploymentUnit.getName());
        return;
    }
    // use Search module name specified in persistence unit definition
    if (searchModuleName != null && !IGNORE.equals(searchModuleName)) {
        ModuleIdentifier moduleIdentifier = ModuleIdentifier.fromString(searchModuleName);
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, moduleIdentifier, false, true, true, false));
        ROOT_LOGGER.debugf("added %s dependency to %s", moduleIdentifier, deploymentUnit.getName());
    } else {
        // add Hibernate Search module dependency if application is using the Hibernate Search Indexed annotation
        final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
        List<AnnotationInstance> annotations = index.getAnnotations(SEARCH_INDEXED_ANNOTATION_NAME);
        if (annotations != null && annotations.size() > 0) {
            moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, defaultSearchModule, false, true, true, false));
            ROOT_LOGGER.debugf("deployment %s contains %s annotation, added %s dependency", deploymentUnit.getName(), SEARCH_INDEXED_ANNOTATION_NAME, defaultSearchModule);
        }
    }
}
Also used : ModuleDependency(org.jboss.as.server.deployment.module.ModuleDependency) PersistenceUnitMetadataHolder(org.jboss.as.jpa.config.PersistenceUnitMetadataHolder) PersistenceUnitsInApplication(org.jboss.as.jpa.config.PersistenceUnitsInApplication) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) PersistenceUnitMetadata(org.jipijapa.plugin.spi.PersistenceUnitMetadata) ModuleIdentifier(org.jboss.modules.ModuleIdentifier) AnnotationInstance(org.jboss.jandex.AnnotationInstance)

Example 24 with CompositeIndex

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

the class JPAAnnotationProcessor method deploy.

@Override
public void deploy(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);
    final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    // @PersistenceContext
    List<AnnotationInstance> persistenceContexts = index.getAnnotations(PERSISTENCE_CONTEXT_ANNOTATION_NAME);
    // create binding and injection configurations out of the @PersistenceContext annotations
    this.processPersistenceAnnotations(deploymentUnit, eeModuleDescription, persistenceContexts, applicationClasses);
    // @PersistenceContexts
    List<AnnotationInstance> collectionPersistenceContexts = index.getAnnotations(PERSISTENCE_CONTEXTS_ANNOTATION_NAME);
    // create binding and injection configurations out of the @PersistenceContext annotations
    processPersistenceAnnotations(deploymentUnit, eeModuleDescription, collectionPersistenceContexts, applicationClasses);
    // @PersistenceUnits
    List<AnnotationInstance> collectionPersistenceunits = index.getAnnotations(PERSISTENCE_UNITS_ANNOTATION_NAME);
    processPersistenceAnnotations(deploymentUnit, eeModuleDescription, collectionPersistenceunits, applicationClasses);
    // @PersistenceUnit
    List<AnnotationInstance> persistenceUnits = index.getAnnotations(PERSISTENCE_UNIT_ANNOTATION_NAME);
    // create binding and injection configurations out of the @PersistenceUnit annotations
    this.processPersistenceAnnotations(deploymentUnit, eeModuleDescription, persistenceUnits, applicationClasses);
    // if we found any @PersistenceContext or @PersistenceUnit annotations then mark this as a JPA deployment
    if (!persistenceContexts.isEmpty() || !persistenceUnits.isEmpty() || !collectionPersistenceContexts.isEmpty() || !collectionPersistenceunits.isEmpty()) {
        JPADeploymentMarker.mark(deploymentUnit);
    }
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) AnnotationInstance(org.jboss.jandex.AnnotationInstance)

Example 25 with CompositeIndex

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

the class InboundBridgeDeploymentProcessor method isBridgeRequired.

private boolean isBridgeRequired(final DeploymentUnit deploymentUnit) {
    final CompositeIndex index = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
    if (index == null) {
        return false;
    }
    final List<AnnotationInstance> pathAnnotations = index.getAnnotations(PATH_DOT_NAME);
    for (AnnotationInstance annotationInstance : pathAnnotations) {
        final Object target = annotationInstance.target();
        if (target instanceof ClassInfo) {
            final ClassInfo classInfo = (ClassInfo) target;
            if (classInfo.annotations().get(TRANSACTIONAL_DOT_NAME) != null) {
                return true;
            }
            if (classInfo.annotations().get(TRANSACTION_ATTRIBUTE_DOT_NAME) != null) {
                return true;
            }
        }
    }
    return false;
}
Also used : CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) AnnotationInstance(org.jboss.jandex.AnnotationInstance) ClassInfo(org.jboss.jandex.ClassInfo)

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