Return-Path: X-Original-To: apmail-openwebbeans-commits-archive@www.apache.org Delivered-To: apmail-openwebbeans-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id ADE88119EF for ; Thu, 4 Sep 2014 16:26:58 +0000 (UTC) Received: (qmail 52564 invoked by uid 500); 4 Sep 2014 16:26:58 -0000 Delivered-To: apmail-openwebbeans-commits-archive@openwebbeans.apache.org Received: (qmail 52544 invoked by uid 500); 4 Sep 2014 16:26:58 -0000 Mailing-List: contact commits-help@openwebbeans.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openwebbeans.apache.org Delivered-To: mailing list commits@openwebbeans.apache.org Received: (qmail 52529 invoked by uid 99); 4 Sep 2014 16:26:58 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Sep 2014 16:26:58 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Sep 2014 16:26:57 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 0A603238890D; Thu, 4 Sep 2014 16:26:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1622509 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/event/ContainerEventObserverMethodImpl.java test/java/org/apache/webbeans/test/portable/WithAnnotationTest.java Date: Thu, 04 Sep 2014 16:26:36 -0000 To: commits@openwebbeans.apache.org From: rmannibucau@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140904162637.0A603238890D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rmannibucau Date: Thu Sep 4 16:26:36 2014 New Revision: 1622509 URL: http://svn.apache.org/r1622509 Log: Fixes OWB-997 supporting generics in ProcessAnnotatedType observers using WithAnnotations Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ContainerEventObserverMethodImpl.java openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/WithAnnotationTest.java Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ContainerEventObserverMethodImpl.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ContainerEventObserverMethodImpl.java?rev=1622509&r1=1622508&r2=1622509&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ContainerEventObserverMethodImpl.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ContainerEventObserverMethodImpl.java Thu Sep 4 16:26:36 2014 @@ -27,6 +27,8 @@ import javax.enterprise.inject.spi.Defin import javax.enterprise.inject.spi.ProcessAnnotatedType; import javax.enterprise.inject.spi.WithAnnotations; import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; public class ContainerEventObserverMethodImpl extends ObserverMethodImpl { @@ -39,7 +41,12 @@ public class ContainerEventObserverMetho WithAnnotations withAnnotationsAnn = annotatedObservesParameter.getAnnotation(WithAnnotations.class); if (withAnnotationsAnn != null) { - if (annotatedObservesParameter.getBaseType().equals(ProcessAnnotatedType.class)) + Type baseType = annotatedObservesParameter.getBaseType(); + if (ParameterizedType.class.isInstance(baseType)) + { + baseType = ParameterizedType.class.cast(baseType).getRawType(); + } + if (baseType.equals(ProcessAnnotatedType.class)) { withAnnotations = withAnnotationsAnn.value(); } Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/WithAnnotationTest.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/WithAnnotationTest.java?rev=1622509&r1=1622508&r2=1622509&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/WithAnnotationTest.java (original) +++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/WithAnnotationTest.java Thu Sep 4 16:26:36 2014 @@ -43,17 +43,20 @@ public class WithAnnotationTest extends public void testWithAnnotation() { WithAnnotationExtension.scannedClasses = 0; + WithAnnotationExtension.one = 0; addExtension(new WithAnnotationExtension()); startContainer(WithoutAnyAnnotation.class, WithAnnotatedClass.class, WithAnnotatedField.class, WithAnnotatedMethod.class); Assert.assertEquals(3, WithAnnotationExtension.scannedClasses); + Assert.assertEquals(1, WithAnnotationExtension.one); } public static class WithAnnotationExtension implements Extension { public static int scannedClasses = 0; + public static int one = 0; public void processClassess(@Observes @WithAnnotations(MyAnnoation.class) ProcessAnnotatedType pat) { @@ -64,6 +67,11 @@ public class WithAnnotationTest extends { throw new IllegalStateException("This observer must not get called by the container!"); } + + public void noIssueWithGenericsOWB997(@Observes @WithAnnotations(MyAnnoation.class) ProcessAnnotatedType pat) + { + one++; + } } @Retention(RetentionPolicy.RUNTIME)