[cdi-dev] [JBoss JIRA] (CDI-472) Support @WithAnnotations as type annotation of lifecycle events
Antonin Stefanutti (JIRA)
issues at jboss.org
Mon Sep 15 05:37:02 EDT 2014
[ https://issues.jboss.org/browse/CDI-472?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Antonin Stefanutti updated CDI-472:
-----------------------------------
Description:
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:
{code}
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));
}
{code}
One could write directly:
{code}
<@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));
}
{code}
was:
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:
{code}
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));
}
{code}
One could write directly:
{code}
<@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));
}
{code}
> Support @WithAnnotations as type annotation of lifecycle events
> ---------------------------------------------------------------
>
> Key: CDI-472
> URL: https://issues.jboss.org/browse/CDI-472
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Reporter: Antonin Stefanutti
>
> 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:
> {code}
> 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));
> }
> {code}
> One could write directly:
> {code}
> <@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));
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)
More information about the cdi-dev
mailing list