Search in sources :

Example 11 with AnnotationInstance

use of org.jboss.jandex.AnnotationInstance 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 12 with AnnotationInstance

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

Example 13 with AnnotationInstance

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

the class WebServiceAnnotation method build.

public static WebServiceAnnotation build(DeploymentUnit unit, String endpoint) throws XTSException {
    AnnotationInstance annotationInstance = JandexHelper.getAnnotation(unit, endpoint, WEBSERVICE_ANNOTATION);
    if (annotationInstance == null) {
        return null;
    }
    final String portName = getStringValue(annotationInstance, "portName");
    final String serviceName = getStringValue(annotationInstance, "serviceName");
    final String name = getStringValue(annotationInstance, "name");
    final String targetNamespace = getStringValue(annotationInstance, "targetNamespace");
    return new WebServiceAnnotation(portName, serviceName, name, targetNamespace);
}
Also used : AnnotationInstance(org.jboss.jandex.AnnotationInstance)

Example 14 with AnnotationInstance

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

the class JandexAnnotationRepositoryImpl method getAnnotation.

@Override
public Collection<Annotation> getAnnotation(Class<?> annotationClass) {
    List<AnnotationInstance> instances = backingRepository.getAnnotations(DotName.createSimple(annotationClass.getName()));
    ArrayList<Annotation> annotations = new ArrayList<Annotation>(instances.size());
    for (AnnotationInstance instance : instances) {
        AnnotationTarget target = instance.target();
        Annotation annotation = null;
        if (target instanceof MethodInfo) {
            MethodInfo m = (MethodInfo) target;
            List<String> parameterTypes = new ArrayList<String>(m.args().length);
            for (Type type : m.args()) {
                parameterTypes.add(type.toString());
            }
            String declaringClass = m.declaringClass().name().toString();
            annotation = new AnnotationImpl(declaringClass, cl, parameterTypes, m.name(), true, false, annotationClass);
        }
        if (target instanceof FieldInfo) {
            FieldInfo f = (FieldInfo) target;
            String declaringClass = f.declaringClass().name().toString();
            annotation = new AnnotationImpl(declaringClass, cl, null, f.name(), false, true, annotationClass);
        }
        if (target instanceof ClassInfo) {
            ClassInfo c = (ClassInfo) target;
            annotation = new AnnotationImpl(c.name().toString(), cl, null, null, false, false, annotationClass);
        }
        if (annotation != null) {
            annotations.add(annotation);
        }
    }
    annotations.trimToSize();
    if (annotations.size() == 0) {
        return null;
    } else {
        return Collections.unmodifiableList(annotations);
    }
}
Also used : AnnotationTarget(org.jboss.jandex.AnnotationTarget) ArrayList(java.util.ArrayList) Annotation(org.jboss.jca.common.spi.annotations.repository.Annotation) Type(org.jboss.jandex.Type) MethodInfo(org.jboss.jandex.MethodInfo) AnnotationInstance(org.jboss.jandex.AnnotationInstance) FieldInfo(org.jboss.jandex.FieldInfo) ClassInfo(org.jboss.jandex.ClassInfo)

Example 15 with AnnotationInstance

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

the class LifecycleAnnotationParsingProcessor method deploy.

public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
    for (DotName annotationName : LIFE_CYCLE_ANNOTATIONS) {
        final List<AnnotationInstance> lifecycles = index.getAnnotations(annotationName);
        for (AnnotationInstance annotation : lifecycles) {
            processLifeCycle(eeModuleDescription, annotation.target(), annotationName, applicationClasses);
        }
    }
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DotName(org.jboss.jandex.DotName) AnnotationInstance(org.jboss.jandex.AnnotationInstance)

Aggregations

AnnotationInstance (org.jboss.jandex.AnnotationInstance)40 ClassInfo (org.jboss.jandex.ClassInfo)26 CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)17 AnnotationTarget (org.jboss.jandex.AnnotationTarget)16 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)15 AnnotationValue (org.jboss.jandex.AnnotationValue)11 MethodInfo (org.jboss.jandex.MethodInfo)11 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)9 HashSet (java.util.HashSet)8 DotName (org.jboss.jandex.DotName)7 FieldInfo (org.jboss.jandex.FieldInfo)7 ArrayList (java.util.ArrayList)5 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)5 PropertyReplacer (org.jboss.metadata.property.PropertyReplacer)5 HashMap (java.util.HashMap)4 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)4 EEModuleClassDescription (org.jboss.as.ee.component.EEModuleClassDescription)3 Module (org.jboss.modules.Module)3 PersistenceUnitMetadata (org.jipijapa.plugin.spi.PersistenceUnitMetadata)3 URL (java.net.URL)2