Return-Path: X-Original-To: apmail-openwebbeans-user-archive@www.apache.org Delivered-To: apmail-openwebbeans-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4057610A4 for ; Wed, 20 Apr 2011 16:14:33 +0000 (UTC) Received: (qmail 90153 invoked by uid 500); 20 Apr 2011 16:14:33 -0000 Delivered-To: apmail-openwebbeans-user-archive@openwebbeans.apache.org Received: (qmail 90117 invoked by uid 500); 20 Apr 2011 16:14:33 -0000 Mailing-List: contact user-help@openwebbeans.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@openwebbeans.apache.org Delivered-To: mailing list user@openwebbeans.apache.org Received: (qmail 90109 invoked by uid 99); 20 Apr 2011 16:14:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Apr 2011 16:14:33 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [87.128.223.163] (HELO mx01.openknowledge.de) (87.128.223.163) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Apr 2011 16:14:25 +0000 From: Arne Limburg To: "user@openwebbeans.apache.org" Date: Wed, 20 Apr 2011 18:14:31 +0200 Subject: AW: Decorators with generic type-arguments Thread-Topic: Decorators with generic type-arguments Thread-Index: Acv/c+4rUcq5EfdmTHSUfJfTqbHsYwAADXEg Message-ID: References: In-Reply-To: Accept-Language: de-DE, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: de-DE, en-US Content-Type: multipart/alternative; boundary="_000_CFB57C5359CC9D478AE2CAC5FCFB3CCE1037F488BAoldmzexch02op_" MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org --_000_CFB57C5359CC9D478AE2CAC5FCFB3CCE1037F488BAoldmzexch02op_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Gurkan, The spec says "the actual type is assignable to..." and you wrote isAssigna= bleFrom so I think the correct behavior would be to assign the Decorator. A= nyway the code that applies a Decorator to a bean looks very good imho and = I don't think the implementation is wrong here, but the code that checks if= the delegate matches the decorator is not right. The Spec says "A decorator implements one or more bean types and intercepts business meth= od invocations of beans which implement those bean types. These bean types are called decorated types." (8) "The delegate type of a decorator must implement or extend every decorated = type (with exactly the same type parameters)." (8.3.1) I have not tested it with Weld, I'll do that and tell you. But anyway I thi= nk this should be fixed. In my examples every delegate has the same type-parameters as the decorator= , so it should work. I have a fix now for the ClassUtil.setInterfaceTypeHierarchy. I'll provide = it via Jira. Unfortunately now I get another error saying something like my= return type does not match... java.lang.IllegalArgumentException: Given bean type : class org.apache.owb.= TestDecorator is not applicable for the bean instance : Name:null,WebBeans = Type:DECORATOR,API Types:[java.lang.Object,org.apache.owb.TestDecorator,org= .apache.owb.GenericInterface],Qualifiers:[javax.enterprise.inject.Any,javax= .enterprise.inject.Default] at org.apache.webbeans.container.BeanManagerImpl.getReferenc= e(BeanManagerImpl.java:914) at org.apache.webbeans.decorator.WebBeansDecoratorConfig.get= DecoratorStack(WebBeansDecoratorConfig.java:160) at org.apache.webbeans.intercept.InterceptorHandler.invoke(I= nterceptorHandler.java:216) at org.apache.webbeans.intercept.NormalScopedBeanInterceptor= Handler.invoke(NormalScopedBeanInterceptorHandler.java:98) at org.apache.owb.DecoratedBean_$$_javassist_0.isDecoratorCa= lled(DecoratedBean_$$_javassist_0.java) I'll do some further investigation. Regards, Arne Von: Gurkan Erdogdu [mailto:cgurkanerdogdu@gmail.com] Gesendet: Mittwoch, 20. April 2011 17:59 An: user@openwebbeans.apache.org Betreff: Re: Decorators with generic type-arguments In your example, spec says that * the delegate type parameter is a type variable, the bean type paramete= r is an actual type, and the actual type is assignable to the upper bound, if any, of the type variable. Actual Type of Bean Class --> Scope Upper bound of type variable --> Annotation Scope.isAssignableFrom(Annotation) --> False Gurkan 2011/4/20 Arne Limburg > Hi, Currently I try to get a Decorator working, that decorates an interface wit= h a generic type argument. Although the Spec is quite clear about how to ha= ndle this (in 8.3.1) I am afraid, OpenWebBeans cannot handle it: This is the scenario @Decorator public class TestDecorator implements GenericInterfac= e { @Inject @Any @Delegate private GenericInterface delegate; } public class TestBean implements GenericInterface { ... } I have tried various combinations of actual type arguments in the Decorator= (like Wildcard, raw type, ...). The above leads to a definition error. Som= e 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 s= upported. Shall I fill a Jira Issue? Regards, Arne -- Arne Limburg - Enterprise Architect open knowledge GmbH, Oldenburg Bismarckstra=DFe 13, 26122 Oldenburg Mobil: +49 (0) 151 108 22 942 Tel: +49 (0) 441 - 4082-0 Fax: +49 (0) 441 - 4082-111 arne.limburg@openknowledge.de http://www.openknowledge.de Registergericht: Amtsgericht Oldenburg, HRB 4670 Gesch=E4ftsf=FChrer: Lars R=F6wekamp, Jens Schumann -- Gurkan Erdogdu http://gurkanerdogdu.blogspot.com --_000_CFB57C5359CC9D478AE2CAC5FCFB3CCE1037F488BAoldmzexch02op_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

Hi Gurkan,<= o:p>

 

The spec says „the actual = type is assignable to…” and you wrote isAssignableFro= m so I think the correct behavior would be to assign the Decorator. Any= way the code that applies a Decorator to a bean looks very good imho and I = don’t think the implementation is wrong here, but the code that check= s if the delegate matches the decorator is not right.

=

The Spec says

= 220;A decorator implements one or more bean types and intercept= s business method invocations of beans which implement

those bean types. These bean types are called decora= ted types.” (8)

“Th= e delegate type of a decorator must implement or extend every decorated typ= e (with exactly the same type parameters).” (8.3.1)=

I have not tested it with Weld= , I’ll do that and tell you. But anyway I think this should be fixed.=

In my exampl= es every delegate has the same type-parameters as the decorator, so it shou= ld work.

 

I have a f= ix now for the ClassUtil.setInterfaceTypeHierarchy. I’ll provide it v= ia Jira. Unfortunately now I get another error saying something like my ret= urn type does not match…

 

java.lang.IllegalArgumentException: Given bean type : class org= .apache.owb.TestDecorator is not applicable for the bean instance : Name:nu= ll,WebBeans Type:DECORATOR,API Types:[java.lang.Object,org.apache.owb.TestD= ecorator,org.apache.owb.GenericInterface],Qualifiers:[javax.enterprise.inje= ct.Any,javax.enterprise.inject.Default]

=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 at or= g.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.ja= va:914)

=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 at org.apache.webbeans.decorator.We= bBeansDecoratorConfig.getDecoratorStack(WebBeansDecoratorConfig.java:160)

=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 at org.apache.webbeans.intercept.Interceptor= Handler.invoke(InterceptorHandler.java:216)

=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.invoke= (NormalScopedBeanInterceptorHandler.java:98)

=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= at org.apache.owb.DecoratedBean_$$_javassist_0.isDecoratorCalled(Decorated= Bean_$$_javassist_0.java)

I’ll do some further investigation.

 

Regards,

Arne

 

<= b>Von: Gurkan Erdogdu [mailto:cgurkanerdogdu@gmail.com]
Gesendet: Mit= twoch, 20. April 2011 17:59
An: user@openwebbeans.apache.org
<= b>Betreff: Re: Decorators with generic type-arguments
=

 

In your example, spec says that

  • the delegate type parameter is a = type variable, the bean type parameter is an actual type, and the actual ty= pe is assignable
    to the upper bound, if any, of the type variable.<= /o:p>

Actual T= ype of Bean Class --> Scope
Upper bound of type variable --> Annot= ation

Scope.isAssignableFrom(Annotation) --> False

Gurkan<= o:p>

2011/4/20 Arne Limburg <arne.limburg@openknowledge.de= >

Hi,

 

Currently I try to get a Decorator working= , that decorates an interface with a generic type argument. Although the Sp= ec is quite clear about how to handle this (in 8.3.1) I am afraid, OpenWebB= eans cannot handle it:

 = ;

This is the scenario

 

@Decorator

public class TestDecorator<A extends Annotation> implements Gener= icInterface<A> {

 = ; @Inject @Any @Delegate

&nb= sp; private GenericInterface<A> delegate;

}

 =

public class TestBean imple= ments GenericInterface<Scope> {

  …

}

 

<= p class=3DMsoNormal style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:= auto'>I have tried various combinations of actual type a= rguments in the Decorator (like Wildcard, raw type, …). The above lea= ds to a definition error. Some other combinations lead to a behavior where = the Decorator is not applied. Even declaring the Decorator with the same ac= tual type variable (Scope in the example) does not work?<= /p>

Would you consider this a bug or do I read the= spec wrong and this is not supported.

 

Shall I fi= ll a Jira Issue?

 

Regards,

Arne

 

--=

 

Arne Limburg - Enterprise Architect

<= span lang=3DEN-US>open knowledge GmbH, Oldenburg

Bismarckstra=DFe 13, 26122 Oldenburg

Mobil: +49 (0) = 151 108 22 942

Tel: +49 (0) 441 - 4082-0

Fax: +49 (0) 441 - 4082-111

arne.limburg@openknowledge= .de

http://www.openknowledge.de

 

Registergericht: Amtsgericht Oldenburg, HRB 4670

Gesch=E4ftsf=FChrer: Lars R=F6wekamp, Jens Schumann=

 


=

--
Gurkan Erdogdu
http://gurkanerdogdu.blogspot.com

<= /body>= --_000_CFB57C5359CC9D478AE2CAC5FCFB3CCE1037F488BAoldmzexch02op_--