You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2012/12/31 12:50:24 UTC

svn commit: r1427090 - /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java

Author: struberg
Date: Mon Dec 31 11:50:24 2012
New Revision: 1427090

URL: http://svn.apache.org/viewvc?rev=1427090&view=rev
Log:
OWB-344 add AnnotatedType version of interceptor check

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java?rev=1427090&r1=1427089&r2=1427090&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java Mon Dec 31 11:50:24 2012
@@ -91,8 +91,48 @@ public final class InterceptorUtil
     /**
      * Check if the given method is a 'business method'
      * in the sense of the Interceptor specification
+     * @param annotatedMethod
+     * @return <code>true</code> if the given method is an interceptable business method
+     */
+    public boolean isWebBeansBusinessMethod(AnnotatedMethod annotatedMethod)
+    {
+        Method method = annotatedMethod.getJavaMember();
+        int modifiers = method.getModifiers();
+
+        if ((modifiers & MODIFIER_STATIC_FINAL_PRIVATE) != 0)
+        {
+            // static, final and private methods are NO business methods!
+            return false;
+        }
+
+        Set<Annotation> anns = annotatedMethod.getAnnotations();
+
+        // filter out all container 'special' methods
+        for (Annotation ann : anns)
+        {
+            Class <? extends Annotation> annCls = ann.annotationType();
+            if (annCls.equals(Inject.class)        ||
+                    annCls.equals(PreDestroy.class)    ||
+                    annCls.equals(PostConstruct.class) ||
+                    annCls.equals(AroundInvoke.class)  ||
+                    annCls.equals(AroundTimeout.class) ||    // JSR-299 7.2
+                    ((ejbPlugin != null)              &&
+                            (annCls.equals(prePassivateClass)   ||  // JSR-299 7.2
+                                    annCls.equals(postActivateClass))))    // JSR-299 7.2
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    /**
+     * Check if the given method is a 'business method'
+     * in the sense of the Interceptor specification
      * @param method
      * @return <code>true</code> if the given method is an interceptable business method
+     * @deprecated TODO remove this class as it does not take AnnotatedType/Extensions into account
      */
     public boolean isWebBeansBusinessMethod(Method method)
     {
@@ -158,7 +198,6 @@ public final class InterceptorUtil
         }
     }
 
-    @SuppressWarnings("unchecked")
     public <T> boolean isBusinessMethodInterceptor(AnnotatedType<T> annotatedType)
     {
         Set<AnnotatedMethod<? super T>> methods = annotatedType.getMethods();
@@ -365,6 +404,7 @@ public final class InterceptorUtil
 
     /**
      * @param clazz AUTSCH! we should use the AnnotatedType for all that stuff!
+     * @deprecated TODO remove and only use the AnnotatedType version for all
      */
     public <T> void checkLifecycleConditions(Class<T> clazz, Annotation[] annots, String errorMessage)
     {