Search in sources :

Example 11 with ClassInfo

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

the class ASHelper method isJaxwsEndpoint.

public static boolean isJaxwsEndpoint(final EEModuleClassDescription classDescription, final CompositeIndex index) {
    ClassInfo classInfo = null;
    WebServiceAnnotationInfo webserviceAnnoationInfo = null;
    final ClassAnnotationInformation<WebService, WebServiceAnnotationInfo> classAnnotationInfo = classDescription.getAnnotationInformation(WebService.class);
    if (classAnnotationInfo != null && !classAnnotationInfo.getClassLevelAnnotations().isEmpty()) {
        webserviceAnnoationInfo = classAnnotationInfo.getClassLevelAnnotations().get(0);
        classInfo = (ClassInfo) webserviceAnnoationInfo.getTarget();
    }
    WebServiceProviderAnnotationInfo webserviceProviderAnnoationInfo = null;
    final ClassAnnotationInformation<WebServiceProvider, WebServiceProviderAnnotationInfo> providerAnnotationInfo = classDescription.getAnnotationInformation(WebServiceProvider.class);
    if (providerAnnotationInfo != null && !providerAnnotationInfo.getClassLevelAnnotations().isEmpty()) {
        webserviceProviderAnnoationInfo = providerAnnotationInfo.getClassLevelAnnotations().get(0);
        classInfo = (ClassInfo) webserviceProviderAnnoationInfo.getTarget();
    }
    if (classInfo == null) {
        return false;
    }
    // assert JAXWS endpoint class flags
    final short flags = classInfo.flags();
    if (Modifier.isInterface(flags))
        return false;
    if (Modifier.isAbstract(flags))
        return false;
    if (!Modifier.isPublic(flags))
        return false;
    if (isJaxwsService(classInfo, index))
        return false;
    if (webserviceAnnoationInfo != null && webserviceProviderAnnoationInfo != null) {
        WSLogger.ROOT_LOGGER.mutuallyExclusiveAnnotations(classInfo.name().toString());
        return false;
    }
    if (Modifier.isFinal(flags)) {
        WSLogger.ROOT_LOGGER.finalEndpointClassDetected(classInfo.name().toString());
        return false;
    }
    return true;
}
Also used : WebServiceProvider(javax.xml.ws.WebServiceProvider) WebService(javax.jws.WebService) WebServiceProviderAnnotationInfo(org.jboss.as.webservices.deployers.WebServiceProviderAnnotationInfo) ClassInfo(org.jboss.jandex.ClassInfo) WebServiceAnnotationInfo(org.jboss.as.webservices.deployers.WebServiceAnnotationInfo)

Example 12 with ClassInfo

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

the class WeldClassFileInfo method isAssignableTo.

/**
     * @param to
     * @param name
     * @return <code>true</code> if the name is equal to the fromName, or if the name represents a superclass or superinterface of the fromName,
     *         <code>false</code> otherwise
     */
private boolean isAssignableTo(DotName name, Class<?> to) {
    if (to.getName().equals(name.toString())) {
        return true;
    }
    if (OBJECT_NAME.equals(name)) {
        // there's nothing assignable from Object.class except for Object.class
        return false;
    }
    ClassInfo fromClassInfo = index.getClassByName(name);
    if (fromClassInfo == null) {
        // We reached a class that is not in the index. Let's use reflection.
        final Class<?> clazz = loadClass(name.toString());
        return to.isAssignableFrom(clazz);
    }
    DotName superName = fromClassInfo.superName();
    if (superName != null && isAssignableTo(superName, to)) {
        return true;
    }
    if (fromClassInfo.interfaces() != null) {
        for (DotName interfaceName : fromClassInfo.interfaces()) {
            if (isAssignableTo(interfaceName, to)) {
                return true;
            }
        }
    }
    return false;
}
Also used : DotName(org.jboss.jandex.DotName) ClassInfo(org.jboss.jandex.ClassInfo)

Example 13 with ClassInfo

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

the class WeldClassFileInfo method isVetoedTypeOrPackage.

private boolean isVetoedTypeOrPackage() {
    if (isAnnotationDeclared(classInfo, DOT_NAME_VETOED)) {
        return true;
    }
    final DotName packageInfoName = DotName.createComponentized(getPackageName(classInfo.name()), PACKAGE_INFO_NAME);
    ClassInfo packageInfo = index.getClassByName(packageInfoName);
    if (packageInfo != null && isAnnotationDeclared(packageInfo, DOT_NAME_VETOED)) {
        return true;
    }
    return false;
}
Also used : DotName(org.jboss.jandex.DotName) ClassInfo(org.jboss.jandex.ClassInfo)

Example 14 with ClassInfo

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

Example 15 with ClassInfo

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

the class XTSDependenciesDeploymentProcessor method isTransactionalEndpointPresent.

private boolean isTransactionalEndpointPresent(final CompositeIndex compositeIndex) {
    final List<AnnotationInstance> annotations = new ArrayList<>();
    annotations.addAll(compositeIndex.getAnnotations(DotName.createSimple(Transactional.class.getName())));
    annotations.addAll(compositeIndex.getAnnotations(DotName.createSimple(TransactionAttribute.class.getName())));
    for (final AnnotationInstance annotation : annotations) {
        final Object target = annotation.target();
        if (target instanceof ClassInfo) {
            final ClassInfo classInfo = (ClassInfo) target;
            if (classInfo.annotations().get(DotName.createSimple(WebService.class.getName())) != null) {
                return true;
            }
        }
    }
    return false;
}
Also used : TransactionAttribute(javax.ejb.TransactionAttribute) WebService(javax.jws.WebService) ArrayList(java.util.ArrayList) AnnotationInstance(org.jboss.jandex.AnnotationInstance) Transactional(javax.transaction.Transactional) 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