[seam-commits] Seam SVN: r10079 - trunk/src/main/org/jboss/seam.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Mon Feb 23 12:42:29 EST 2009


Author: norman.richards at jboss.com
Date: 2009-02-23 12:42:29 -0500 (Mon, 23 Feb 2009)
New Revision: 10079

Modified:
   trunk/src/main/org/jboss/seam/Component.java
Log:
JBSEAM-3950

Modified: trunk/src/main/org/jboss/seam/Component.java
===================================================================
--- trunk/src/main/org/jboss/seam/Component.java	2009-02-23 17:14:33 UTC (rev 10078)
+++ trunk/src/main/org/jboss/seam/Component.java	2009-02-23 17:42:29 UTC (rev 10079)
@@ -997,31 +997,38 @@
    private List<Interceptor> newSort(List<Interceptor> list)
    {
       List<SortItem<Interceptor>> siList = new ArrayList<SortItem<Interceptor>>();
-      Map<Class<?>,SortItem<Interceptor>> ht = new HashMap<Class<?>,SortItem<Interceptor>>();
+      Map<Class<?>,SortItem<Interceptor>> ht = 
+          new HashMap<Class<?>,SortItem<Interceptor>>();
 
-      for (Interceptor i : list)
-      {
+      for (Interceptor i: list) {
          SortItem<Interceptor> si = new SortItem<Interceptor>(i);
          siList.add(si);
-         ht.put( i.getUserInterceptorClass(), si );
+         ht.put(i.getUserInterceptorClass(), si);
       }
 
-      for (SortItem<Interceptor> si : siList)
-      {
-         Class<?> clazz = si.getObj().getUserInterceptorClass();
-         if ( clazz.isAnnotationPresent(org.jboss.seam.annotations.intercept.Interceptor.class) )
-         {
-            org.jboss.seam.annotations.intercept.Interceptor interceptorAnn = clazz.getAnnotation(org.jboss.seam.annotations.intercept.Interceptor.class);
-            for (Class<?> cl : Arrays.asList( interceptorAnn.around() ) )
-            {
-               SortItem<Interceptor> sortItem = ht.get(cl);
-               if (sortItem!=null) si.getAround().add( sortItem );
+      for (SortItem<Interceptor> si : siList) {
+          Class<?> clazz = si.getObj().getUserInterceptorClass();
+          org.jboss.seam.annotations.intercept.Interceptor interceptorAnn = 
+              seamInterceptor(clazz);
+          
+          if (interceptorAnn != null) {
+              for (Class<?> cl : Arrays.asList(interceptorAnn.around())) {
+                  if (!isCompatibleInterceptor(interceptorAnn, seamInterceptor(cl))) {
+                      log.warn("Interceptor " + clazz +  
+                               " has different type than around interceptor " + cl);
+                  }
+
+                  si.addAround(ht.get(cl));
+              }
+            
+            for (Class<?> cl : Arrays.asList( interceptorAnn.within())) {
+                if (!isCompatibleInterceptor(interceptorAnn, seamInterceptor(cl))) {                
+                    log.warn("Interceptor " + clazz +  
+                            " has different type than within interceptor " + cl);
+                }
+                
+                si.addWithin(ht.get(cl));
             }
-            for (Class<?> cl : Arrays.asList( interceptorAnn.within() ) )
-            {
-               SortItem<Interceptor> sortItem = ht.get(cl);
-               if (sortItem!=null) si.getWithin().add( sortItem );
-            }
          }
       }
 
@@ -1029,13 +1036,35 @@
       siList = sList.sort(siList);
 
       list.clear();
-      for (SortItem<Interceptor> si : siList)
-      {
-         list.add( si.getObj() );
+      for (SortItem<Interceptor> si : siList) {
+         list.add(si.getObj());
       }
       return list ;
    }
+   
+   private org.jboss.seam.annotations.intercept.Interceptor seamInterceptor(Class<?> clazz) {
+       return clazz.getAnnotation(org.jboss.seam.annotations.intercept.Interceptor.class);
+   }
 
+   private boolean isCompatibleInterceptor(
+            org.jboss.seam.annotations.intercept.Interceptor anno1,
+            org.jboss.seam.annotations.intercept.Interceptor anno2) {
+
+        if (anno1==null || anno2==null) {
+            return true;
+        }
+        
+        if (anno1.type()==InterceptorType.CLIENT && anno2.type()==InterceptorType.SERVER) {
+            return false;
+        } 
+        
+        if (anno2.type()==InterceptorType.CLIENT && anno2.type()==InterceptorType.SERVER) {
+            return false;
+        }
+         
+        return true;
+    }
+
    private void initDefaultInterceptors()
    {
       List<String> interceptors;




More information about the seam-commits mailing list