[cdi-dev] Clarification on the difference on Vetoed and exclude filters regarding Java EE component classes

Martin Kouba mkouba at redhat.com
Thu Aug 6 10:24:41 EDT 2015


Dne 6.8.2015 v 15:55 Emily Jiang napsal(a):
> In the section 3.6. Java EE components of CDI 1.2 specification, it has
> the following statement:
>
> /It is safe to annotate Java EE components with //@Vetoed //to prevent
> them being considered beans./
>
> According to my understanding, the JavaEE component classes with @Vetoed
> should still support injections and *ProcessInjectionTarget*events
> should still be fired.
>
> In the 12.4.2, it states:
> /If the filter is active, and: .... then we say that the type is
> excluded from discovery./
>
> Does this mean if a JavaEE component class is excluded from the scan in
> the beans.xml, its CDI involvement should be ignored (@Inject would be
> ignored etc)?

I don't think so. I believe the intent of "3.6. Java EE components" is 
to clarify that if a component class (e.g. a servlet class) is also 
recognized as a managed bean [1] there will be two different 
"components" in your applicaion, each managed by a different Java EE 
technology - e.g. a servlet managed by the servlet container and a CDI 
bean with servlet class in its set of bean types.

The servlet has a different lifecycle, it's managed by a servlet 
container and as such must support injection (but cannot be injected, etc.).

This might be confusing and therefore it's a good idea to veto the Java 
EE component classes -> there will be no CDI bean definitions based on 
the component classes.

[1]
http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#what_classes_are_beans


>
> Many thanks,
> Emily
> ===========================
> Emily Jiang
> WebSphere Application Server Liberty Profile development, CDI
> Development Lead
>
> MP 211, DE3A20, Winchester, Hampshire, England, SO21 2JN
> Phone:  +44 (0)1962 816278  Internal: 246278
>
> Email: emijiang at uk.ibm.com
> Lotus Notes: Emily Jiang/UK/IBM at IBMGB
>
> Unless stated otherwise above:
> IBM United Kingdom Limited - Registered in England and Wales with number
> 741598.
> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
>
>
> _______________________________________________
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/cdi-dev
>
> Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.
>

-- 
Martin Kouba
Software Engineer
Red Hat, Czech Republic


More information about the cdi-dev mailing list