openwebbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: CDI spec question on interceptors, alternatives and priority
Date Wed, 15 Jun 2016 13:03:42 GMT
Hi

got the same when working on TCK, some spec redefine priorities in their
own "constant class" like JAX-RS. As a dev I also did it quite a few with
my own ordering (using interceptor as reference but using my own semantic).
This is still an option for you.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-06-15 15:00 GMT+02:00 Lars-Fredrik Smedberg <itsmeden@gmail.com>:

> Hi!
>
> Was not sure what mailing list to send this to but I guess some of you
> could help me out.
>
> We are moving to JEE 7 and we are annotating our interceptors with
> @Priority(...) to not have to include them in all beans.xml in all archives
> where they should be used.
> The value for the @Priority annotation are based upon the constants
> defined in Interceptor.Priority... which JavaDoc says "Interceptors with
> smaller priority values are called first."... so far so good...
>
> Then I also want to be able to place alternatives in separate modules/jars
> that we will use in some test environments. This also works good using
> @Alternative and @Priority... I understand
> that the alternative is activated by using the @Priority annotation. In
> section 5.2.2 of the CDI 1.2 spec (e.g.
> http://docs.jboss.org/cdi/spec/1.2/cdi-spec-1.2.pdf) I read the following:
>
> "...all the beans left are alternatives with a priority, or producer
> methods or fields of beans that
> are alternatives with a priority, then the container will determine the
> highest priority value, and
> eliminate all beans, except for alternatives with the highest priority..."
>
> I have tested this and I'm fine with that the higher priority alternative
> is choosen. However in same spec in section 4.3 they have the following
> example:
>
> "@Alternative @Priority(APPLICATION+100)
> public class MockAsynchronousService extends AsynchronousService {"
>
> Similar example can be found at e.g.:
> https://docs.oracle.com/javaee/7/tutorial/cdi-adv002.htm
>
> To me its confusing to use a priority value based on Interceptors.Priority
> since the semantics of the Priority value is the opposite for interceptors
> and alternatives?
>
> Does the examples for alternatives only confuse me or did I miss someting?
>
> Best regards
> Lars-Fredrik Smedberg
>
> --
> Med vänlig hälsning / Best regards
>
> Lars-Fredrik Smedberg
>
> STATEMENT OF CONFIDENTIALITY:
> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of the
> address(es) and may contain confidential or privileged information. If
> you are not the intended recipient, please notify Lars-Fredrik Smedberg
> immediately at itsmeden@gmail.com, and destroy all copies of this
> message and any attachments.
>

Mime
View raw message