[jboss-cvs] JBossAS SVN: r96141 - in projects/interceptors/trunk/jboss-interceptor/src: main/java/org/jboss/interceptor/proxy and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Nov 8 22:38:22 EST 2009


Author: marius.bogoevici
Date: 2009-11-08 22:38:22 -0500 (Sun, 08 Nov 2009)
New Revision: 96141

Modified:
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptorClassMetadataImpl.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorMethodHandler.java
   projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/FirstInterceptor.java
   projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTest.java
Log:
Further fixes.

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptorClassMetadataImpl.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptorClassMetadataImpl.java	2009-11-09 02:49:18 UTC (rev 96140)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptorClassMetadataImpl.java	2009-11-09 03:38:22 UTC (rev 96141)
@@ -97,7 +97,7 @@
       List<Method> methods = methodMap.get(interceptionType);
       return methods == null ? Collections.EMPTY_LIST : methods;
    }
-
+   
    public boolean isInterceptor()
    {
       return hasInterceptorMethods;

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorMethodHandler.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorMethodHandler.java	2009-11-09 02:49:18 UTC (rev 96140)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorMethodHandler.java	2009-11-09 03:38:22 UTC (rev 96141)
@@ -27,25 +27,26 @@
 
 /**
  * @author Marius Bogoevici
-*/
+ */
 public class InterceptorMethodHandler extends TargetInstanceProxyMethodHandler implements Serializable
 {
 
-   private static ThreadLocal<Set<MethodHolder>> interceptionStack = new ThreadLocal<Set<MethodHolder>>();
-
-
    private Map<Object, InterceptionHandler> interceptorHandlerInstances = new HashMap<Object, InterceptionHandler>();
    private InterceptorClassMetadata targetClassInterceptorMetadata;
    private List<InterceptionModel<Class<?>, ?>> interceptionModels;
 
    public InterceptorMethodHandler(Object target, Class<?> targetClass, List<InterceptionModel<Class<?>, ?>> interceptionModels, List<InterceptionHandlerFactory<?>> interceptionHandlerFactories)
    {
-      super(target, targetClass != null? targetClass: target.getClass());
+      super(target, targetClass != null ? targetClass : target.getClass());
       if (interceptionModels == null)
+      {
          throw new IllegalArgumentException("Interception model must not be null");
+      }
 
       if (interceptionHandlerFactories == null)
+      {
          throw new IllegalArgumentException("Interception handler factory must not be null");
+      }
 
       if (interceptionModels.size() != interceptionHandlerFactories.size())
       {
@@ -58,7 +59,7 @@
       {
          for (Object interceptorReference : this.interceptionModels.get(i).getAllInterceptors())
          {
-            interceptorHandlerInstances.put(interceptorReference, ((InterceptionHandlerFactory) interceptionHandlerFactories.get(i)).createFor((Object)interceptorReference));
+            interceptorHandlerInstances.put(interceptorReference, ((InterceptionHandlerFactory) interceptionHandlerFactories.get(i)).createFor((Object) interceptorReference));
          }
       }
       targetClassInterceptorMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(getTargetClass());
@@ -67,47 +68,36 @@
    public Object doInvoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable
    {
       ReflectionUtils.ensureAccessible(thisMethod);
-      if (getInterceptionStack().contains(MethodHolder.of(thisMethod, true)))
-         return thisMethod.invoke(getTargetInstance(), args);
-      try
+      if (!thisMethod.getDeclaringClass().equals(LifecycleMixin.class))
       {
-         getInterceptionStack().add(MethodHolder.of(thisMethod, true));
-
-         if (!thisMethod.getDeclaringClass().equals(LifecycleMixin.class))
+         if (!org.jboss.interceptor.util.InterceptionUtils.isInterceptionCandidate(thisMethod))
          {
-            if (!org.jboss.interceptor.util.InterceptionUtils.isInterceptionCandidate(thisMethod))
-               return thisMethod.invoke(getTargetInstance(), args);
-            if (InterceptionTypeRegistry.supportsTimeoutMethods() && thisMethod.isAnnotationPresent(InterceptionTypeRegistry.TIMEOUT_ANNOTATION_CLASS))
-               return executeInterception(thisMethod, args, InterceptionType.AROUND_TIMEOUT);
-            else
-               return executeInterception(thisMethod, args, InterceptionType.AROUND_INVOKE);
-         } else
+            return thisMethod.invoke(getTargetInstance(), args);
+         }
+         if (InterceptionTypeRegistry.supportsTimeoutMethods() && thisMethod.isAnnotationPresent(InterceptionTypeRegistry.TIMEOUT_ANNOTATION_CLASS))
          {
-            if (thisMethod.getName().equals(InterceptionUtils.POST_CONSTRUCT))
-            {
-               return executeInterception(null, null, InterceptionType.POST_CONSTRUCT);
-            } else if (thisMethod.getName().equals(InterceptionUtils.PRE_DESTROY))
-            {
-               return executeInterception(null, null, InterceptionType.PRE_DESTROY);
-            }
+            return executeInterception(thisMethod, args, InterceptionType.AROUND_TIMEOUT);
          }
-          return null;
-      } finally
+         else
+         {
+            return executeInterception(thisMethod, args, InterceptionType.AROUND_INVOKE);
+         }
+      }
+      else
       {
-         getInterceptionStack().remove(MethodHolder.of(thisMethod, true));
+         if (thisMethod.getName().equals(InterceptionUtils.POST_CONSTRUCT))
+         {
+            return executeInterception(null, null, InterceptionType.POST_CONSTRUCT);
+         }
+         else if (thisMethod.getName().equals(InterceptionUtils.PRE_DESTROY))
+         {
+            return executeInterception(null, null, InterceptionType.PRE_DESTROY);
+         }
       }
+      return null;
 
-
    }
 
-   private Set<MethodHolder> getInterceptionStack()
-   {
-      if (interceptionStack.get() == null)
-         interceptionStack.set(new HashSet<MethodHolder>());
-      return interceptionStack.get();
-   }
-
-
    private Object executeInterception(Method thisMethod, Object[] args, InterceptionType interceptionType) throws Throwable
    {
 
@@ -143,7 +133,7 @@
       }
    }
 
-    private void readObject(ObjectInputStream objectInputStream) throws IOException
+   private void readObject(ObjectInputStream objectInputStream) throws IOException
    {
       try
       {

Modified: projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/FirstInterceptor.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/FirstInterceptor.java	2009-11-09 02:49:18 UTC (rev 96140)
+++ projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/FirstInterceptor.java	2009-11-09 03:38:22 UTC (rev 96141)
@@ -42,5 +42,6 @@
    public void doAfterConstruction(InvocationContext invocationContext) throws Exception
    {
       InterceptorTestLogger.add(FirstInterceptor.class, "postConstruct");
+      invocationContext.proceed();
    }
 }

Modified: projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTest.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTest.java	2009-11-09 02:49:18 UTC (rev 96140)
+++ projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTest.java	2009-11-09 03:38:22 UTC (rev 96141)
@@ -39,37 +39,37 @@
    private static final String TEAM_NAME = "Ajax Amsterdam";
 
    private String[] expectedLoggedValues = {
-         "org.jboss.interceptors.proxy.InterceptionTest$MyFirstInterceptor_postConstruct",
-         "org.jboss.interceptors.proxy.InterceptionTest$MyFirstInterceptor_aroundInvokeBefore",
-         "org.jboss.interceptors.proxy.InterceptionTest$MySecondInterceptor_aroundInvokeBefore",
+         "org.jboss.interceptors.proxy.FirstInterceptor_postConstruct",
+         "org.jboss.interceptors.proxy.FirstInterceptor_aroundInvokeBefore",
+         "org.jboss.interceptors.proxy.SecondInterceptor_aroundInvokeBefore",
          "org.jboss.interceptors.proxy.FootballTeam_aroundInvokeBefore",
          "org.jboss.interceptors.proxy.FootballTeam_getName",
          "org.jboss.interceptors.proxy.FootballTeam_aroundInvokeAfter",
-         "org.jboss.interceptors.proxy.InterceptionTest$MySecondInterceptor_aroundInvokeAfter",
-         "org.jboss.interceptors.proxy.InterceptionTest$MyFirstInterceptor_aroundInvokeAfter",
-         "org.jboss.interceptors.proxy.InterceptionTest$MySecondInterceptor_preDestroy"
+         "org.jboss.interceptors.proxy.SecondInterceptor_aroundInvokeAfter",
+         "org.jboss.interceptors.proxy.FirstInterceptor_aroundInvokeAfter",
+         "org.jboss.interceptors.proxy.SecondInterceptor_preDestroy"
    };
 
    private String[] expectedLoggedValuesWithGlobalsIgnored = {
-         "org.jboss.interceptors.proxy.InterceptionTest$MyFirstInterceptor_postConstruct",
-         "org.jboss.interceptors.proxy.InterceptionTest$MySecondInterceptor_aroundInvokeBefore",
+         "org.jboss.interceptors.proxy.FirstInterceptor_postConstruct",
+         "org.jboss.interceptors.proxy.SecondInterceptor_aroundInvokeBefore",
          "org.jboss.interceptors.proxy.FootballTeam_aroundInvokeBefore",
          "org.jboss.interceptors.proxy.FootballTeam_getName",
          "org.jboss.interceptors.proxy.FootballTeam_aroundInvokeAfter",
-         "org.jboss.interceptors.proxy.InterceptionTest$MySecondInterceptor_aroundInvokeAfter",
-         "org.jboss.interceptors.proxy.InterceptionTest$MySecondInterceptor_preDestroy"
+         "org.jboss.interceptors.proxy.SecondInterceptor_aroundInvokeAfter",
+         "org.jboss.interceptors.proxy.SecondInterceptor_preDestroy"
    };
 
    private String[] expectedLoggedValuesOnSerialization = {
          "org.jboss.interceptors.proxy.FootballTeam_prePassivating",
          "org.jboss.interceptors.proxy.FootballTeam_postActivating",
-         "org.jboss.interceptors.proxy.InterceptionTest$MyFirstInterceptor_aroundInvokeBefore",
-         "org.jboss.interceptors.proxy.InterceptionTest$MySecondInterceptor_aroundInvokeBefore",
+         "org.jboss.interceptors.proxy.FirstInterceptor_aroundInvokeBefore",
+         "org.jboss.interceptors.proxy.SecondInterceptor_aroundInvokeBefore",
          "org.jboss.interceptors.proxy.FootballTeam_aroundInvokeBefore",
          "org.jboss.interceptors.proxy.FootballTeam_getName",
          "org.jboss.interceptors.proxy.FootballTeam_aroundInvokeAfter",
-         "org.jboss.interceptors.proxy.InterceptionTest$MySecondInterceptor_aroundInvokeAfter",
-         "org.jboss.interceptors.proxy.InterceptionTest$MyFirstInterceptor_aroundInvokeAfter",
+         "org.jboss.interceptors.proxy.SecondInterceptor_aroundInvokeAfter",
+         "org.jboss.interceptors.proxy.FirstInterceptor_aroundInvokeAfter",
    };
 
    private String[] expectedLoggedValuesWhenRaw = {




More information about the jboss-cvs-commits mailing list