javax.enterprise.inject.spi.WithAnnotations Java Examples
The following examples show how to use
javax.enterprise.inject.spi.WithAnnotations.
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: AxonCdiExtension.java From cdi with Apache License 2.0 | 6 votes |
/** * Scans all annotated types with the {@link Aggregate} annotation and * collects them for registration. * * @param processAnnotatedType annotated type processing event. */ // Mark: All I need to do here is look up what the aggregate classes are // and what the value of the @Aggregate annotation is. This feels a little // overkill. That said, currently I do need these values in afterBeanDiscovery // and this might be the most efficient way of collecting these anyway. // Other than being a bit ugly, this is not anything that is causing any // functional issues. <T> void processAggregate(@Observes @WithAnnotations({Aggregate.class}) final ProcessAnnotatedType<T> processAnnotatedType) { // TODO Aggregate classes may need to be vetoed so that CDI does not // actually try to manage them. final Class<?> clazz = processAnnotatedType.getAnnotatedType().getJavaClass(); logger.debug("Found aggregate: {}.", clazz); aggregates.add(new AggregateDefinition(clazz)); }
Example #2
Source File: MetricCdiInjectionExtension.java From smallrye-metrics with Apache License 2.0 | 5 votes |
private <X> void findAnnotatedInterfaces(@Observes @WithAnnotations({ Counted.class, Gauge.class, Metered.class, SimplyTimed.class, Timed.class, ConcurrentGauge.class }) ProcessAnnotatedType<X> pat) { Class<X> clazz = pat.getAnnotatedType().getJavaClass(); Package pack = clazz.getPackage(); if (pack != null && pack.getName().equals(GaugeRegistrationInterceptor.class.getPackage().getName())) { return; } if (clazz.isInterface()) { // All declared metrics of an annotated interface are registered during AfterDeploymentValidation metricsInterfaces.add(clazz); } }
Example #3
Source File: JerseyCdiExtension.java From hammock with Apache License 2.0 | 5 votes |
public <T> void observeProviders(@WithAnnotations({ Provider.class }) @Observes ProcessAnnotatedType<T> event) { AnnotatedType<T> annotatedType = event.getAnnotatedType(); if (!annotatedType.getJavaClass().isInterface()) { this.providers.add(annotatedType.getJavaClass()); } }
Example #4
Source File: JerseyCdiExtension.java From hammock with Apache License 2.0 | 5 votes |
public <T> void observeResources(@WithAnnotations({ Path.class }) @Observes ProcessAnnotatedType<T> event) { AnnotatedType<T> annotatedType = event.getAnnotatedType(); if (!annotatedType.getJavaClass().isInterface()) { this.resources.add(annotatedType.getJavaClass()); } }
Example #5
Source File: RestClientExtension.java From cxf with Apache License 2.0 | 5 votes |
public void findClients(@Observes @WithAnnotations({RegisterRestClient.class}) ProcessAnnotatedType<?> pat) { Class<?> restClient = pat.getAnnotatedType().getJavaClass(); if (restClient.isInterface()) { restClientClasses.add(restClient); pat.veto(); } else { errors.add(new IllegalArgumentException("The class " + restClient + " is not an interface")); } }
Example #6
Source File: SnoopEurekaScannerExtension.java From snoop with MIT License | 5 votes |
<T> void processAnnotatedType(@Observes @WithAnnotations({EnableEurekaClient.class}) ProcessAnnotatedType<T> pat) { LOGGER.config(() -> "Found @EnableEurekaClient annotated class: " + pat.getAnnotatedType().getJavaClass().getName()); eurekaEnabled = true; applicationName = pat.getAnnotatedType().getAnnotation(EnableEurekaClient.class).name(); LOGGER.config(() -> "Eureka application name is: " + applicationName); }
Example #7
Source File: SnoopScannerExtension.java From snoop with MIT License | 5 votes |
<T> void processAnnotatedType(@Observes @WithAnnotations(EnableSnoopClient.class) ProcessAnnotatedType<T> pat) { // workaround for WELD bug revealed by JDK8u60 final ProcessAnnotatedType<T> snoopAnnotated = pat; LOGGER.config(() -> "Found @EnableSnoopClient annotated class: " + snoopAnnotated.getAnnotatedType().getJavaClass().getName()); snoopEnabled = true; serviceName = snoopAnnotated.getAnnotatedType().getAnnotation(EnableSnoopClient.class).serviceName(); LOGGER.config(() -> "Snoop Service name is: " + serviceName); }
Example #8
Source File: TomEESecurityExtension.java From tomee with Apache License 2.0 | 5 votes |
void processAuthenticationMechanismDefinitions(@Observes @WithAnnotations({ BasicAuthenticationMechanismDefinition.class, FormAuthenticationMechanismDefinition.class }) final ProcessAnnotatedType<?> processAnnotatedType) { final AnnotatedType<?> annotatedType = processAnnotatedType.getAnnotatedType(); if (annotatedType.isAnnotationPresent(BasicAuthenticationMechanismDefinition.class)) { basicAuthentication.add(annotatedType); } if (annotatedType.isAnnotationPresent(FormAuthenticationMechanismDefinition.class)) { formAuthentication.add(annotatedType); } }
Example #9
Source File: GraphQlClientExtension.java From smallrye-graphql with Apache License 2.0 | 5 votes |
public void registerGraphQlClientApis(@Observes @WithAnnotations(GraphQlClientApi.class) ProcessAnnotatedType<?> type) { Class<?> javaClass = type.getAnnotatedType().getJavaClass(); if (javaClass.isInterface()) { log.info("register {}", javaClass.getName()); apis.add(javaClass); } else { log.error("failed to register", new IllegalArgumentException( "a GraphQlClientApi must be an interface: " + javaClass.getName())); } }
Example #10
Source File: ServiceProxyExtension.java From weld-vertx with Apache License 2.0 | 5 votes |
void findServiceInterfaces(@Observes @WithAnnotations(ProxyGen.class) ProcessAnnotatedType<?> event, BeanManager beanManager) { AnnotatedType<?> annotatedType = event.getAnnotatedType(); if (annotatedType.isAnnotationPresent(ProxyGen.class) && annotatedType.getJavaClass().isInterface()) { LOGGER.debug("Service interface {0} discovered", annotatedType.getJavaClass()); serviceInterfaces.add(annotatedType.getJavaClass()); } }
Example #11
Source File: ExcludedBeansExtension.java From weld-junit with Apache License 2.0 | 5 votes |
<T> void excludeBeans(@Observes @WithAnnotations({Scope.class, NormalScope.class}) ProcessAnnotatedType<T> pat) { if (excludedBeanClasses.contains(pat.getAnnotatedType().getJavaClass())) { pat.veto(); return; } Set<Type> typeClosure = pat.getAnnotatedType().getTypeClosure(); for (Type excludedBeanType : excludedBeanTypes) { if (typeClosure.contains(excludedBeanType)) { pat.veto(); return; } } }
Example #12
Source File: AxonCdiExtension.java From cdi with Apache License 2.0 | 5 votes |
<T> void processSaga(@Observes @WithAnnotations({Saga.class}) final ProcessAnnotatedType<T> processAnnotatedType) { // TODO Saga classes may need to be vetoed so that CDI does not // actually try to manage them. final Class<?> clazz = processAnnotatedType.getAnnotatedType().getJavaClass(); logger.debug("Found saga: {}.", clazz); sagas.add(new SagaDefinition(clazz)); }
Example #13
Source File: MetricCdiInjectionExtension.java From smallrye-metrics with Apache License 2.0 | 5 votes |
private <X> void applyMetricsBinding(@Observes @WithAnnotations({ Gauge.class }) ProcessAnnotatedType<X> pat) { Class<X> clazz = pat.getAnnotatedType().getJavaClass(); Package pack = clazz.getPackage(); if (pack == null || !pack.getName().equals(GaugeRegistrationInterceptor.class.getPackage().getName())) { if (!clazz.isInterface()) { AnnotatedTypeDecorator newPAT = new AnnotatedTypeDecorator<>(pat.getAnnotatedType(), METRICS_BINDING); pat.setAnnotatedType(newPAT); } } }
Example #14
Source File: UndertowWebSocketExtension.java From hammock with Apache License 2.0 | 4 votes |
public void findWebSocketServers(@Observes @WithAnnotations(ServerEndpoint.class)ProcessAnnotatedType<?> pat) { endpointClasses.add(pat.getAnnotatedType().getJavaClass()); }
Example #15
Source File: WebServerExtension.java From hammock with Apache License 2.0 | 4 votes |
public void findFilters(@Observes @WithAnnotations({WebFilter.class}) ProcessAnnotatedType<? extends Filter> pat) { filters.add(pat.getAnnotatedType().getJavaClass()); }
Example #16
Source File: MetricsExtension.java From metrics-cdi with Apache License 2.0 | 4 votes |
private <X> void metricsAnnotations(@Observes @WithAnnotations({CachedGauge.class, Counted.class, ExceptionMetered.class, Gauge.class, Metered.class, Timed.class}) ProcessAnnotatedType<X> pat) { pat.setAnnotatedType(new AnnotatedTypeDecorator<>(pat.getAnnotatedType(), METRICS_BINDING)); }
Example #17
Source File: WebServerExtension.java From hammock with Apache License 2.0 | 4 votes |
public void findServlets(@Observes @WithAnnotations({WebServlet.class}) ProcessAnnotatedType<? extends HttpServlet> pat) { servlets.add(pat.getAnnotatedType().getJavaClass()); }
Example #18
Source File: WebServerExtension.java From hammock with Apache License 2.0 | 4 votes |
public void findListeners(@Observes @WithAnnotations({WebListener.class}) ProcessAnnotatedType<? extends ServletContextListener> pat) { listeners.add(pat.getAnnotatedType().getJavaClass()); }
Example #19
Source File: JpaExtension.java From openwebbeans-meecrowave with Apache License 2.0 | 4 votes |
void collectEntities(@Observes @WithAnnotations({Entity.class, MappedSuperclass.class, Embeddable.class}) final ProcessAnnotatedType<?> jpa) { jpaClasses.add(jpa.getAnnotatedType().getJavaClass().getName()); }
Example #20
Source File: JpaExtension.java From openwebbeans-meecrowave with Apache License 2.0 | 4 votes |
<T> void addJpaToEmConsumers(@Observes @WithAnnotations(Unit.class) final ProcessAnnotatedType<T> pat) { if (pat.getAnnotatedType().isAnnotationPresent(Jpa.class)) { return; } pat.setAnnotatedType(new AutoJpaAnnotationType<T>(pat.getAnnotatedType())); }
Example #21
Source File: JAXRSCdiResourceExtension.java From cxf with Apache License 2.0 | 3 votes |
/** * For any {@link AnnotatedType} that includes a {@link Context} injection point, this method replaces * the field with the following code: * <pre> * @Inject @ContextResolved T field; * </pre> * For any usage of T that is a valid context object in JAX-RS. * * It also has a side effect of capturing the context object type, in case no * {@link org.apache.cxf.jaxrs.ext.ContextClassProvider} was registered for the type. * * @param processAnnotatedType the annotated type being investigated * @param <X> the generic type of that processAnnotatedType */ public <X> void convertContextsToCdi(@Observes @WithAnnotations({Context.class}) ProcessAnnotatedType<X> processAnnotatedType) { AnnotatedType<X> annotatedType = processAnnotatedType.getAnnotatedType(); DelegateContextAnnotatedType<X> type = new DelegateContextAnnotatedType<>(annotatedType); contextTypes.addAll(type.getContextFieldTypes()); processAnnotatedType.setAnnotatedType(type); }
Example #22
Source File: BeanTestExtension.java From BeanTest with Apache License 2.0 | 3 votes |
/** * Replaces the meta data of the {@link ProcessAnnotatedType}. * * <p> * The ProcessAnnotatedType's meta data will be replaced, if the annotated type has one of the following annotations: * <ul> * <li> {@link Stateless} * <li> {@link MessageDriven} * <li> {@link Interceptor} * <li> {@link Singleton} * </ul> * * @param <X> the type of the ProcessAnnotatedType * @param pat the annotated type representing the class being processed */ public <X> void processInjectionTarget(@Observes @WithAnnotations({Stateless.class, MessageDriven.class, Interceptor.class, Singleton.class}) ProcessAnnotatedType<X> pat) { if (pat.getAnnotatedType().isAnnotationPresent(Stateless.class) || pat.getAnnotatedType().isAnnotationPresent(MessageDriven.class)) { modifiyAnnotatedTypeMetadata(pat); } else if (pat.getAnnotatedType().isAnnotationPresent(Interceptor.class)) { processInterceptorDependencies(pat); } else if(pat.getAnnotatedType().isAnnotationPresent(Singleton.class)) { addApplicationScopedAndTransactionalToSingleton(pat); } }