As Joe said that this is not so explicit in specification. There were some discussions on using generic decorators on mailing list but I did not find it.
Could you ensure that your example works in Weld (Reference implementation)? Thanks Gurkan 2011/4/20 Arne Limburg <[email protected]> > Hi Joe, > > > > you are right, but I think the spec is clear enough here. The delegate has > to have the same type parameters as the decorator and the decorated bean has > to match the delegate in clearly specified way. > > So the following all should work: > > @Decorator > > public class TestDecorator implements GenericInterface { > > @Inject @Any @Delegate > > private GenericInterface delegate; > > } > > > > @Decorator > > public class TestDecorator implements GenericInterface<?> { > > @Inject @Any @Delegate > > private GenericInterface<?> delegate; > > } > > > > @Decorator > > public class TestDecorator<T> implements GenericInterface<T> { > > @Inject @Any @Delegate > > private GenericInterface<T> delegate; > > } > > > > @Decorator > > public class TestDecorator implements GenericInterface<ConcreteClass> { > > @Inject @Any @Delegate > > private GenericInterface<ConcreteClass> delegate; > > } > > > > I am afraid, that all does not work with OWB. I have tracked it down to the > ClassUtil.setInterfaceTypeHierarchy. It does not respect actual > type-arguments. > > I create a Jira-Issue and try to provide a fix for this. > > > > Regards, > > Arne > > > > *Von:* Joseph Bergmark [mailto:[email protected]] > *Gesendet:* Mittwoch, 20. April 2011 17:10 > *An:* [email protected] > *Betreff:* Re: Decorators with generic type-arguments > > > > I took a quick look at the spec, I didn't find much at all about Decorators > with generic types. The only snippet I found was in 8.1.3, where it > basically says that if the Decorated type is a parameterized type, then the > delegate type has to have the same type parameters as the decorated type, > otherwise it is a definition error. > > > > It seems to me there is probably an OWB bug here, but the spec doesn't > provide a lot of guidance beyond the single definition error. > > > > Sincerely, > > > Joe > > > > On Wed, Apr 20, 2011 at 9:40 AM, Arne Limburg < > [email protected]> wrote: > > Hi, > > > > Currently I try to get a Decorator working, that decorates an interface > with a generic type argument. Although the Spec is quite clear about how to > handle this (in 8.3.1) I am afraid, OpenWebBeans cannot handle it: > > > > This is the scenario > > > > @Decorator > > public class TestDecorator<A extends Annotation> implements > GenericInterface<A> { > > @Inject @Any @Delegate > > private GenericInterface<A> delegate; > > } > > > > public class TestBean implements GenericInterface<Scope> { > > … > > } > > > > I have tried various combinations of actual type arguments in the Decorator > (like Wildcard, raw type, …). The above leads to a definition error. Some > other combinations lead to a behavior where the Decorator is not applied. > Even declaring the Decorator with the same actual type variable (Scope in > the example) does not work? > > Would you consider this a bug or do I read the spec wrong and this is not > supported. > > > > Shall I fill a Jira Issue? > > > > Regards, > > Arne > > > > -- > > > > Arne Limburg - Enterprise Architect > > open knowledge GmbH, Oldenburg > > Bismarckstraße 13, 26122 Oldenburg > > Mobil: +49 (0) 151 108 22 942 > > Tel: +49 (0) 441 - 4082-0 > > Fax: +49 (0) 441 - 4082-111 > > [email protected] > > http://www.openknowledge.de > > > > Registergericht: Amtsgericht Oldenburg, HRB 4670 > > Geschäftsführer: Lars Röwekamp, Jens Schumann > > > > > -- Gurkan Erdogdu http://gurkanerdogdu.blogspot.com
