-
Feature Request
-
Resolution: Obsolete
-
Major
-
None
-
None
-
None
-
None
As Java 8 introduces type annotations, generalizing the benefit of @WithAnnotations by using it as type annotation could improve a lot of recurring patterns that are usually implemented as a combination of ProcessAnnotatedType and other lifecycle events.
For example, instead of having to write that in a CDI extension:
Set<AnnotatedType<?>> camelBeans = new HashMap<>(); void camelAnnotations(@Observes @WithAnnotations({BeanInject.class, Consume.class, EndpointInject.class, Produce.class, PropertyInject.class}) ProcessAnnotatedType<?> pat) { camelBeans.add(pat.getAnnotatedType()); } <T> void camelBeansPostProcessor(@Observes ProcessInjectionTarget<T> pit, BeanManager manager) { if (camelBeans.contains(pit.getAnnotatedType())) pit.setInjectionTarget(new CdiCamelInjectionTarget<>(pit.getInjectionTarget(), manager)); }
One could write directly:
<@WithAnnotations({BeanInject.class, Consume.class, EndpointInject.class, Produce.class, PropertyInject.class}) T> void camelBeansPostProcessor(@Observes ProcessInjectionTarget<T> pit, BeanManager manager) {
pit.setInjectionTarget(new CdiCamelInjectionTarget<>(pit.getInjectionTarget(), manager));
}
- is related to
-
CDI-270 Allow @WithAnnotations to be applied to other events
- Closed