use of org.jboss.jandex.MethodInfo in project wildfly by wildfly.
the class ResourceInjectionAnnotationParsingProcessor method deploy.
public 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);
final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
final PropertyReplacer replacer = EJBAnnotationPropertyReplacement.propertyReplacer(deploymentUnit);
if (module == null) {
return;
}
final List<AnnotationInstance> resourceAnnotations = index.getAnnotations(RESOURCE_ANNOTATION_NAME);
for (AnnotationInstance annotation : resourceAnnotations) {
final AnnotationTarget annotationTarget = annotation.target();
final AnnotationValue nameValue = annotation.value("name");
final String name = (nameValue != null) ? replacer.replaceProperties(nameValue.asString()) : null;
final AnnotationValue typeValue = annotation.value("type");
final String type = typeValue != null ? typeValue.asClass().name().toString() : null;
if (annotationTarget instanceof FieldInfo) {
final FieldInfo fieldInfo = (FieldInfo) annotationTarget;
final ClassInfo classInfo = fieldInfo.declaringClass();
EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
processFieldResource(phaseContext, fieldInfo, name, type, classDescription, annotation, eeModuleDescription, module, applicationClasses, replacer);
} else if (annotationTarget instanceof MethodInfo) {
final MethodInfo methodInfo = (MethodInfo) annotationTarget;
ClassInfo classInfo = methodInfo.declaringClass();
EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
processMethodResource(phaseContext, methodInfo, name, type, classDescription, annotation, eeModuleDescription, module, applicationClasses, replacer);
} else if (annotationTarget instanceof ClassInfo) {
final ClassInfo classInfo = (ClassInfo) annotationTarget;
EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
processClassResource(phaseContext, name, type, classDescription, annotation, eeModuleDescription, module, applicationClasses, replacer);
}
}
final List<AnnotationInstance> resourcesAnnotations = index.getAnnotations(RESOURCES_ANNOTATION_NAME);
for (AnnotationInstance outerAnnotation : resourcesAnnotations) {
final AnnotationTarget annotationTarget = outerAnnotation.target();
if (annotationTarget instanceof ClassInfo) {
final ClassInfo classInfo = (ClassInfo) annotationTarget;
final AnnotationInstance[] values = outerAnnotation.value("value").asNestedArray();
for (AnnotationInstance annotation : values) {
final AnnotationValue nameValue = annotation.value("name");
final String name = (nameValue != null) ? replacer.replaceProperties(nameValue.asString()) : null;
final AnnotationValue typeValue = annotation.value("type");
final String type = (typeValue != null) ? typeValue.asClass().name().toString() : null;
EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
processClassResource(phaseContext, name, type, classDescription, annotation, eeModuleDescription, module, applicationClasses, replacer);
}
}
}
}
use of org.jboss.jandex.MethodInfo in project wildfly by wildfly.
the class LifecycleAnnotationParsingProcessor method processLifeCycle.
private void processLifeCycle(final EEModuleDescription eeModuleDescription, final AnnotationTarget target, final DotName annotationType, final EEApplicationClasses applicationClasses) throws DeploymentUnitProcessingException {
if (!(target instanceof MethodInfo)) {
throw EeLogger.ROOT_LOGGER.methodOnlyAnnotation(annotationType);
}
final MethodInfo methodInfo = MethodInfo.class.cast(target);
final ClassInfo classInfo = methodInfo.declaringClass();
final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
final Type[] args = methodInfo.args();
if (args.length > 1) {
ROOT_LOGGER.warn(EeLogger.ROOT_LOGGER.invalidNumberOfArguments(methodInfo.name(), annotationType, classInfo.name()));
return;
} else if (args.length == 1 && !args[0].name().toString().equals(InvocationContext.class.getName())) {
ROOT_LOGGER.warn(EeLogger.ROOT_LOGGER.invalidSignature(methodInfo.name(), annotationType, classInfo.name(), "void methodName(InvocationContext ctx)"));
return;
}
final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription());
if (annotationType == POST_CONSTRUCT_ANNOTATION) {
builder.setPostConstruct(getMethodIdentifier(args, methodInfo));
} else if (annotationType == PRE_DESTROY_ANNOTATION) {
builder.setPreDestroy(getMethodIdentifier(args, methodInfo));
} else if (annotationType == AROUND_CONSTRUCT_ANNOTATION) {
builder.setAroundConstruct(getMethodIdentifier(args, methodInfo));
}
classDescription.setInterceptorClassDescription(builder.build());
}
use of org.jboss.jandex.MethodInfo in project wildfly by wildfly.
the class EjbResourceInjectionAnnotationProcessor method deploy.
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
final List<AnnotationInstance> resourceAnnotations = index.getAnnotations(EJB_ANNOTATION_NAME);
PropertyReplacer propertyReplacer = EJBAnnotationPropertyReplacement.propertyReplacer(deploymentUnit);
for (AnnotationInstance annotation : resourceAnnotations) {
final AnnotationTarget annotationTarget = annotation.target();
final EJBResourceWrapper annotationWrapper = new EJBResourceWrapper(annotation, propertyReplacer);
if (annotationTarget instanceof FieldInfo) {
processField(deploymentUnit, annotationWrapper, (FieldInfo) annotationTarget, moduleDescription);
} else if (annotationTarget instanceof MethodInfo) {
processMethod(deploymentUnit, annotationWrapper, (MethodInfo) annotationTarget, moduleDescription);
} else if (annotationTarget instanceof ClassInfo) {
processClass(deploymentUnit, annotationWrapper, (ClassInfo) annotationTarget, moduleDescription);
}
}
final List<AnnotationInstance> ejbsAnnotations = index.getAnnotations(EJBS_ANNOTATION_NAME);
for (AnnotationInstance annotation : ejbsAnnotations) {
final AnnotationTarget annotationTarget = annotation.target();
if (annotationTarget instanceof ClassInfo) {
final AnnotationValue annotationValue = annotation.value();
final AnnotationInstance[] ejbAnnotations = annotationValue.asNestedArray();
for (AnnotationInstance ejbAnnotation : ejbAnnotations) {
final EJBResourceWrapper annotationWrapper = new EJBResourceWrapper(ejbAnnotation, propertyReplacer);
processClass(deploymentUnit, annotationWrapper, (ClassInfo) annotationTarget, moduleDescription);
}
} else {
throw EjbLogger.ROOT_LOGGER.annotationOnlyAllowedOnClass(EJBs.class.getName(), annotation.target());
}
}
}
use of org.jboss.jandex.MethodInfo in project wildfly by wildfly.
the class PassivationAnnotationParsingProcessor method processPassivation.
private void processPassivation(final EEModuleDescription eeModuleDescription, final AnnotationTarget target, final DotName annotationType) throws DeploymentUnitProcessingException {
if (!(target instanceof MethodInfo)) {
throw EeLogger.ROOT_LOGGER.methodOnlyAnnotation(annotationType);
}
final MethodInfo methodInfo = MethodInfo.class.cast(target);
final ClassInfo classInfo = methodInfo.declaringClass();
final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
final Type[] args = methodInfo.args();
if (args.length > 1) {
ROOT_LOGGER.warn(EeLogger.ROOT_LOGGER.invalidNumberOfArguments(methodInfo.name(), annotationType, classInfo.name()));
return;
} else if (args.length == 1 && !args[0].name().toString().equals(InvocationContext.class.getName())) {
ROOT_LOGGER.warn(EeLogger.ROOT_LOGGER.invalidSignature(methodInfo.name(), annotationType, classInfo.name(), "void methodName(InvocationContext ctx)"));
return;
}
final MethodIdentifier methodIdentifier;
if (args.length == 0) {
methodIdentifier = MethodIdentifier.getIdentifier(Void.TYPE, methodInfo.name());
} else {
methodIdentifier = MethodIdentifier.getIdentifier(Void.TYPE, methodInfo.name(), InvocationContext.class);
}
final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription());
if (annotationType == POST_ACTIVATE) {
builder.setPostActivate(methodIdentifier);
} else {
builder.setPrePassivate(methodIdentifier);
}
classDescription.setInterceptorClassDescription(builder.build());
}
use of org.jboss.jandex.MethodInfo in project wildfly by wildfly.
the class XTSHandlerDeploymentProcessor method addEndpointsToList.
private void addEndpointsToList(Set<String> endpoints, List<AnnotationInstance> annotations) {
for (AnnotationInstance annotationInstance : annotations) {
Object target = annotationInstance.target();
if (target instanceof ClassInfo) {
final ClassInfo classInfo = (ClassInfo) annotationInstance.target();
final String endpointClass = classInfo.name().toString();
endpoints.add(endpointClass);
} else if (target instanceof MethodInfo) {
final MethodInfo methodInfo = (MethodInfo) target;
final String endpointClass = methodInfo.declaringClass().name().toString();
endpoints.add(endpointClass);
}
}
}
Aggregations