[cdi-dev] How to specify priority of interceptor registered as custom bean?

Gunnar Morling gunnar at hibernate.org
Wed Jan 15 06:29:04 EST 2014


2014/1/15 Jozef Hartinger <jharting at redhat.com>

>  Yes,
>
> the problem with this is that currently we cannot add a new method to the
> interface - otherwise we break existing implementations of the interface.
> We can either wait for Java 8 or find some other way of specifying the
> priority.
>

One could think about supporting the @Priority annotation on
implementations of j.e.i.s.Interceptor or have a derived interface
PrioritizedInterceptor which adds the new method.

--Gunnar



> Jozef
>
>
> On 01/15/2014 12:17 PM, Gunnar Morling wrote:
>
> Hi Jozef,
>
>  Thanks for the clarification.
>
>  Would it make sense to add Interceptor#getPriority() in a future spec
> revision and handle such a custom interceptor bean as if there was an
> equivalent annotated interceptor type? As it seems its currently not
> possible to achieve the semantics of an annotated interceptor type using a
> portable extension.
>
>  --Gunnar
>
>
>
>
>
>
> 2014/1/15 Jozef Hartinger <jharting at redhat.com>
>
>>  Hi Gunnar,
>>
>> this is not possible. You can only enable the interceptor by adding it to
>> AfterTypeDiscovery#getInterceptors() relatively to other interceptors.
>>
>> Jozef
>>
>>
>> On 01/15/2014 10:56 AM, Gunnar Morling wrote:
>>
>>  Hi,
>>
>>  Using a CDI portable extension, I'm registering a custom bean which
>> represents an interceptor (by implementing the
>> javax.enterprise.inject.spi.Interceptor interface).
>>
>>  My question now is how to specify the priority of that interceptor.
>> Intuitively I had expected a method such as Interceptor#getPriority(), but
>> there isn't such method.
>>
>>  In section 9 the spec says extensions could "override the interceptor
>> order defined by the @Priority annotation" and refers to section 11.5.2
>> which introduces AfterTypeDiscovery#getInterceptors(). So I could use this
>> to add my interceptor, but I don't see how I could specify the priority
>> while doing so.
>>
>>  How can this be achieved?
>>
>>  Many thanks,
>>
>>  --Gunnar
>>
>>
>>
>>  _______________________________________________
>> cdi-dev mailing listcdi-dev at lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/cdi-dev
>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20140115/ae83507c/attachment.html 


More information about the cdi-dev mailing list