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);
}
}
}
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;
}
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);
}
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);
}
}
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);
}
}
}
Aggregations