Search in sources :

Example 36 with ClassInfo

use of org.jboss.jandex.ClassInfo in project wildfly by wildfly.

the class ServletContainerInitializerDeploymentProcessor method loadClassInfoSet.

private Set<Class<?>> loadClassInfoSet(Set<ClassInfo> classInfos, ClassLoader classLoader) throws DeploymentUnitProcessingException {
    Set<Class<?>> classes = new HashSet<Class<?>>();
    for (ClassInfo classInfo : classInfos) {
        Class<?> type;
        try {
            type = classLoader.loadClass(classInfo.name().toString());
            classes.add(type);
        } catch (Exception e) {
            UndertowLogger.ROOT_LOGGER.cannotLoadDesignatedHandleTypes(classInfo, e);
        }
    }
    return classes;
}
Also used : ModuleLoadException(org.jboss.modules.ModuleLoadException) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) IOException(java.io.IOException) HashSet(java.util.HashSet) ClassInfo(org.jboss.jandex.ClassInfo)

Example 37 with ClassInfo

use of org.jboss.jandex.ClassInfo in project wildfly by wildfly.

the class ServletContainerInitializerDeploymentProcessor method processHandlesType.

private Set<ClassInfo> processHandlesType(DotName typeName, Class<?> type, CompositeIndex index) 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));
    }
    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) HashSet(java.util.HashSet) ClassInfo(org.jboss.jandex.ClassInfo)

Example 38 with ClassInfo

use of org.jboss.jandex.ClassInfo 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)

Example 39 with ClassInfo

use of org.jboss.jandex.ClassInfo in project wildfly by wildfly.

the class ASHelper method isJaxwsService.

public static boolean isJaxwsService(final ClassInfo current, final Index index) {
    ClassInfo tmp = current;
    while (tmp != null) {
        final DotName superName = tmp.superName();
        if (JAXWS_SERVICE_CLASS.equals(superName)) {
            return true;
        }
        tmp = index.getClassByName(superName);
    }
    return false;
}
Also used : DotName(org.jboss.jandex.DotName) ClassInfo(org.jboss.jandex.ClassInfo)

Example 40 with ClassInfo

use of org.jboss.jandex.ClassInfo in project wildfly by wildfly.

the class AroundInvokeAnnotationParsingProcessor method processAroundInvoke.

private void processAroundInvoke(final EEModuleDescription eeModuleDescription, final AnnotationTarget target) throws DeploymentUnitProcessingException {
    if (!(target instanceof MethodInfo)) {
        throw EeLogger.ROOT_LOGGER.methodOnlyAnnotation(AROUND_INVOKE_ANNOTATION_NAME);
    }
    final MethodInfo methodInfo = MethodInfo.class.cast(target);
    final ClassInfo classInfo = methodInfo.declaringClass();
    final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
    final List<AnnotationInstance> classAroundInvokes = classInfo.annotations().get(AROUND_INVOKE_ANNOTATION_NAME);
    if (classAroundInvokes.size() > 1) {
        throw EeLogger.ROOT_LOGGER.aroundInvokeAnnotationUsedTooManyTimes(classInfo.name(), classAroundInvokes.size());
    }
    validateArgumentType(classInfo, methodInfo);
    InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription());
    builder.setAroundInvoke(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) AnnotationInstance(org.jboss.jandex.AnnotationInstance) ClassInfo(org.jboss.jandex.ClassInfo)

Aggregations

ClassInfo (org.jboss.jandex.ClassInfo)43 AnnotationInstance (org.jboss.jandex.AnnotationInstance)26 AnnotationTarget (org.jboss.jandex.AnnotationTarget)18 MethodInfo (org.jboss.jandex.MethodInfo)14 HashSet (java.util.HashSet)12 CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)12 DotName (org.jboss.jandex.DotName)10 EEModuleClassDescription (org.jboss.as.ee.component.EEModuleClassDescription)9 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)9 AnnotationValue (org.jboss.jandex.AnnotationValue)9 HashMap (java.util.HashMap)7 FieldInfo (org.jboss.jandex.FieldInfo)7 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)6 WebService (javax.jws.WebService)5 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)5 ArrayList (java.util.ArrayList)4 WebServiceProvider (javax.xml.ws.WebServiceProvider)4 InterceptorClassDescription (org.jboss.as.ee.component.interceptors.InterceptorClassDescription)4 PropertyReplacer (org.jboss.metadata.property.PropertyReplacer)4 Module (org.jboss.modules.Module)4