use of org.jboss.as.server.deployment.annotation.CompositeIndex in project wildfly by wildfly.
the class JSFAnnotationProcessor method deploy.
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final Map<Class<? extends Annotation>, Set<Class<?>>> instances = new HashMap<Class<? extends Annotation>, Set<Class<?>>>();
final CompositeIndex compositeIndex = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
if (compositeIndex == null) {
// Can not continue without index
return;
}
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
if (module == null) {
// Can not continue without module
return;
}
final ClassLoader classLoader = module.getClassLoader();
for (FacesAnnotation annotation : FacesAnnotation.values()) {
final List<AnnotationInstance> annotationInstances = compositeIndex.getAnnotations(annotation.indexName);
if (annotationInstances == null || annotationInstances.isEmpty()) {
continue;
}
final Set<Class<?>> discoveredClasses = new HashSet<Class<?>>();
instances.put(annotation.annotationClass, discoveredClasses);
for (AnnotationInstance annotationInstance : annotationInstances) {
final AnnotationTarget target = annotationInstance.target();
if (target instanceof ClassInfo) {
final DotName className = ClassInfo.class.cast(target).name();
final Class<?> annotatedClass;
try {
annotatedClass = classLoader.loadClass(className.toString());
} catch (ClassNotFoundException e) {
throw new DeploymentUnitProcessingException(JSFLogger.ROOT_LOGGER.classLoadingFailed(className));
}
discoveredClasses.add(annotatedClass);
} else {
throw new DeploymentUnitProcessingException(JSFLogger.ROOT_LOGGER.invalidAnnotationLocation(annotation, target));
}
}
}
deploymentUnit.addToAttachmentList(ServletContextAttribute.ATTACHMENT_KEY, new ServletContextAttribute(FACES_ANNOTATIONS_SC_ATTR, instances));
}
use of org.jboss.as.server.deployment.annotation.CompositeIndex in project wildfly by wildfly.
the class EjbContextJndiBindingProcessor method deploy.
/**
* {@inheritDoc} *
*/
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEResourceReferenceProcessorRegistry registry = deploymentUnit.getAttachment(Attachments.RESOURCE_REFERENCE_PROCESSOR_REGISTRY);
//setup ejb context jndi handlers
registry.registerResourceReferenceProcessor(new EjbContextResourceReferenceProcessor(EJBContext.class));
registry.registerResourceReferenceProcessor(new EjbContextResourceReferenceProcessor(SessionContext.class));
registry.registerResourceReferenceProcessor(new EjbContextResourceReferenceProcessor(EntityContext.class));
registry.registerResourceReferenceProcessor(new EjbContextResourceReferenceProcessor(MessageDrivenContext.class));
final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
final Collection<ComponentDescription> componentConfigurations = eeModuleDescription.getComponentDescriptions();
if (componentConfigurations == null || componentConfigurations.isEmpty()) {
return;
}
for (ComponentDescription componentConfiguration : componentConfigurations) {
final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
if (index != null) {
processComponentConfig(deploymentUnit, phaseContext, index, componentConfiguration);
}
}
}
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);
}
}
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);
}
}
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());
}
}
}
Aggregations