Search in sources :

Example 41 with CompositeIndex

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

the class ResourceLookupDependenciesProvider method getDependencies.

@Override
public Set<ServiceName> getDependencies(DeploymentUnit unit) {
    CompositeIndex index = unit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
    PropertyReplacer replacer = EJBAnnotationPropertyReplacement.propertyReplacer(unit);
    List<AnnotationInstance> annotations = index.getAnnotations(RESOURCE_ANNOTATION_NAME);
    Set<ServiceName> result = !annotations.isEmpty() ? new TreeSet<>() : Collections.emptySet();
    for (AnnotationInstance annotation : annotations) {
        AnnotationValue lookupValue = annotation.value("lookup");
        if (lookupValue != null) {
            String lookup = replacer.replaceProperties(lookupValue.asString());
            try {
                ServiceName name = ContextNames.bindInfoFor(lookup).getBinderServiceName();
                if (ContextNames.JBOSS_CONTEXT_SERVICE_NAME.isParentOf(name)) {
                    result.add(name);
                }
            } catch (RuntimeException e) {
            // No associated naming store
            }
        }
    }
    return result;
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) AnnotationValue(org.jboss.jandex.AnnotationValue) PropertyReplacer(org.jboss.metadata.property.PropertyReplacer) AnnotationInstance(org.jboss.jandex.AnnotationInstance)

Example 42 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)

Example 43 with CompositeIndex

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

the class XTSDependenciesDeploymentProcessor 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) || isTransactionalEndpointPresent(compositeIndex)) {
        addXTSModuleDependency(unit);
    }
}
Also used : CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 44 with CompositeIndex

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

the class JaxrsMethodParameterProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!JaxrsDeploymentMarker.isJaxrsDeployment(deploymentUnit)) {
        return;
    }
    if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
        return;
    }
    final ResteasyDeploymentData resteasy = deploymentUnit.getAttachment(JaxrsAttachments.RESTEASY_DEPLOYMENT_DATA);
    if (resteasy == null) {
        return;
    }
    final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    final CompositeIndex index = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
    processData(index, module.getClassLoader(), resteasy, false);
}
Also used : CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 45 with CompositeIndex

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

the class JaxrsScanningProcessor method scan.

protected void scan(final DeploymentUnit du, final ClassLoader classLoader, final ResteasyDeploymentData resteasyDeploymentData) throws DeploymentUnitProcessingException, ModuleLoadException {
    final CompositeIndex index = du.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
    if (!resteasyDeploymentData.shouldScan()) {
        return;
    }
    if (!resteasyDeploymentData.isDispatcherCreated()) {
        final Set<ClassInfo> applicationClasses = index.getAllKnownSubclasses(APPLICATION);
        try {
            for (ClassInfo c : applicationClasses) {
                if (Modifier.isAbstract(c.flags()))
                    continue;
                @SuppressWarnings("unchecked") Class<? extends Application> scanned = (Class<? extends Application>) classLoader.loadClass(c.name().toString());
                resteasyDeploymentData.getScannedApplicationClasses().add(scanned);
            }
        } catch (ClassNotFoundException e) {
            throw JaxrsLogger.JAXRS_LOGGER.cannotLoadApplicationClass(e);
        }
    }
    List<AnnotationInstance> resources = null;
    List<AnnotationInstance> providers = null;
    if (resteasyDeploymentData.isScanResources()) {
        resources = index.getAnnotations(JaxrsAnnotations.PATH.getDotName());
    }
    if (resteasyDeploymentData.isScanProviders()) {
        providers = index.getAnnotations(JaxrsAnnotations.PROVIDER.getDotName());
    }
    if ((resources == null || resources.isEmpty()) && (providers == null || providers.isEmpty()))
        return;
    final Set<ClassInfo> pathInterfaces = new HashSet<ClassInfo>();
    if (resources != null) {
        for (AnnotationInstance e : resources) {
            final ClassInfo info;
            if (e.target() instanceof ClassInfo) {
                info = (ClassInfo) e.target();
            } else if (e.target() instanceof MethodInfo) {
                // ignore
                continue;
            } else {
                JAXRS_LOGGER.classOrMethodAnnotationNotFound("@Path", e.target());
                continue;
            }
            if (info.name().toString().startsWith(ORG_APACHE_CXF)) {
                // see WFLY-9752
                continue;
            }
            if (info.annotations().containsKey(DECORATOR)) {
                // we can't pick up on programatically added decorators, but that is such an edge case it should not really matter
                continue;
            }
            if (!Modifier.isInterface(info.flags())) {
                resteasyDeploymentData.getScannedResourceClasses().add(info.name().toString());
            } else {
                pathInterfaces.add(info);
            }
        }
    }
    if (providers != null) {
        for (AnnotationInstance e : providers) {
            if (e.target() instanceof ClassInfo) {
                ClassInfo info = (ClassInfo) e.target();
                if (info.name().toString().startsWith(ORG_APACHE_CXF)) {
                    // see WFLY-9752
                    continue;
                }
                if (info.annotations().containsKey(DECORATOR)) {
                    // we can't pick up on programatically added decorators, but that is such an edge case it should not really matter
                    continue;
                }
                if (!Modifier.isInterface(info.flags())) {
                    resteasyDeploymentData.getScannedProviderClasses().add(info.name().toString());
                }
            } else {
                JAXRS_LOGGER.classAnnotationNotFound("@Provider", e.target());
            }
        }
    }
    // look for all implementations of interfaces annotated @Path
    for (final ClassInfo iface : pathInterfaces) {
        final Set<ClassInfo> implementors = index.getAllKnownImplementors(iface.name());
        for (final ClassInfo implementor : implementors) {
            if (implementor.name().toString().startsWith(ORG_APACHE_CXF)) {
                // see WFLY-9752
                continue;
            }
            if (implementor.annotations().containsKey(DECORATOR)) {
                // we can't pick up on programatically added decorators, but that is such an edge case it should not really matter
                continue;
            }
            resteasyDeploymentData.getScannedResourceClasses().add(implementor.name().toString());
        }
    }
}
Also used : CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) MethodInfo(org.jboss.jandex.MethodInfo) Application(javax.ws.rs.core.Application) AnnotationInstance(org.jboss.jandex.AnnotationInstance) ClassInfo(org.jboss.jandex.ClassInfo) HashSet(java.util.HashSet)

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