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

Martin Kouba mkouba at redhat.com
Mon Aug 10 02:51:51 EDT 2015


Dne 7.8.2015 v 10:29 Emily Jiang napsal(a):
> Thanks Martin for your reply! Your reply confirmed my understanding of
> @Vetoed.
>
> What is the expected behaviour if I exclude my JavaEE component class in
> the filter under beans.xml? Will this cause the JavaEE component class
> being ignored by CDI or this should have the same effect as being
> annotated as @Vetoed?

This should have the same effect as @Vetoed.

>
> "In the 12.4.2, it states: If the filter is active, and: .... then we
> say that the type is excluded from discovery."
>
> Does the above discovery mean both type and bean discovery or just bean
> discovery? If it means both type and bean discovery, the classes should
> be ignored by CDI. Please confirm.

@Veto, ProcessAnnotatedType.veto() and exclude filters are tied to Type 
discovery. Moreover, the Java EE components (like servlets) are not CDI 
beans and may not be vetoed at all.

>
> 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
>
>
>
>
> From: Martin Kouba <mkouba at redhat.com>
> To: Emily Jiang/UK/IBM at IBMGB, cdi-dev at lists.jboss.org,
> Date: 07/08/2015 03:40
> Subject: Re: [cdi-dev] Clarification on the difference on Vetoed and
> exclude filters regarding Java EE component classes
> Sent by: cdi-dev-bounces at lists.jboss.org
> ------------------------------------------------------------------------
>
>
>
> 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
> _______________________________________________
> 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.
>
>
>
> 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

-- 
Martin Kouba
Software Engineer
Red Hat, Czech Republic


More information about the cdi-dev mailing list