use of org.jboss.jandex.MethodInfo in project wildfly by wildfly.
the class AroundTimeoutAnnotationParsingProcessor method processAroundInvoke.
private void processAroundInvoke(final AnnotationTarget target, final EEModuleDescription eeModuleDescription) {
if (!(target instanceof MethodInfo)) {
throw EjbLogger.ROOT_LOGGER.annotationApplicableOnlyForMethods(AROUND_TIMEOUT_ANNOTATION_NAME.toString());
}
final MethodInfo methodInfo = MethodInfo.class.cast(target);
final ClassInfo classInfo = methodInfo.declaringClass();
final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
validateArgumentType(classInfo, methodInfo);
final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription());
builder.setAroundTimeout(MethodIdentifier.getIdentifier(Object.class, methodInfo.name(), InvocationContext.class));
classDescription.setInterceptorClassDescription(builder.build());
}
use of org.jboss.jandex.MethodInfo in project wildfly by wildfly.
the class JandexHelper method getAnnotation.
public static AnnotationInstance getAnnotation(DeploymentUnit unit, String endpoint, String annotationClassName) {
final List<AnnotationInstance> annotations = ASHelper.getAnnotations(unit, DotName.createSimple(annotationClassName));
for (AnnotationInstance annotationInstance : annotations) {
Object target = annotationInstance.target();
if (target instanceof ClassInfo) {
final ClassInfo classInfo = (ClassInfo) target;
final String endpointClass = classInfo.name().toString();
if (endpointClass.equals(endpoint)) {
return annotationInstance;
}
} else if (target instanceof MethodInfo) {
final MethodInfo methodInfo = (MethodInfo) target;
final String endpointClass = methodInfo.declaringClass().name().toString();
if (endpointClass.equals(endpoint)) {
return annotationInstance;
}
}
}
return null;
}
use of org.jboss.jandex.MethodInfo in project wildfly by wildfly.
the class ServletContainerInitializerDeploymentProcessor method processHandlesType.
private Set<ClassInfo> processHandlesType(DotName typeName, Class<?> type, CompositeIndex index, CompositeIndex parent) throws DeploymentUnitProcessingException {
Set<ClassInfo> classes = new HashSet<ClassInfo>();
if (type.isAnnotation()) {
List<AnnotationInstance> instances = index.getAnnotations(typeName);
for (AnnotationInstance instance : instances) {
AnnotationTarget annotationTarget = instance.target();
if (annotationTarget instanceof ClassInfo) {
classes.add((ClassInfo) annotationTarget);
} else if (annotationTarget instanceof FieldInfo) {
classes.add(((FieldInfo) annotationTarget).declaringClass());
} else if (annotationTarget instanceof MethodInfo) {
classes.add(((MethodInfo) annotationTarget).declaringClass());
} else if (annotationTarget instanceof MethodParameterInfo) {
classes.add(((MethodParameterInfo) annotationTarget).method().declaringClass());
}
}
} else {
classes.addAll(index.getAllKnownSubclasses(typeName));
classes.addAll(index.getAllKnownImplementors(typeName));
if (parent != null) {
Set<ClassInfo> parentImplementors = new HashSet<>();
parentImplementors.addAll(parent.getAllKnownImplementors(typeName));
parentImplementors.addAll(parent.getAllKnownSubclasses(typeName));
for (ClassInfo pc : parentImplementors) {
classes.addAll(index.getAllKnownSubclasses(pc.name()));
classes.addAll(index.getAllKnownImplementors(pc.name()));
}
}
}
return classes;
}
use of org.jboss.jandex.MethodInfo in project wildfly by wildfly.
the class WSRefAnnotationProcessor method deploy.
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit unit = phaseContext.getDeploymentUnit();
// Process @WebServiceRef annotations
final List<AnnotationInstance> webServiceRefAnnotations = getAnnotations(unit, WEB_SERVICE_REF_ANNOTATION);
for (final AnnotationInstance annotation : webServiceRefAnnotations) {
final AnnotationTarget annotationTarget = annotation.target();
final WSRefAnnotationWrapper annotationWrapper = new WSRefAnnotationWrapper(annotation);
if (annotationTarget instanceof FieldInfo) {
processFieldRef(unit, annotationWrapper, (FieldInfo) annotationTarget);
} else if (annotationTarget instanceof MethodInfo) {
processMethodRef(unit, annotationWrapper, (MethodInfo) annotationTarget);
} else if (annotationTarget instanceof ClassInfo) {
processClassRef(unit, annotationWrapper, (ClassInfo) annotationTarget);
}
}
// Process @WebServiceRefs annotations
final List<AnnotationInstance> webServiceRefsAnnotations = getAnnotations(unit, WEB_SERVICE_REFS_ANNOTATION);
for (final AnnotationInstance outerAnnotation : webServiceRefsAnnotations) {
final AnnotationTarget annotationTarget = outerAnnotation.target();
if (annotationTarget instanceof ClassInfo) {
final AnnotationInstance[] values = outerAnnotation.value("value").asNestedArray();
for (final AnnotationInstance annotation : values) {
final WSRefAnnotationWrapper annotationWrapper = new WSRefAnnotationWrapper(annotation);
processClassRef(unit, annotationWrapper, (ClassInfo) annotationTarget);
}
}
}
}
Aggregations