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;
}
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);
}
}
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);
}
}
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);
}
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());
}
}
}
Aggregations