Java Code Examples for javax.enterprise.inject.spi.AnnotatedMember#getAnnotation()
The following examples show how to use
javax.enterprise.inject.spi.AnnotatedMember#getAnnotation() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SeMetricName.java From smallrye-metrics with Apache License 2.0 | 5 votes |
@Override public String of(AnnotatedMember<?> member) { if (member.isAnnotationPresent(Metric.class)) { Metric metric = member.getAnnotation(Metric.class); String name = (metric.name().isEmpty()) ? member.getJavaMember().getName() : of(metric.name()); return metric.absolute() | parameters.contains(MetricsParameter.useAbsoluteName) ? name : MetricRegistry.name(member.getJavaMember().getDeclaringClass(), name); } else { return parameters.contains(MetricsParameter.useAbsoluteName) ? member.getJavaMember().getName() : MetricRegistry.name(member.getJavaMember().getDeclaringClass(), member.getJavaMember().getName()); } }
Example 2
Source File: AxonCdiExtension.java From cdi with Apache License 2.0 | 5 votes |
/** * Scans for a serializer producer. * * @param processProducer process producer event. */ <T> void processSerializerProducer( @Observes final ProcessProducer<T, Serializer> processProducer) { // TODO Handle multiple serializer definitions of the same type. AnnotatedMember<T> annotatedMember = processProducer.getAnnotatedMember(); Named named = annotatedMember.getAnnotation(Named.class); if (named != null) { String namedValue = named.value(); String serializerName = "".equals(namedValue) ? annotatedMember.getJavaMember().getName() : namedValue; switch (serializerName) { case "eventSerializer": logger.debug("Producer for event serializer found: {}.", processProducer.getProducer()); eventSerializerProducer = processProducer.getProducer(); break; case "messageSerializer": logger.debug("Producer for message serializer found: {}.", processProducer.getProducer()); messageSerializerProducer = processProducer.getProducer(); break; case "serializer": logger.debug("Producer for serializer found: {}.", processProducer.getProducer()); this.serializerProducer = processProducer.getProducer(); break; default: logger.warn("Unknown named serializer configured: " + serializerName); } } else { logger.debug("Producer for serializer found: {}.", processProducer.getProducer()); this.serializerProducer = processProducer.getProducer(); } }
Example 3
Source File: CdiUtilities.java From cdi with Apache License 2.0 | 5 votes |
static String extractBeanName(AnnotatedMember<?> annotatedMember) { Named named = annotatedMember.getAnnotation(Named.class); if (named != null && !"".equals(named.value())) { return named.value(); } // TODO: Should not try to derive the name of a member that does not // have the @Named annotation on it. return annotatedMember.getJavaMember().getName(); }
Example 4
Source File: SeMetricName.java From metrics-cdi with Apache License 2.0 | 5 votes |
@Override public String of(AnnotatedMember<?> member) { if (member.isAnnotationPresent(Metric.class)) { Metric metric = member.getAnnotation(Metric.class); String name = metric.name().isEmpty() ? member.getJavaMember().getName() : of(metric.name()); return metric.absolute() | extension.<Boolean>getParameter(UseAbsoluteName).orElse(false) ? name : MetricRegistry.name(member.getJavaMember().getDeclaringClass(), name); } else { return extension.<Boolean>getParameter(UseAbsoluteName).orElse(false) ? member.getJavaMember().getName() : MetricRegistry.name(member.getJavaMember().getDeclaringClass(), member.getJavaMember().getName()); } }
Example 5
Source File: MockExtension.java From deltaspike with Apache License 2.0 | 4 votes |
public <X, T> void onProcessProducer(@Observes ProcessProducer<X, T> processProducer, BeanManager beanManager) { if (!isActivated) { return; } for (MockFilter mockFilter : mockFilters) { if (!mockFilter.isMockedImplementationSupported(beanManager, processProducer.getAnnotatedMember())) { return; } } final Producer<T> originalProducer = processProducer.getProducer(); AnnotatedMember<X> annotatedMember = processProducer.getAnnotatedMember(); List<Annotation> qualifiers = new ArrayList<Annotation>(); for (Annotation annotation : annotatedMember.getAnnotations()) { if (beanManager.isQualifier(annotation.annotationType())) { qualifiers.add(annotation); } } Typed typed = annotatedMember.getAnnotation(Typed.class); List<Type> foundTypes = new ArrayList<Type>(); if (typed != null) { Collections.addAll(foundTypes, typed.value()); } else if (annotatedMember.getBaseType() instanceof Class) { foundTypes.addAll(extractTypes((Class)annotatedMember.getBaseType())); } if (foundTypes.isEmpty()) { return; } processProducer.setProducer(new MockAwareProducerWrapper<T>( beanManager, originalProducer, foundTypes, qualifiers)); }