You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gp...@apache.org on 2010/03/04 02:44:32 UTC

svn commit: r918812 - /myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/ViewControllerInterceptor.java

Author: gpetracek
Date: Thu Mar  4 01:44:32 2010
New Revision: 918812

URL: http://svn.apache.org/viewvc?rev=918812&view=rev
Log:
cleanup

Modified:
    myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/ViewControllerInterceptor.java

Modified: myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/ViewControllerInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/ViewControllerInterceptor.java?rev=918812&r1=918811&r2=918812&view=diff
==============================================================================
--- myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/ViewControllerInterceptor.java (original)
+++ myfaces/extensions/cdi/branches/branch_for_jsf_1_2/jee-modules/jsf-module/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/listener/phase/ViewControllerInterceptor.java Thu Mar  4 01:44:32 2010
@@ -19,11 +19,14 @@
 package org.apache.myfaces.extensions.cdi.javaee.jsf.impl.listener.phase;
 
 import org.apache.myfaces.extensions.cdi.core.api.listener.phase.annotation.View;
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.annotation.BeforePhase;
+import org.apache.myfaces.extensions.cdi.javaee.jsf.api.listener.phase.annotation.AfterPhase;
 
 import javax.interceptor.Interceptor;
 import javax.interceptor.AroundInvoke;
 import javax.interceptor.InvocationContext;
 import javax.faces.context.FacesContext;
+import java.lang.annotation.Annotation;
 
 @View
 @Interceptor
@@ -50,7 +53,7 @@
 
     private boolean invokeListenerMethod(InvocationContext invocationContext)
     {
-        if(!invocationContext.getMethod().isAnnotationPresent(View.class))
+        if(!isObserverMethod(invocationContext) || !isViewAnnotationPresent(invocationContext))
         {
             return true;
         }
@@ -66,6 +69,28 @@
         return isMethodBoundToView(view.value(), viewId);
     }
 
+    private boolean isObserverMethod(InvocationContext invocationContext)
+    {
+        for(Annotation[] annotations : invocationContext.getMethod().getParameterAnnotations())
+        {
+            for(Annotation annotation : annotations)
+            {
+                if(BeforePhase.class.isAssignableFrom(annotation.annotationType()) ||
+                        AfterPhase.class.isAssignableFrom(annotation.annotationType()))
+                {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    private boolean isViewAnnotationPresent(InvocationContext invocationContext)
+    {
+        return invocationContext.getMethod().isAnnotationPresent(View.class) ||
+             invocationContext.getMethod().getDeclaringClass().isAnnotationPresent(View.class);
+    }
+
     private View getViewAnnotation(InvocationContext invocationContext)
     {
         View view;