[weld-dev] Two interceptor bindings considered the same when the only annotation member is nonbinding?

Pete Muir pmuir at redhat.com
Tue Mar 6 11:47:30 EST 2012


On 5 Mar 2012, at 16:15, Marko Lukša wrote:

> As Jozef pointed out, this has been clarified in 1.1. So what should I do in 1.0, since in 1.0 there is nothing that says that interceptor bindings on methods override the bindings of the class.
> 
> As I wrote below, it is probably perfectly legal to have the same binding on both the class and the method. But since BeanManager.resolveInterceptors is supposed to throw an exception if you pass two instances of the same binding, weld should make sure it calls resolveInterceptors with only one instance (the method's as in 1.1). 
> 
> -Marko
> 
> On 5.3.2012 17:03, Ales Justin wrote:
>> This looks like a normal use-case to me.
>> 
>> e.g. bean / class has more generic annotation binding,
>> where you are more fine-grained on the actual method.
>> 
>> Hence, imo, it should be supported.
>> 
>> -Ales
>> 
>>> According to the spec, BeanManager.resolveInterceptors() should throw IAE if two instances of the same interceptor binding type are given.
>>> 
>>> o.j.weld.tests.interceptors.tb.GenericDAO is annotated @Tx(0) and its method find() is annotated @Tx(1). The annotation's only member is Nonbinding.
>>> 
>>> - So @Tx(0) and @Tx(1) are considered to be the _same_ binding? 

Yes.

>>> - The spec allows (doesn't disallow) methods to be annotated with the same binding type as the class, right?

Correct.

>>> - However, calling resolveInterceptors with these two should throw IAE? Currently it does not. 

Correct.

>>> 
>>> I've made fixes for WELD-999 and now resolveInterceptors does in fact throw IAE in this case. But I guess I now have to remove duplicate bindings before calling resolveInterceptors in cases where the method of a bean is annotated with the same binding type as the bean itself.

This sounds like the best option.

>>> 
>>> Am I wrong in assuming that @Tx(0) and @Tx(1) are the same binding?
>>> 
>>> Regards
>>> Marko
>>> 
>>> 
>>> _______________________________________________
>>> weld-dev mailing list
>>> weld-dev at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/weld-dev
>> 
>> 
>> 
>> _______________________________________________
>> weld-dev mailing list
>> 
>> weld-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/weld-dev
> 
> _______________________________________________
> weld-dev mailing list
> weld-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/weld-dev




More information about the weld-dev mailing list