[webbeans-commits] Webbeans SVN: r1136 - ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector and 1 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Tue Jan 20 21:07:34 EST 2009


Author: pete.muir at jboss.org
Date: 2009-01-20 21:07:34 -0500 (Tue, 20 Jan 2009)
New Revision: 1136

Added:
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/WrappedAnnotatedParameter.java
Modified:
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/realization/FarmHouse.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/realization/RealizationTest.java
Log:
realization support for observer methods

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java	2009-01-21 01:06:31 UTC (rev 1135)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java	2009-01-21 02:07:34 UTC (rev 1136)
@@ -121,6 +121,7 @@
       {
          createRealizedProducerMethods(bean, annotatedClass);
          createRealizedProducerFields(bean, annotatedClass);
+         createRealizedObserverMethods(bean, annotatedClass);
       }
       
       log.info("Web Bean: " + bean);
@@ -179,12 +180,22 @@
 
    private void createObserverMethods(AbstractClassBean<?> declaringBean, AnnotatedClass<?> annotatedClass)
    {
-      for (AnnotatedMethod<?> observerMethod : annotatedClass.getDeclaredMethodsWithAnnotatedParameters(Observes.class))
+      for (AnnotatedMethod<?> method : annotatedClass.getDeclaredMethodsWithAnnotatedParameters(Observes.class))
       {
-         ObserverImpl<?> observer = ObserverImpl.of(observerMethod, declaringBean, manager);
-         manager.addObserver(observer);
+         createObserverMethod(declaringBean, method);
       }
    }
+   
+   private void createRealizedObserverMethods(AbstractClassBean<?> declaringBean, AnnotatedClass<?> realizingClass)
+   {
+      createObserverMethods(declaringBean, realizingClass.getSuperclass());
+   }
+   
+   private void createObserverMethod(AbstractClassBean<?> declaringBean, AnnotatedMethod<?> method)
+   {
+      ObserverImpl<?> observer = ObserverImpl.of(method, declaringBean, manager);
+      manager.addObserver(observer);
+   }
 
    private void createFacades(Set<AnnotatedItem<?, ?>> injectionPoints)
    {

Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/WrappedAnnotatedParameter.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/WrappedAnnotatedParameter.java	                        (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/WrappedAnnotatedParameter.java	2009-01-21 02:07:34 UTC (rev 1136)
@@ -0,0 +1,35 @@
+package org.jboss.webbeans.introspector;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+public class WrappedAnnotatedParameter<T> extends ForwardingAnnotatedParameter<T>
+{
+   
+   public static <T> WrappedAnnotatedParameter<T> of(AnnotatedParameter<T> parameter, Set<Annotation> extraAnnotations)
+   {
+      return new WrappedAnnotatedParameter<T>(parameter, extraAnnotations);
+   }
+   
+   private final AnnotatedParameter<T> delegate;
+   private AnnotationStore annotationStore;
+   
+   public WrappedAnnotatedParameter(AnnotatedParameter<T> parameter, Set<Annotation> extraAnnotations)
+   {
+      this.delegate = parameter;
+      this.annotationStore = AnnotationStore.wrap(parameter.getAnnotationStore(), extraAnnotations, extraAnnotations);
+   }
+   
+   @Override
+   protected AnnotatedParameter<T> delegate()
+   {
+      return delegate;
+   }
+   
+   @Override
+   public AnnotationStore getAnnotationStore()
+   {
+      return annotationStore;
+   }
+   
+}


Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/WrappedAnnotatedParameter.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/realization/FarmHouse.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/realization/FarmHouse.java	2009-01-21 01:06:31 UTC (rev 1135)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/realization/FarmHouse.java	2009-01-21 02:07:34 UTC (rev 1136)
@@ -1,5 +1,8 @@
 package org.jboss.webbeans.tck.unit.inheritance.realization;
 
+import javax.webbeans.Realizes;
+
+ at Smelly @Realizes
 class FarmHouse extends AbstractFarmHouse
 {
    

Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/realization/RealizationTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/realization/RealizationTest.java	2009-01-21 01:06:31 UTC (rev 1135)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/inheritance/realization/RealizationTest.java	2009-01-21 02:07:34 UTC (rev 1136)
@@ -137,11 +137,12 @@
       assert false;
    }
    
-   @Test(groups="broken") @SpecAssertion(section="4.1")
+   @Test @SpecAssertion(section="4.1")
    public void testObserverMethodInheritedAndHasSameBindings()
    {
       deployBeans(FarmHouse.class);
       assert manager.resolveObservers(new Cow(), new AnnotationLiteral<Tame>(){}).size() == 1;
+      assert manager.resolveObservers(new Cow(), SMELLY_LITERAL).size() == 0;
    }
    
 }




More information about the weld-commits mailing list