You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ar...@apache.org on 2013/01/19 12:24:23 UTC

svn commit: r1435524 - /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java

Author: arne
Date: Sat Jan 19 11:24:23 2013
New Revision: 1435524

URL: http://svn.apache.org/viewvc?rev=1435524&view=rev
Log:
OWB-344: Fixed lifecycle methods of decorators

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java?rev=1435524&r1=1435523&r2=1435524&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java Sat Jan 19 11:24:23 2013
@@ -18,6 +18,8 @@
  */
 package org.apache.webbeans.component.creation;
 
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
 import javax.decorator.Delegate;
 import javax.enterprise.context.Dependent;
 import javax.enterprise.inject.Produces;
@@ -35,6 +37,7 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
 import java.lang.reflect.TypeVariable;
+import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -116,7 +119,53 @@ public class DecoratorBeanBuilder<T> ext
         bean.setConstructor(constructor.getJavaMember());
     }
 
+    @Override
+    protected List<AnnotatedMethod<?>> getPostConstructMethods()
+    {
+        List<AnnotatedMethod<?>> postConstructMethods = new ArrayList<AnnotatedMethod<?>>();
+        collectPostConstructMethods(getAnnotated().getJavaClass(), postConstructMethods);
+        return postConstructMethods;
+    }
+
+    private void collectPostConstructMethods(Class<?> type, List<AnnotatedMethod<?>> postConstructMethods)
+    {
+        if (type == null)
+        {
+            return;
+        }
+        collectPostConstructMethods(type.getSuperclass(), postConstructMethods);
+        for (AnnotatedMethod<?> annotatedMethod: getAnnotated().getMethods())
+        {
+            if (annotatedMethod.getJavaMember().getDeclaringClass() == type && annotatedMethod.isAnnotationPresent(PostConstruct.class))
+            {
+                postConstructMethods.add(annotatedMethod);
+            }
+        }
+    }
 
+    @Override
+    protected List<AnnotatedMethod<?>> getPreDestroyMethods()
+    {
+        List<AnnotatedMethod<?>> preDestroyMethods = new ArrayList<AnnotatedMethod<?>>();
+        collectPreDestroyMethods(getAnnotated().getJavaClass(), preDestroyMethods);
+        return preDestroyMethods;
+    }
+
+    private void collectPreDestroyMethods(Class<?> type, List<AnnotatedMethod<?>> preDestroyMethods)
+    {
+        if (type == null)
+        {
+            return;
+        }
+        collectPreDestroyMethods(type.getSuperclass(), preDestroyMethods);
+        for (AnnotatedMethod<?> annotatedMethod: getAnnotated().getMethods())
+        {
+            if (annotatedMethod.getJavaMember().getDeclaringClass() == type && annotatedMethod.isAnnotationPresent(PreDestroy.class))
+            {
+                preDestroyMethods.add(annotatedMethod);
+            }
+        }
+    }
 
     /**
      * If this method returns <code>false</code> the {@link #getBean()} method must not get called.