Search in sources :

Example 36 with Index

use of org.jboss.jandex.Index in project wildfly by wildfly.

the class WSHandlerChainAnnotationProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit unit = phaseContext.getDeploymentUnit();
    if (DeploymentTypeMarker.isType(DeploymentType.EAR, unit)) {
        return;
    }
    List<ResourceRoot> resourceRoots = ASHelper.getResourceRoots(unit);
    if (resourceRoots == null) {
        return;
    }
    final WSEndpointHandlersMapping mapping = new WSEndpointHandlersMapping();
    Index index = null;
    for (final ResourceRoot resourceRoot : resourceRoots) {
        index = resourceRoot.getAttachment(ANNOTATION_INDEX);
        if (index != null) {
            // process @HandlerChain annotations
            processHandlerChainAnnotations(resourceRoot, resourceRoots, index, mapping);
        }
    }
    if (!mapping.isEmpty()) {
        unit.putAttachment(WS_ENDPOINT_HANDLERS_MAPPING_KEY, mapping);
    }
}
Also used : ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) Index(org.jboss.jandex.Index) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 37 with Index

use of org.jboss.jandex.Index in project wildfly by wildfly.

the class ServerInterceptorCache method loadServerInterceptors.

private void loadServerInterceptors() {
    serverInterceptorsAroundInvoke = new ArrayList<>();
    serverInterceptorsAroundTimeout = new ArrayList<>();
    for (final ServerInterceptorMetaData si : serverInterceptorMetaData) {
        final Class<?> interceptorClass;
        final ModuleIdentifier moduleId = ModuleIdentifier.create(si.getModule());
        try {
            final Module module = Module.getCallerModuleLoader().loadModule(moduleId);
            interceptorClass = ClassLoadingUtils.loadClass(si.getClazz(), module);
        } catch (ModuleLoadException e) {
            throw EjbLogger.ROOT_LOGGER.cannotLoadServerInterceptorModule(moduleId, e);
        } catch (ClassNotFoundException e) {
            throw EeLogger.ROOT_LOGGER.cannotLoadInterceptor(e, si.getClazz());
        }
        final Index index = buildIndexForClass(interceptorClass);
        serverInterceptorsAroundInvoke.addAll(findAnnotatedMethods(interceptorClass, index, AroundInvoke.class));
        serverInterceptorsAroundTimeout.addAll(findAnnotatedMethods(interceptorClass, index, AroundTimeout.class));
    }
}
Also used : ModuleLoadException(org.jboss.modules.ModuleLoadException) Index(org.jboss.jandex.Index) ModuleIdentifier(org.jboss.modules.ModuleIdentifier) AroundTimeout(javax.interceptor.AroundTimeout) Module(org.jboss.modules.Module) AroundInvoke(javax.interceptor.AroundInvoke)

Example 38 with Index

use of org.jboss.jandex.Index in project wildfly by wildfly.

the class EjbValidationsUtilTest method buildClassInfoForClass.

private ClassInfo buildClassInfoForClass(String mdbClassName) {
    String mdbClassNameAsResource = mdbClassName.replaceAll("\\.", "/").concat(".class");
    Index index = indexStream(getClass().getClassLoader().getResourceAsStream(mdbClassNameAsResource)).complete();
    return index.getClassByName(DotName.createSimple(mdbClassName));
}
Also used : Index(org.jboss.jandex.Index)

Example 39 with Index

use of org.jboss.jandex.Index in project wildfly by wildfly.

the class JBossPersistenceMetaDataFactory method findPersistenceTypeNames.

private Set<String> findPersistenceTypeNames(PersistenceUnitMetadata pu) {
    synchronized (CACHED_TYPENAMES) {
        Set<String> typeNames = CACHED_TYPENAMES.get(pu);
        if (typeNames != null) {
            return typeNames;
        }
    }
    Set<String> persistenceTypeNames = new HashSet<String>();
    for (Map.Entry<URL, Index> entry : pu.getAnnotationIndex().entrySet()) {
        List<AnnotationInstance> instances = entry.getValue().getAnnotations(DotName.createSimple(Entity.class.getName()));
        for (AnnotationInstance instance : instances) {
            AnnotationTarget target = instance.target();
            if (target instanceof ClassInfo) {
                ClassInfo classInfo = (ClassInfo) target;
                persistenceTypeNames.add(classInfo.name().toString());
            }
        }
    }
    synchronized (CACHED_TYPENAMES) {
        CACHED_TYPENAMES.put(pu, persistenceTypeNames);
    }
    return persistenceTypeNames;
}
Also used : AnnotationTarget(org.jboss.jandex.AnnotationTarget) Index(org.jboss.jandex.Index) HashMap(java.util.HashMap) Map(java.util.Map) URL(java.net.URL) AnnotationInstance(org.jboss.jandex.AnnotationInstance) HashSet(java.util.HashSet) ClassInfo(org.jboss.jandex.ClassInfo)

Example 40 with Index

use of org.jboss.jandex.Index in project wildfly by wildfly.

the class ParsedRaDeploymentProcessor method process.

public static ServiceBuilder<ResourceAdapterDeployment> process(final ConnectorXmlDescriptor connectorXmlDescriptor, final IronJacamarXmlDescriptor ironJacamarXmlDescriptor, final ClassLoader classLoader, final ServiceTarget serviceTarget, final Map<ResourceRoot, Index> annotationIndexes, final ServiceName duServiceName, final ManagementResourceRegistration registration, Resource deploymentResource, final CapabilityServiceSupport support) throws DeploymentUnitProcessingException {
    Connector cmd = connectorXmlDescriptor != null ? connectorXmlDescriptor.getConnector() : null;
    final Activation activation = ironJacamarXmlDescriptor != null ? ironJacamarXmlDescriptor.getIronJacamar() : null;
    try {
        // Annotation merging
        Annotations annotator = new Annotations();
        if (annotationIndexes != null && annotationIndexes.size() > 0) {
            DEPLOYMENT_CONNECTOR_LOGGER.debugf("ParsedRaDeploymentProcessor: Found %d annotationIndexes", annotationIndexes.size());
            for (Index index : annotationIndexes.values()) {
                // Don't apply any empty indexes, as IronJacamar doesn't like that atm.
                if (index.getKnownClasses() != null && !index.getKnownClasses().isEmpty()) {
                    AnnotationRepository repository = new JandexAnnotationRepositoryImpl(index, classLoader);
                    cmd = annotator.merge(cmd, repository, classLoader);
                    DEPLOYMENT_CONNECTOR_LOGGER.debugf("ParsedRaDeploymentProcessor: CMD=%s", cmd);
                }
            }
        }
        if (annotationIndexes == null || annotationIndexes.size() == 0)
            DEPLOYMENT_CONNECTOR_LOGGER.debugf("ParsedRaDeploymentProcessor: Found 0 annotationIndexes");
        // FIXME: when the connector is null the Iron Jacamar data is ignored
        if (cmd != null) {
            // Validate metadata
            cmd.validate();
            // Merge metadata
            cmd = (new Merger()).mergeConnectorWithCommonIronJacamar(activation, cmd);
        }
        TransactionSupportEnum transactionSupport = TransactionSupportEnum.NoTransaction;
        if (cmd != null && cmd.getResourceadapter() != null && cmd.getResourceadapter().getOutboundResourceadapter() != null) {
            transactionSupport = cmd.getResourceadapter().getOutboundResourceadapter().getTransactionSupport();
        }
        if (activation != null && activation.getTransactionSupport() != null) {
            transactionSupport = activation.getTransactionSupport();
        }
        final ServiceName deployerServiceName = ConnectorServices.RESOURCE_ADAPTER_DEPLOYER_SERVICE_PREFIX.append(connectorXmlDescriptor.getDeploymentName());
        final ResourceAdapterDeploymentService raDeploymentService = new ResourceAdapterDeploymentService(connectorXmlDescriptor, cmd, activation, classLoader, deployerServiceName, duServiceName, registration, deploymentResource);
        // Create the service
        ServiceBuilder<ResourceAdapterDeployment> builder = Services.addServerExecutorDependency(serviceTarget.addService(deployerServiceName, raDeploymentService), raDeploymentService.getExecutorServiceInjector()).addDependency(ConnectorServices.IRONJACAMAR_MDR, AS7MetadataRepository.class, raDeploymentService.getMdrInjector()).addDependency(ConnectorServices.RA_REPOSITORY_SERVICE, ResourceAdapterRepository.class, raDeploymentService.getRaRepositoryInjector()).addDependency(ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE, ManagementRepository.class, raDeploymentService.getManagementRepositoryInjector()).addDependency(ConnectorServices.RESOURCE_ADAPTER_REGISTRY_SERVICE, ResourceAdapterDeploymentRegistry.class, raDeploymentService.getRegistryInjector()).addDependency(support.getCapabilityServiceName(ConnectorServices.TRANSACTION_INTEGRATION_CAPABILITY_NAME), TransactionIntegration.class, raDeploymentService.getTxIntegrationInjector()).addDependency(ConnectorServices.CONNECTOR_CONFIG_SERVICE, JcaSubsystemConfiguration.class, raDeploymentService.getConfigInjector());
        builder.requires(ConnectorServices.IDLE_REMOVER_SERVICE);
        builder.requires(ConnectorServices.CONNECTION_VALIDATOR_SERVICE);
        builder.requires(support.getCapabilityServiceName(NamingService.CAPABILITY_NAME));
        if (transactionSupport == null || transactionSupport.equals(TransactionSupportEnum.NoTransaction)) {
            builder.addDependency(ConnectorServices.NON_TX_CCM_SERVICE, CachedConnectionManager.class, raDeploymentService.getCcmInjector());
        } else {
            builder.addDependency(ConnectorServices.CCM_SERVICE, CachedConnectionManager.class, raDeploymentService.getCcmInjector());
        }
        if (activation != null && ActivationSecurityUtil.isLegacySecurityRequired(activation)) {
            throw ConnectorLogger.DS_DEPLOYER_LOGGER.legacySecurityNotAvailableForRa(connectorXmlDescriptor.getDeploymentName());
        }
        return builder;
    } catch (Throwable t) {
        throw new DeploymentUnitProcessingException(t);
    }
}
Also used : JandexAnnotationRepositoryImpl(org.jboss.as.connector.annotations.repository.jandex.JandexAnnotationRepositoryImpl) ResourceAdapterDeployment(org.jboss.as.connector.metadata.deployment.ResourceAdapterDeployment) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) Connector(org.jboss.jca.common.api.metadata.spec.Connector) TransactionIntegration(org.jboss.jca.core.spi.transaction.TransactionIntegration) Activation(org.jboss.jca.common.api.metadata.resourceadapter.Activation) Index(org.jboss.jandex.Index) ResourceAdapterDeploymentService(org.jboss.as.connector.services.resourceadapters.deployment.ResourceAdapterDeploymentService) AS7MetadataRepository(org.jboss.as.connector.services.mdr.AS7MetadataRepository) Annotations(org.jboss.jca.common.annotations.Annotations) Merger(org.jboss.jca.common.metadata.merge.Merger) ManagementRepository(org.jboss.jca.core.api.management.ManagementRepository) ServiceName(org.jboss.msc.service.ServiceName) AnnotationRepository(org.jboss.jca.common.spi.annotations.repository.AnnotationRepository) TransactionSupportEnum(org.jboss.jca.common.api.metadata.common.TransactionSupportEnum)

Aggregations

Index (org.jboss.jandex.Index)50 Indexer (org.jboss.jandex.Indexer)24 InputStream (java.io.InputStream)21 Test (org.junit.Test)18 File (java.io.File)16 URI (java.net.URI)15 AnnotationRepository (org.jboss.jca.common.spi.annotations.repository.AnnotationRepository)13 VirtualFile (org.jboss.vfs.VirtualFile)13 URL (java.net.URL)11 SuffixMatchFilter (org.jboss.vfs.util.SuffixMatchFilter)11 ClassInfo (org.jboss.jandex.ClassInfo)10 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)8 IOException (java.io.IOException)7 HashMap (java.util.HashMap)6 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)6 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)5 Map (java.util.Map)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 CompositeIndex (org.jboss.jandex.CompositeIndex)4