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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jan 29 01:13:20 EST 2010


Author: marius.bogoevici
Date: 2010-01-29 01:13:14 -0500 (Fri, 29 Jan 2010)
New Revision: 100109

Added:
   projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/Team.java
Modified:
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptorClassMetadata.java
   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/AbstractClassInterceptionHandler.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandler.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionChain.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionHandler.java
   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/InterceptorProxyCreatorImpl.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java
   projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/FootballTeam.java
   projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTest.java
Log:
fixes on how interceptors are applied for lifecycle methods

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptorClassMetadata.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptorClassMetadata.java	2010-01-29 05:54:44 UTC (rev 100108)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptorClassMetadata.java	2010-01-29 06:13:14 UTC (rev 100109)
@@ -39,4 +39,6 @@
    List<Method> getInterceptorMethods(InterceptionType interceptionType);
 
    boolean isInterceptor();
+
+   boolean isTargetClass();
 }

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	2010-01-29 05:54:44 UTC (rev 100108)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptorClassMetadataImpl.java	2010-01-29 06:13:14 UTC (rev 100109)
@@ -156,5 +156,9 @@
       }
 
    }
-   
+
+   public boolean isTargetClass()
+   {
+      return interceptionTargetClass;
+   }
 }

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/AbstractClassInterceptionHandler.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/AbstractClassInterceptionHandler.java	2010-01-29 05:54:44 UTC (rev 100108)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/AbstractClassInterceptionHandler.java	2010-01-29 06:13:14 UTC (rev 100109)
@@ -19,6 +19,7 @@
 
 import java.lang.reflect.Method;
 import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
 import java.util.Queue;
 import java.util.List;
 import java.util.Map;
@@ -44,7 +45,7 @@
 
    protected AbstractClassInterceptionHandler(Class<?> clazz)
    {
-      this.interceptorMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(clazz);      
+      this.interceptorMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(clazz);
    }
 
    public AbstractClassInterceptionHandler(InterceptorClassMetadata targetClassInterceptorMetadata)
@@ -58,10 +59,13 @@
       List<Method> methods = interceptorMetadata.getInterceptorMethods(interceptionType);
       if (methods != null)
       {
-         DelegatingInvocationContext delegatingInvocationContext = new DelegatingInvocationContext(invocationContext, getInterceptorInstance(), methods);
+         DelegatingInvocationContext delegatingInvocationContext = new DelegatingInvocationContext(invocationContext, getInterceptorInstance(), methods, interceptionType);
          return delegatingInvocationContext.proceed();
-      } else
+      }
+      else
+      {
          throw new InterceptorException(target.toString() + " was requested to perform " + interceptionType.name() + " but no such method is defined on it");
+      }
    }
 
    public InterceptorClassMetadata getInterceptorMetadata()
@@ -75,13 +79,15 @@
       private InvocationContext delegateInvocationContext;
 
       private Object targetObject;
+      private InterceptionType interceptionType;
 
       private Queue<Method> invocationQueue;
 
-      public DelegatingInvocationContext(InvocationContext delegateInvocationContext, Object targetObject, List<Method> methods)
+      public DelegatingInvocationContext(InvocationContext delegateInvocationContext, Object targetObject, List<Method> methods, InterceptionType interceptionType)
       {
          this.delegateInvocationContext = delegateInvocationContext;
          this.targetObject = targetObject;
+         this.interceptionType = interceptionType;
          this.invocationQueue = new ConcurrentLinkedQueue<Method>(methods);
       }
 
@@ -109,24 +115,47 @@
       {
          if (!invocationQueue.isEmpty())
          {
-
-            Method interceptorMethod = invocationQueue.remove();
-            ReflectionUtils.ensureAccessible(interceptorMethod);
             try
             {
-               if (interceptorMethod.getParameterTypes().length == 0)
-                  return interceptorMethod.invoke(targetObject);
+               if (AbstractClassInterceptionHandler.this.interceptorMetadata.isTargetClass() && interceptionType.isLifecycleCallback())
+               {
+                  Iterator<Method> methodIterator = invocationQueue.iterator();
+                  while (methodIterator.hasNext())
+                  {
+                     Method interceptorMethod = methodIterator.next();
+                     ReflectionUtils.ensureAccessible(interceptorMethod);
+                     // interceptor methods defined on
+                     interceptorMethod.invoke(targetObject);
+                  }
+                  return null;
+               }
                else
-                  return interceptorMethod.invoke(targetObject, this);
+               {
+                  Method interceptorMethod = invocationQueue.remove();
+                  ReflectionUtils.ensureAccessible(interceptorMethod);
+                  if (interceptorMethod.getParameterTypes().length == 0)
+                  {
+                     return interceptorMethod.invoke(targetObject);
+                  }
+                  else
+                  {
+                     return interceptorMethod.invoke(targetObject, this);
+                  }
+               }
             }
             catch (InvocationTargetException e)
             {
                if (e.getCause() instanceof Exception)
-                  throw (Exception)e.getCause();
+               {
+                  throw (Exception) e.getCause();
+               }
                else
+               {
                   throw new InterceptorException(e);
+               }
             }
-         } else
+         }
+         else
          {
             return delegateInvocationContext.proceed();
          }

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandler.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandler.java	2010-01-29 05:54:44 UTC (rev 100108)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandler.java	2010-01-29 06:13:14 UTC (rev 100109)
@@ -29,6 +29,7 @@
 
    private final Object interceptorInstance;
 
+   private boolean selfIntercepting;
 
    public DirectClassInterceptionHandler(Object interceptorInstance, Class<?> clazz)
    {

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionChain.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionChain.java	2010-01-29 05:54:44 UTC (rev 100108)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionChain.java	2010-01-29 06:13:14 UTC (rev 100109)
@@ -62,7 +62,10 @@
       if (hasNext())
       {
          InterceptionHandler nextInterceptorHandler = interceptorHandlers.get(currentPosition++);
-         log.debug("Invoking next interceptor in chain:" + nextInterceptorHandler.getClass().getName());
+         if (log.isTraceEnabled())
+         {
+            log.trace("Invoking next interceptor in chain:" + nextInterceptorHandler.getClass().getName());
+         }
          return nextInterceptorHandler.invoke(target, interceptionType, invocationContext);
       }
       else

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionHandler.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionHandler.java	2010-01-29 05:54:44 UTC (rev 100108)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionHandler.java	2010-01-29 06:13:14 UTC (rev 100109)
@@ -27,6 +27,5 @@
 public interface InterceptionHandler
 {
    public Object invoke(Object target, InterceptionType interceptionType, InvocationContext invocationContext) throws Exception;
-
 }
 

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	2010-01-29 05:54:44 UTC (rev 100108)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorMethodHandler.java	2010-01-29 06:13:14 UTC (rev 100109)
@@ -36,7 +36,7 @@
    private InterceptorClassMetadata targetClassInterceptorMetadata;
    private List<InterceptionModel<Class<?>, ?>> interceptionModels;
 
-   public InterceptorMethodHandler(Object target, Class<?> targetClass, List<InterceptionModel<Class<?>, ?>> interceptionModels, List<InterceptionHandlerFactory<?>> interceptionHandlerFactories)
+   public InterceptorMethodHandler(Object target, Class<?> targetClass, List<InterceptionModel<Class<?>, ?>> interceptionModels, List<InterceptionHandlerFactory<?>> interceptionHandlerFactories, boolean includeTargetClass)
    {
       super(target, targetClass != null ? targetClass : target.getClass());
       if (interceptionModels == null)
@@ -63,7 +63,10 @@
             interceptorHandlerInstances.put(interceptorReference, ((InterceptionHandlerFactory) interceptionHandlerFactories.get(i)).createFor((Object) interceptorReference));
          }
       }
-      targetClassInterceptorMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(getTargetClass(), true);
+      if (includeTargetClass)
+      {
+         targetClassInterceptorMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(getTargetClass(), true);
+      }
    }
 
    public Object doInvoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable
@@ -112,7 +115,7 @@
          }
       }
 
-      if (targetClassInterceptorMetadata.getInterceptorMethods(interceptionType) != null && !targetClassInterceptorMetadata.getInterceptorMethods(interceptionType).isEmpty())
+      if (targetClassInterceptorMetadata != null && targetClassInterceptorMetadata.getInterceptorMethods(interceptionType) != null && !targetClassInterceptorMetadata.getInterceptorMethods(interceptionType).isEmpty())
       {
          interceptionHandlers.add(new DirectClassInterceptionHandler<Class<?>>(getTargetInstance(), targetClassInterceptorMetadata));
       }

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreatorImpl.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreatorImpl.java	2010-01-29 05:54:44 UTC (rev 100108)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreatorImpl.java	2010-01-29 06:13:14 UTC (rev 100109)
@@ -110,9 +110,14 @@
    }
 
 
+   public <T> MethodHandler getMethodHandler(Object target, Class<T> proxyClass, boolean includeTargetClass)
+   {
+      return new InterceptorMethodHandler(target, proxyClass, getModelsFor(proxyClass), interceptionHandlerFactories, includeTargetClass);
+   }
+
    public <T> MethodHandler getMethodHandler(Object target, Class<T> proxyClass)
    {
-      return new InterceptorMethodHandler(target, proxyClass, getModelsFor(proxyClass), interceptionHandlerFactories);
+      return this.getMethodHandler(target, proxyClass, true);
    }
 
    private <T> List<InterceptionModel<Class<?>, ?>> getModelsFor(Class<T> proxyClass)
@@ -125,125 +130,11 @@
       return interceptionModels;
    }
 
-   /*
-   public <T> T createInstrumentedInstance(Class<T> proxyClass, Class<?>[] constructorTypes, Object[] constructorArguments)
-   {
-      ProxyFactory proxyFactory = new ProxyFactory();
-      if (proxyClass != null)
-         proxyFactory.setSuperclass(proxyClass);
-
-
-      proxyFactory.setInterfaces(new Class<?>[]{LifecycleMixin.class});
-
-      proxyFactory.setHandler(new AutoProxifiedMethodHandler(proxyClass, interceptorRegistries));
-
-      try
-      {
-         return (T) proxyFactory.create(constructorTypes, constructorArguments);
-      } catch (Exception e)
-      {
-         throw new InterceptorException(e);
-      }
-   }
-   */
-
-   public <T> T constructInstrumentedInstance(final Object target, Class<T> proxyClass, Class<?>[] constructorTypes, Object[] constructorArguments) throws IllegalAccessException, InstantiationException
-   {
-      ProxyFactory proxyFactory = new ProxyFactory();
-      if (proxyClass != null)
-      {
-         proxyFactory.setSuperclass(target.getClass());
-      }
-
-      proxyFactory.setHandler(new InterceptorMethodHandler(target, proxyClass, getModelsFor(proxyClass), interceptionHandlerFactories));
-
-      try
-      {
-         return (T) proxyFactory.create(constructorTypes, constructorArguments);
-      }
-      catch (Exception e)
-      {
-         throw new InterceptorException(e);
-      }
-   }
-
    public <T> T createProxyFromInstance(final Object target, Class<T> proxyClass) throws IllegalAccessException, InstantiationException
    {
       return createProxyFromInstance(target, proxyClass, new Class[0], new Object[0]);
    }
 
-   public MethodHandler createInstanceProxifyingMethodHandler(final Object target, Class<?> proxyClass)
-   {
-      return new InterceptorMethodHandler(target, proxyClass, getModelsFor(proxyClass), interceptionHandlerFactories);
-   }
-
-   /*
-   private class AutoProxifiedMethodHandler implements MethodHandler
-   {
-      private InterceptorRegistry<Class<?>, I> registry;
-      private Map<I, InterceptionHandler> interceptorHandlerInstances = new HashMap<I, InterceptionHandler>();
-      private Class<?> targetClazz;
-      private InterceptorClassMetadata targetClassInterceptorMetadata;
-
-
-      public AutoProxifiedMethodHandler(Class<?> targetClazz, InterceptorRegistry<Class<?>, I> registry)
-      {
-         if (targetClazz == null)
-            throw new IllegalArgumentException("Target class must not be null");
-
-         this.targetClazz = targetClazz;
-         this.registry = registry;
-
-         for (I interceptorClazz : registry.getInterceptionModel(this.targetClazz).getAllInterceptors())
-         {
-            interceptorHandlerInstances.put(interceptorClazz, interceptionHandlerFactories.createFor(interceptorClazz));
-         }
-         targetClassInterceptorMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(targetClazz);
-      }
-
-      public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable
-      {
-         // do not intercept interceptor methods
-         if (!thisMethod.getDeclaringClass().equals(LifecycleMixin.class))
-         {
-            if (thisMethod.getAnnotation(AroundInvoke.class) != null)
-               return proceed.invoke(self, args);
-            return executeInterception(self, thisMethod, proceed, args, InterceptionType.AROUND_INVOKE);
-         } else
-         {
-            if (thisMethod.getName().equals(InterceptionUtils.POST_CONSTRUCT))
-            {
-               return executeInterception(self, null, null, null, InterceptionType.POST_CONSTRUCT);
-            } else if (thisMethod.getName().equals(InterceptionUtils.PRE_DESTROY))
-            {
-               return executeInterception(self, null, null, null, InterceptionType.PRE_DESTROY);
-            }
-         }
-
-         return null;
-      }
-
-      private Object executeInterception(Object self, Method thisMethod, Method proceed, Object[] args, InterceptionType interceptionType) throws Throwable
-      {
-
-         List<I> interceptorClasses = registry.getInterceptionModel(targetClazz).getInterceptors(interceptionType, thisMethod);
-         List<InterceptionHandler> interceptionHandlers = new ArrayList<InterceptionHandler>();
-         for (I interceptorReference : interceptorClasses)
-         {
-            interceptionHandlers.add(interceptorHandlerInstances.get(interceptorReference));
-         }
-
-         if (targetClassInterceptorMetadata.getInterceptorMethods(interceptionType) != null && !targetClassInterceptorMetadata.getInterceptorMethods(interceptionType).isEmpty())
-         {
-            interceptionHandlers.add(new DirectClassInterceptionHandler<Class<?>>(targetClazz));
-         }
-         InterceptionChain chain = new InterceptionChain(interceptionHandlers, interceptionType, self, proceed, args);
-         return chain.invokeNext(new InterceptorInvocationContext(chain, self, proceed, args));
-      }
-
-
-   }      */
-
 }
 
 

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java	2010-01-29 05:54:44 UTC (rev 100108)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java	2010-01-29 06:13:14 UTC (rev 100109)
@@ -37,6 +37,7 @@
 import java.lang.annotation.Annotation;
 import java.util.List;
 import java.util.Collections;
+import java.util.concurrent.Callable;
 
 import javassist.util.proxy.ProxyObject;
 
@@ -66,24 +67,56 @@
       };
    }
 
-   public static void executePostConstruct(Object proxy)
+   public static void executePostConstruct(Object proxy, Callable callback)
    {
       if (proxy instanceof LifecycleMixin)
       {
          LifecycleMixin lifecycleMixin = (LifecycleMixin) proxy;
          lifecycleMixin.lifecycle_mixin_$$_postConstruct();
       }
+      if (callback != null)
+      {
+         try
+         {
+            callback.call();
+         }
+         catch (Exception e)
+         {
+            throw new InterceptorException(e);
+         }
+      }
    }
 
-   public static void executePredestroy(Object proxy)
+   public static void executePostConstruct(Object proxy)
    {
+      executePostConstruct(proxy, null);
+   }
+
+   public static void executePredestroy(Object proxy, Callable callback)
+   {
       if (proxy instanceof LifecycleMixin)
       {
          LifecycleMixin lifecycleMixin = (LifecycleMixin) proxy;
          lifecycleMixin.lifecycle_mixin_$$_preDestroy();
       }
+      if (callback != null)
+      {
+         try
+         {
+            callback.call();
+         }
+         catch (Exception e)
+         {
+            throw new InterceptorException(e);
+         }
+      }
    }
 
+   public static void executePredestroy(Object proxy)
+   {
+      executePredestroy(proxy, null);
+   }
+
    /**
     * @param method
     * @return true if the method has none of the interception type annotations, and is public and not static

Modified: projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/FootballTeam.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/FootballTeam.java	2010-01-29 05:54:44 UTC (rev 100108)
+++ projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/FootballTeam.java	2010-01-29 06:13:14 UTC (rev 100109)
@@ -30,13 +30,11 @@
 /**
  * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
  */
-public class FootballTeam implements Serializable
+public class FootballTeam extends Team 
 {
 
    private String teamName;
 
-   public static boolean postConstructed = false;
-
     // an empty-argument constructor is required for proxifycation
     public FootballTeam() {
 
@@ -109,7 +107,7 @@
    @PostConstruct
    public void afterConstruction()
    {
-      postConstructed = true;
+      InterceptorTestLogger.add(FootballTeam.class, "postConstruct");
    }
 }
 

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	2010-01-29 05:54:44 UTC (rev 100108)
+++ projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTest.java	2010-01-29 06:13:14 UTC (rev 100109)
@@ -41,6 +41,8 @@
 
    private String[] expectedLoggedValues = {
          "org.jboss.interceptors.proxy.FirstInterceptor_postConstruct",
+         "org.jboss.interceptors.proxy.Team_postConstruct",
+         "org.jboss.interceptors.proxy.FootballTeam_postConstruct",
          "org.jboss.interceptors.proxy.FirstInterceptor_aroundInvokeBefore",
          "org.jboss.interceptors.proxy.SecondInterceptor_aroundInvokeBefore",
          "org.jboss.interceptors.proxy.FootballTeam_aroundInvokeBefore",
@@ -53,6 +55,8 @@
 
    private String[] expectedLoggedValuesWithGlobalsIgnored = {
          "org.jboss.interceptors.proxy.FirstInterceptor_postConstruct",
+         "org.jboss.interceptors.proxy.Team_postConstruct",
+         "org.jboss.interceptors.proxy.FootballTeam_postConstruct",
          "org.jboss.interceptors.proxy.SecondInterceptor_aroundInvokeBefore",
          "org.jboss.interceptors.proxy.FootballTeam_aroundInvokeBefore",
          "org.jboss.interceptors.proxy.FootballTeam_getName",
@@ -63,6 +67,8 @@
 
    private String[] expectedLoggedValuesOnSerialization = {
          "org.jboss.interceptors.proxy.FirstInterceptor_postConstruct",
+         "org.jboss.interceptors.proxy.Team_postConstruct",
+         "org.jboss.interceptors.proxy.FootballTeam_postConstruct",
          "org.jboss.interceptors.proxy.FootballTeam_prePassivating",
          "org.jboss.interceptors.proxy.FootballTeam_postActivating",
          "org.jboss.interceptors.proxy.FirstInterceptor_aroundInvokeBefore",
@@ -87,7 +93,6 @@
    {
       InterceptorTestLogger.reset();
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-      FootballTeam.postConstructed = false;
       builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(FirstInterceptor.class, SecondInterceptor.class);
       builder.interceptPostConstruct().with(FirstInterceptor.class);
       builder.interceptPreDestroy().with(SecondInterceptor.class);
@@ -100,7 +105,6 @@
    public void resetLogAndSetupClassesGlobally() throws Exception
    {
       InterceptorTestLogger.reset();
-      FootballTeam.postConstructed = false;
 
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
 
@@ -114,7 +118,6 @@
    public void resetLogAndSetupClassesMixed() throws Exception
    {
       InterceptorTestLogger.reset();
-      FootballTeam.postConstructed = false;
 
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
       builder.interceptAll().with(FirstInterceptor.class);
@@ -129,7 +132,6 @@
    public void resetLogAndSetupClassesWithGlobalsIgnored() throws Exception
    {
       InterceptorTestLogger.reset();
-      FootballTeam.postConstructed = false;
 
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
       builder.interceptAll().with(FirstInterceptor.class);
@@ -214,7 +216,6 @@
    public void testMethodParameterOverriding() throws Exception
    {
       InterceptorTestLogger.reset();
-      FootballTeam.postConstructed = false;
 
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
 
@@ -231,7 +232,6 @@
    public void testMethodParameterOverridingWithPrimitive() throws Exception
    {
       InterceptorTestLogger.reset();
-      FootballTeam.postConstructed = false;
 
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
 
@@ -248,7 +248,6 @@
    public void testMethodParameterOverridingWithObject() throws Exception
    {
       InterceptorTestLogger.reset();
-      FootballTeam.postConstructed = false;
 
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
 
@@ -265,7 +264,6 @@
    public void testMethodParameterOverridingWithObjectSucceed() throws Exception
    {
       InterceptorTestLogger.reset();
-      FootballTeam.postConstructed = false;
 
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
 
@@ -282,7 +280,6 @@
    public void testMethodParameterOverridingWithPrimitiveWidening() throws Exception
    {
       InterceptorTestLogger.reset();
-      FootballTeam.postConstructed = false;
 
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
 
@@ -299,7 +296,6 @@
    public void testMethodParameterOverridingWithPrimitiveNarrowing() throws Exception
    {
       InterceptorTestLogger.reset();
-      FootballTeam.postConstructed = false;
 
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
 
@@ -316,7 +312,6 @@
    public void testMethodParameterOverridingWithArray() throws Exception
    {
       InterceptorTestLogger.reset();
-      FootballTeam.postConstructed = false;
 
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
 
@@ -333,7 +328,6 @@
    public void testMethodParameterOverridingWithArrayOnString() throws Exception
    {
       InterceptorTestLogger.reset();
-      FootballTeam.postConstructed = false;
 
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
 
@@ -350,7 +344,6 @@
    public void testMethodParameterOverridingWithSubclass() throws Exception
    {
       InterceptorTestLogger.reset();
-      FootballTeam.postConstructed = false;
 
 
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
@@ -372,7 +365,6 @@
       Assert.assertEquals(TEAM_NAME, rawInstance.getName());
       Object[] logValues = InterceptorTestLogger.getLog().toArray();
       Assert.assertArrayEquals(iterateAndDisplay(logValues), expectedLoggedValuesWhenRaw, logValues);
-      Assert.assertTrue(FootballTeam.postConstructed);
    }
 
    private String iterateAndDisplay(Object[] logValues)

Added: projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/Team.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/Team.java	                        (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/Team.java	2010-01-29 06:13:14 UTC (rev 100109)
@@ -0,0 +1,17 @@
+package org.jboss.interceptors.proxy;
+
+import javax.annotation.PostConstruct;
+import java.io.Serializable;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class Team implements Serializable
+{
+
+   @PostConstruct
+   void teamPostConstruct()
+   {
+      InterceptorTestLogger.add(Team.class, "postConstruct"); 
+   }
+}




More information about the jboss-cvs-commits mailing list