Search in sources :

Example 21 with MethodInfo

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());
}
Also used : InterceptorClassDescription(org.jboss.as.ee.component.interceptors.InterceptorClassDescription) MethodInfo(org.jboss.jandex.MethodInfo) EEModuleClassDescription(org.jboss.as.ee.component.EEModuleClassDescription) InvocationContext(javax.interceptor.InvocationContext) ClassInfo(org.jboss.jandex.ClassInfo)

Example 22 with MethodInfo

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;
}
Also used : MethodInfo(org.jboss.jandex.MethodInfo) AnnotationInstance(org.jboss.jandex.AnnotationInstance) ClassInfo(org.jboss.jandex.ClassInfo)

Example 23 with MethodInfo

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;
}
Also used : AnnotationTarget(org.jboss.jandex.AnnotationTarget) MethodInfo(org.jboss.jandex.MethodInfo) MethodParameterInfo(org.jboss.jandex.MethodParameterInfo) AnnotationInstance(org.jboss.jandex.AnnotationInstance) FieldInfo(org.jboss.jandex.FieldInfo) ClassInfo(org.jboss.jandex.ClassInfo) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 24 with MethodInfo

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);
            }
        }
    }
}
Also used : AnnotationTarget(org.jboss.jandex.AnnotationTarget) MethodInfo(org.jboss.jandex.MethodInfo) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) AnnotationInstance(org.jboss.jandex.AnnotationInstance) FieldInfo(org.jboss.jandex.FieldInfo) ClassInfo(org.jboss.jandex.ClassInfo)

Aggregations

MethodInfo (org.jboss.jandex.MethodInfo)24 AnnotationInstance (org.jboss.jandex.AnnotationInstance)18 ClassInfo (org.jboss.jandex.ClassInfo)18 EEModuleClassDescription (org.jboss.as.ee.component.EEModuleClassDescription)7 FieldInfo (org.jboss.jandex.FieldInfo)7 AnnotationTarget (org.jboss.jandex.AnnotationTarget)6 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)5 InterceptorClassDescription (org.jboss.as.ee.component.interceptors.InterceptorClassDescription)5 InvocationContext (javax.interceptor.InvocationContext)4 AnnotationValue (org.jboss.jandex.AnnotationValue)4 Type (org.jboss.jandex.Type)4 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)3 CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)3 MethodIdentifier (org.jboss.invocation.proxy.MethodIdentifier)3 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)2 DotName (org.jboss.jandex.DotName)2 MethodParameterInfo (org.jboss.jandex.MethodParameterInfo)2 PropertyReplacer (org.jboss.metadata.property.PropertyReplacer)2 JBossWebContainer (org.wildfly.swarm.undertow.descriptors.JBossWebContainer)2