[jboss-cvs] JBossAS SVN: r100379 - in projects/interceptors/trunk/jboss-interceptor/src: main/java/org/jboss/interceptor/model/metadata and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Feb 3 18:58:46 EST 2010


Author: marius.bogoevici
Date: 2010-02-03 18:58:45 -0500 (Wed, 03 Feb 2010)
New Revision: 100379

Added:
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptorMetadata.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/SerializationProxyFactory.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/AbstractInterceptorMetadata.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/AbstractInterceptorMetadataSerializationProxy.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/ArrayIterator.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/ClassReference.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/ImmutableIteratorWrapper.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/MethodReference.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/ReflectiveClassReference.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/ReflectiveMethodReference.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/registry/ClassMetadataReader.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/registry/InterceptorMetadataRegistry.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/registry/SimpleClassMetadataReader.java
Removed:
   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/model/InterceptorReference.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/registry/InterceptorClassMetadataRegistry.java
Modified:
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/MethodHolder.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/DirectClassInterceptionHandlerFactory.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/InterceptorProxyCreator.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/metadata/InterceptorClassMetadataTestCase.java
   projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTestCase.java
Log:
Change the way metadata is read - allow for custom metadata reading and registration.

Deleted: 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-02-03 22:24:32 UTC (rev 100378)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptorClassMetadata.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
- * contributors by the @authors tag. See the copyright.txt in the
- * distribution for a full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.interceptor.model;
-
-import java.lang.reflect.Method;
-import java.util.List;
-
-/**
- * A 
- * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
- */
-public interface InterceptorClassMetadata
-{
-   Class<?> getInterceptorClass();
-
-   /**
-    * Returns the list of methods to be invoked on this class when doing
-    * interception (as an interceptor is supposed to invoke the superclass
-    * methods too)
-    *
-    * @param interceptionType
-    * @return a list of methods
-    */
-   List<Method> getInterceptorMethods(InterceptionType interceptionType);
-
-   boolean isInterceptor();
-
-   boolean isTargetClass();
-}

Deleted: 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-02-03 22:24:32 UTC (rev 100378)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptorClassMetadataImpl.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -1,164 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
- * contributors by the @authors tag. See the copyright.txt in the
- * distribution for a full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.interceptor.model;
-
-import java.lang.reflect.Method;
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.interceptor.util.InterceptionUtils;
-import org.jboss.interceptor.util.ReflectionUtils;
-import org.jboss.interceptor.registry.InterceptorClassMetadataRegistry;
-import org.jboss.interceptor.InterceptorException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
- */
-public class InterceptorClassMetadataImpl implements InterceptorClassMetadata, Serializable
-{
-
-   private Logger log = LoggerFactory.getLogger(InterceptorClassMetadataImpl.class);
-
-   private Class<?> interceptorClass;
-
-   private boolean interceptionTargetClass;
-
-   private Map<InterceptionType, List<Method>> methodMap = new HashMap<InterceptionType, List<Method>>();
-
-   private boolean hasInterceptorMethods;
-
-   /**
-    * @param interceptorClass
-    * @param interceptionTargetClass - a flag indicating whether the inspected class is
-    *                                the interception target itself. Interceptor method signatures are different
-    *                                in this case
-    */
-   public InterceptorClassMetadataImpl(Class<?> interceptorClass, boolean interceptionTargetClass)
-   {
-      this.interceptorClass = interceptorClass;
-      this.interceptionTargetClass = interceptionTargetClass;
-
-      Class<?> currentClass = interceptorClass;
-
-      Set<MethodHolder> foundMethods = new HashSet<MethodHolder>();
-      do
-      {
-         Set<InterceptionType> detectedInterceptorTypes = new HashSet<InterceptionType>();
-
-         for (Method method : currentClass.getDeclaredMethods())
-         {
-            for (InterceptionType interceptionType : InterceptionTypeRegistry.getSupportedInterceptionTypes())
-            {
-               if (InterceptionUtils.isInterceptorMethod(interceptionType, method, interceptionTargetClass))
-               {
-                  if (methodMap.get(interceptionType) == null)
-                  {
-                     methodMap.put(interceptionType, new LinkedList<Method>());
-                  }
-                  if (detectedInterceptorTypes.contains(interceptionType))
-                  {
-                     throw new InterceptorMetadataException("Same interception type cannot be specified twice on the same class");
-                  }
-                  else
-                  {
-                     detectedInterceptorTypes.add(interceptionType);
-                  }
-                  // add method in the list - if it is there already, it means that it has been added by a subclass
-                  ReflectionUtils.ensureAccessible(method);
-                  if (!foundMethods.contains(MethodHolder.of(method, false)))
-                  {
-                     methodMap.get(interceptionType).add(0, method);
-                     hasInterceptorMethods = true;
-                  }
-               }
-            }
-            foundMethods.add(MethodHolder.of(method, false));
-         }
-         currentClass = currentClass.getSuperclass();
-      }
-      while (!Object.class.equals(currentClass));
-   }
-
-   public InterceptorClassMetadataImpl(Class<?> interceptorClass)
-   {
-      this(interceptorClass, false);
-   }
-
-
-   public Class<?> getInterceptorClass()
-   {
-      return interceptorClass;
-   }
-
-   public List<Method> getInterceptorMethods(InterceptionType interceptionType)
-   {
-      List<Method> methods = methodMap.get(interceptionType);
-      return methods == null ? Collections.EMPTY_LIST : methods;
-   }
-
-   public boolean isInterceptor()
-   {
-      return hasInterceptorMethods;
-   }
-
-   private Object writeReplace()
-   {
-      return new InterceptorClassMetadataSerializationProxy(getInterceptorClass().getName(), interceptionTargetClass);
-   }
-
-   static class InterceptorClassMetadataSerializationProxy implements Serializable
-   {
-      private String className;
-
-      private boolean interceptionTargetClass;
-
-      InterceptorClassMetadataSerializationProxy(String className, boolean interceptionTargetClass)
-      {
-         this.className = className;
-         this.interceptionTargetClass = interceptionTargetClass;
-      }
-
-      private Object readResolve()
-      {
-         try
-         {
-            Class<?> interceptorClass = ReflectionUtils.classForName(className);          
-            return InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(interceptorClass, interceptionTargetClass);
-         }
-         catch (ClassNotFoundException e)
-         {
-            throw new InterceptorException("Failed to deserialize the interceptor class metadata", e);
-         }
-      }
-
-   }
-
-   public boolean isTargetClass()
-   {
-      return interceptionTargetClass;
-   }
-}

Copied: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptorMetadata.java (from rev 100310, 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/InterceptorMetadata.java	                        (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptorMetadata.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.interceptor.model;
+
+import java.util.List;
+
+import org.jboss.interceptor.model.metadata.ClassReference;
+import org.jboss.interceptor.model.metadata.MethodReference;
+
+/**
+ * A 
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public interface InterceptorMetadata
+{
+   ClassReference getInterceptorClass();
+
+   /**
+    * Returns the list of method references to be invoked on this class when doing
+    * interception (as an interceptor is supposed to invoke the superclass
+    * methods too)
+    *
+    * @param interceptionType
+    * @return a list of methods
+    */
+   List<MethodReference> getInterceptorMethods(InterceptionType interceptionType);
+
+   boolean isInterceptor();
+
+   boolean isTargetClass();
+}

Deleted: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptorReference.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptorReference.java	2010-02-03 22:24:32 UTC (rev 100378)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/InterceptorReference.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -1,30 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
- * contributors by the @authors tag. See the copyright.txt in the
- * distribution for a full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.interceptor.model;
-
-import org.jboss.interceptor.proxy.InterceptionHandler;
-
-/**
- * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
- */
-public interface InterceptorReference<T>
-{
-   T getReferredInterceptor();
-
-   InterceptionHandler getInterceptionHandler();
-}

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/MethodHolder.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/MethodHolder.java	2010-02-03 22:24:32 UTC (rev 100378)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/MethodHolder.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -21,6 +21,7 @@
 import java.util.Arrays;
 import java.io.Serializable;
 
+import org.jboss.interceptor.model.metadata.MethodReference;
 import org.jboss.interceptor.util.ReflectionUtils;
 import org.jboss.interceptor.InterceptorException;
 
@@ -41,6 +42,11 @@
       return new MethodHolder(method, withDeclaringClass);
    }
 
+   public static MethodHolder of(MethodReference method, boolean withDeclaringClass)
+   {
+      return new MethodHolder(method.getJavaMethod(), withDeclaringClass);
+   }
+
    private MethodHolder(Method method, boolean withDeclaringClass)
    {
       this.methodName = method.getName();

Added: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/SerializationProxyFactory.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/SerializationProxyFactory.java	                        (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/SerializationProxyFactory.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.interceptor.model;
+
+import java.io.Serializable;
+
+/**
+ * @author Marius Bogoevici
+ */
+public interface SerializationProxyFactory
+{
+   public Serializable createSerializableProxy();
+}

Copied: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/AbstractInterceptorMetadata.java (from rev 100310, 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/metadata/AbstractInterceptorMetadata.java	                        (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/AbstractInterceptorMetadata.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.interceptor.model.metadata;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.interceptor.model.InterceptionType;
+import org.jboss.interceptor.model.InterceptionTypeRegistry;
+import org.jboss.interceptor.model.InterceptorMetadata;
+import org.jboss.interceptor.model.InterceptorMetadataException;
+import org.jboss.interceptor.model.MethodHolder;
+import org.jboss.interceptor.model.metadata.ClassReference;
+import org.jboss.interceptor.model.metadata.MethodReference;
+import org.jboss.interceptor.util.InterceptionUtils;
+import org.jboss.interceptor.util.ReflectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public abstract class AbstractInterceptorMetadata implements InterceptorMetadata, Serializable
+{
+
+   private Logger log = LoggerFactory.getLogger(AbstractInterceptorMetadata.class);
+   private ClassReference interceptorClass;
+   private Map<InterceptionType, List<MethodReference>> methodMap;
+   private boolean targetClass;
+
+   protected AbstractInterceptorMetadata(ClassReference interceptorClass, boolean targetClass)
+   {
+      this.interceptorClass = interceptorClass;
+      this.methodMap = buildMethodMap(interceptorClass, targetClass);
+      this.targetClass = targetClass;
+   }
+
+   private Map<InterceptionType, List<MethodReference>> buildMethodMap(ClassReference interceptorClass, boolean isTargetClass)
+   {
+      Map<InterceptionType, List<MethodReference>> methodMap = new HashMap<InterceptionType, List<MethodReference>>();
+      ClassReference currentClass = interceptorClass;
+      Set<MethodHolder> foundMethods = new HashSet<MethodHolder>();
+      do
+      {
+         Set<InterceptionType> detectedInterceptorTypes = new HashSet<InterceptionType>();
+
+         for (MethodReference method : currentClass.getDeclaredMethods())
+         {
+            for (InterceptionType interceptionType : InterceptionTypeRegistry.getSupportedInterceptionTypes())
+            {
+               if (InterceptionUtils.isInterceptorMethod(interceptionType, method, isTargetClass))
+               {
+                  if (methodMap.get(interceptionType) == null)
+                  {
+                     methodMap.put(interceptionType, new LinkedList<MethodReference>());
+                  }
+                  if (detectedInterceptorTypes.contains(interceptionType))
+                  {
+                     throw new InterceptorMetadataException("Same interception type cannot be specified twice on the same class");
+                  }
+                  else
+                  {
+                     detectedInterceptorTypes.add(interceptionType);
+                  }
+                  // add method in the list - if it is there already, it means that it has been added by a subclass
+                  ReflectionUtils.ensureAccessible(method.getJavaMethod());
+                  if (!foundMethods.contains(MethodHolder.of(method, false)))
+                  {
+                     methodMap.get(interceptionType).add(0, method);
+                  }
+               }
+            }
+            foundMethods.add(MethodHolder.of(method, false));
+         }
+         currentClass = currentClass.getSuperclass();
+      }
+      while (!Object.class.equals(currentClass.getJavaClass()));
+      return methodMap;
+   }
+
+   public ClassReference getInterceptorClass()
+   {
+      return interceptorClass;
+   }
+
+   public List<MethodReference> getInterceptorMethods(InterceptionType interceptionType)
+   {
+      if (methodMap != null)
+      {
+         List<MethodReference> methods = methodMap.get(interceptionType);
+         return methods == null ? Collections.<MethodReference>emptyList() : methods;
+      }
+      else
+      {
+         return Collections.<MethodReference>emptyList();
+      }
+   }
+
+   public boolean isInterceptor()
+   {
+      return !methodMap.keySet().isEmpty();
+   }
+
+   private Object writeReplace()
+   {
+      return createSerializableProxy();
+   }
+
+   protected abstract Object createSerializableProxy();
+
+   public boolean isTargetClass()
+   {
+      return targetClass;
+   }
+
+
+}

Added: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/AbstractInterceptorMetadataSerializationProxy.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/AbstractInterceptorMetadataSerializationProxy.java	                        (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/AbstractInterceptorMetadataSerializationProxy.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.interceptor.model.metadata;
+
+import java.io.Serializable;
+
+import org.jboss.interceptor.InterceptorException;
+import org.jboss.interceptor.model.InterceptorMetadata;
+
+public abstract class AbstractInterceptorMetadataSerializationProxy implements Serializable
+{
+   private String className;
+
+   private boolean interceptionTargetClass;
+
+   protected AbstractInterceptorMetadataSerializationProxy(String className, boolean interceptionTargetClass)
+   {
+      this.className = className;
+      this.interceptionTargetClass = interceptionTargetClass;
+   }
+
+   private Object readResolve()
+   {
+      try
+      {
+         return loadInterceptorMetadata();
+      }
+      catch (ClassNotFoundException e)
+      {
+         throw new InterceptorException("Failed to deserialize the interceptor class metadata", e);
+      }
+   }
+
+   protected String getClassName()
+   {
+      return className;
+   }
+
+   protected boolean isInterceptionTargetClass()
+   {
+      return interceptionTargetClass;
+   }
+
+   protected abstract InterceptorMetadata loadInterceptorMetadata() throws ClassNotFoundException;
+}

Added: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/ArrayIterator.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/ArrayIterator.java	                        (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/ArrayIterator.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.interceptor.model.metadata;
+
+import java.util.Iterator;
+
+import org.jboss.interceptor.InterceptorException;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class ArrayIterator<T> implements Iterator<T>
+{
+   private T[] array;
+
+   private int currentIndex = 0;
+
+   public ArrayIterator(T[] array)
+   {
+      if (array == null)
+         throw new IllegalArgumentException("Iterated array cannot be null");
+      this.array = array;
+   }
+
+   public boolean hasNext()
+   {
+      return currentIndex < array.length;
+   }
+
+   public T next()
+   {
+      return array[currentIndex++];
+   }
+
+   public void remove()
+   {
+      throw new UnsupportedOperationException("Removal of elements is not supported");
+   }
+}

Added: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/ClassReference.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/ClassReference.java	                        (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/ClassReference.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.interceptor.model.metadata;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * Abstraction of a class reference. Allows for the framework client to configure
+ * their own way of providing class metadata, rather than relying exclusively on
+ * Java reflection.
+ * 
+ * @author Marius Bogoevici
+ */
+public interface ClassReference extends Serializable
+{
+   Iterable<MethodReference> getDeclaredMethods();
+   
+   Class<?> getJavaClass();
+   
+   String getClassName();
+
+   ClassReference getSuperclass();
+}

Added: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/ImmutableIteratorWrapper.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/ImmutableIteratorWrapper.java	                        (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/ImmutableIteratorWrapper.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.interceptor.model.metadata;
+
+import java.util.Iterator;
+
+/**
+* @author Marius Bogoevici
+*/
+public abstract class ImmutableIteratorWrapper<T> implements Iterator<MethodReference>
+{
+
+   private Iterator<T> originalIterator;
+
+   ImmutableIteratorWrapper(Iterator<T> originalIterator)
+   {
+      this.originalIterator = originalIterator;
+   }
+
+
+   public boolean hasNext()
+   {
+      return originalIterator.hasNext();
+   }
+
+   public MethodReference next()
+   {
+      return wrapObject(originalIterator.next());
+   }
+
+   protected abstract MethodReference wrapObject(T t);
+
+   public void remove()
+   {
+      throw new UnsupportedOperationException("Removal not supported");
+   }
+}

Added: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/MethodReference.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/MethodReference.java	                        (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/MethodReference.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.interceptor.model.metadata;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+/**
+ * Abstraction of a method reference. Allows for the framework client to configure
+ * their own way of providing method metadata, rather than relying exclusively on
+ * Java reflection.
+ * 
+ * @author Marius Bogoevici
+ */
+public interface MethodReference
+{
+   Method getJavaMethod();
+
+   Annotation getAnnotation(Class<? extends Annotation> annotationClass);
+
+   ClassReference getReturnType();
+
+}

Added: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/ReflectiveClassReference.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/ReflectiveClassReference.java	                        (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/ReflectiveClassReference.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.interceptor.model.metadata;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class ReflectiveClassReference implements ClassReference, Serializable
+{
+
+   private Class<?> clazz;
+
+   private ReflectiveClassReference(Class<?> clazz)
+   {
+      this.clazz = clazz;
+   }
+
+   public static ClassReference of(Class<?> clazz)
+   {
+      return new ReflectiveClassReference(clazz);
+   }
+
+   public String getClassName()
+   {
+      return clazz.getName();
+   }
+
+   public Iterable<MethodReference> getDeclaredMethods()
+   {
+      return new Iterable<MethodReference>()
+      {
+         public Iterator<MethodReference> iterator()
+         {
+             return new ImmutableIteratorWrapper<Method>(new ArrayIterator(ReflectiveClassReference.this.clazz.getDeclaredMethods()))
+             {
+                @Override
+                protected MethodReference wrapObject(Method method)
+                {
+                   return ReflectiveMethodReference.of(method);
+                }
+             };
+         }
+      };     
+   }
+
+   public Class<?> getJavaClass()
+   {
+      return clazz;
+   }   
+
+   public ClassReference getSuperclass()
+   {
+      Class<?> superClass = clazz.getSuperclass();
+      return superClass == null? null : new ReflectiveClassReference(superClass);
+   }
+
+}

Added: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/ReflectiveMethodReference.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/ReflectiveMethodReference.java	                        (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/model/metadata/ReflectiveMethodReference.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.interceptor.model.metadata;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class ReflectiveMethodReference implements MethodReference, Serializable
+{
+   private Method javaMethod;
+
+   private ReflectiveMethodReference(Method method)
+   {
+      this.javaMethod = method;
+   }
+
+   public static MethodReference of(Method method)
+   {
+      return new ReflectiveMethodReference(method);
+   }
+
+   public Annotation getAnnotation(Class<? extends Annotation> annotationClass)
+   {
+      return javaMethod.getAnnotation(annotationClass);
+   }
+
+   public Method getJavaMethod()
+   {
+      return javaMethod;
+   }
+
+   public ClassReference getReturnType()
+   {
+      return ReflectiveClassReference.of(javaMethod.getReturnType());
+   }
+
+}

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-02-03 22:24:32 UTC (rev 100378)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/AbstractClassInterceptionHandler.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -28,35 +28,30 @@
 
 import javax.interceptor.InvocationContext;
 
+import org.jboss.interceptor.model.metadata.MethodReference;
 import org.jboss.interceptor.util.ReflectionUtils;
 import org.jboss.interceptor.InterceptorException;
-import org.jboss.interceptor.registry.InterceptorClassMetadataRegistry;
 import org.jboss.interceptor.model.InterceptionType;
-import org.jboss.interceptor.model.InterceptorClassMetadata;
+import org.jboss.interceptor.model.InterceptorMetadata;
 
 /**
  * @author Marius Bogoevici
  */
 public abstract class AbstractClassInterceptionHandler implements InterceptionHandler, Serializable
 {
-   private InterceptorClassMetadata interceptorMetadata;
+   private InterceptorMetadata interceptorMetadata;
 
    public abstract Object getInterceptorInstance();
 
-   protected AbstractClassInterceptionHandler(Class<?> clazz)
+   public AbstractClassInterceptionHandler(InterceptorMetadata interceptorMetadata)
    {
-      this.interceptorMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(clazz);
+      this.interceptorMetadata = interceptorMetadata;
    }
 
-   public AbstractClassInterceptionHandler(InterceptorClassMetadata targetClassInterceptorMetadata)
-   {
-      this.interceptorMetadata = targetClassInterceptorMetadata;
-   }
 
-
    public Object invoke(Object target, InterceptionType interceptionType, InvocationContext invocationContext) throws Exception
    {
-      List<Method> methods = interceptorMetadata.getInterceptorMethods(interceptionType);
+      List<MethodReference> methods = interceptorMetadata.getInterceptorMethods(interceptionType);
       if (methods != null)
       {
          DelegatingInvocationContext delegatingInvocationContext = new DelegatingInvocationContext(invocationContext, getInterceptorInstance(), methods, interceptionType);
@@ -68,7 +63,7 @@
       }
    }
 
-   public InterceptorClassMetadata getInterceptorMetadata()
+   public InterceptorMetadata getInterceptorMetadata()
    {
       return interceptorMetadata;
    }
@@ -81,14 +76,14 @@
       private Object targetObject;
       private InterceptionType interceptionType;
 
-      private Queue<Method> invocationQueue;
+      private Queue<MethodReference> invocationQueue;
 
-      public DelegatingInvocationContext(InvocationContext delegateInvocationContext, Object targetObject, List<Method> methods, InterceptionType interceptionType)
+      public DelegatingInvocationContext(InvocationContext delegateInvocationContext, Object targetObject, List<MethodReference> methods, InterceptionType interceptionType)
       {
          this.delegateInvocationContext = delegateInvocationContext;
          this.targetObject = targetObject;
          this.interceptionType = interceptionType;
-         this.invocationQueue = new ConcurrentLinkedQueue<Method>(methods);
+         this.invocationQueue = new ConcurrentLinkedQueue<MethodReference>(methods);
       }
 
       public Map<String, Object> getContextData()
@@ -119,27 +114,27 @@
             {
                if (AbstractClassInterceptionHandler.this.interceptorMetadata.isTargetClass() && interceptionType.isLifecycleCallback())
                {
-                  Iterator<Method> methodIterator = invocationQueue.iterator();
+                  Iterator<MethodReference> methodIterator = invocationQueue.iterator();
                   while (methodIterator.hasNext())
                   {
-                     Method interceptorMethod = methodIterator.next();
-                     ReflectionUtils.ensureAccessible(interceptorMethod);
+                     MethodReference interceptorMethod = methodIterator.next();
+                     ReflectionUtils.ensureAccessible(interceptorMethod.getJavaMethod());
                      // interceptor methods defined on
-                     interceptorMethod.invoke(targetObject);
+                     interceptorMethod.getJavaMethod().invoke(targetObject);
                   }
                   return null;
                }
                else
                {
-                  Method interceptorMethod = invocationQueue.remove();
-                  ReflectionUtils.ensureAccessible(interceptorMethod);
-                  if (interceptorMethod.getParameterTypes().length == 0)
+                  MethodReference interceptorMethod = invocationQueue.remove();
+                  ReflectionUtils.ensureAccessible(interceptorMethod.getJavaMethod());
+                  if (interceptorMethod.getJavaMethod().getParameterTypes().length == 0)
                   {
-                     return interceptorMethod.invoke(targetObject);
+                     return interceptorMethod.getJavaMethod().invoke(targetObject);
                   }
                   else
                   {
-                     return interceptorMethod.invoke(targetObject, this);
+                     return interceptorMethod.getJavaMethod().invoke(targetObject, this);
                   }
                }
             }

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-02-03 22:24:32 UTC (rev 100378)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandler.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -17,9 +17,10 @@
 
 package org.jboss.interceptor.proxy;
 
-import org.jboss.interceptor.model.InterceptorClassMetadata;
-import org.jboss.interceptor.registry.InterceptorClassMetadataRegistry;
+import org.jboss.interceptor.model.metadata.ClassReference;
+import org.jboss.interceptor.model.InterceptorMetadata;
 import org.jboss.interceptor.InterceptorException;
+import org.jboss.interceptor.util.ReflectionUtils;
 
 /**
  * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
@@ -29,17 +30,15 @@
 
    private final Object interceptorInstance;
 
-   private boolean selfIntercepting;
-
-   public DirectClassInterceptionHandler(Object interceptorInstance, Class<?> clazz)
+   public DirectClassInterceptionHandler(Object interceptorInstance, InterceptorMetadata interceptorMetadata)
    {
-      super((clazz == null) ? interceptorInstance.getClass() : clazz);
+      super(interceptorMetadata);
       this.interceptorInstance = interceptorInstance;
    }
 
-   public DirectClassInterceptionHandler(Class<?> simpleInterceptorClass)
+   public DirectClassInterceptionHandler(Class<?> simpleInterceptorClass, InterceptorMetadata interceptorMetadata)
    {
-      super(simpleInterceptorClass);
+      super(interceptorMetadata);
       if (simpleInterceptorClass == null)
          throw new IllegalArgumentException("Class must not be null");
       try
@@ -52,13 +51,6 @@
 
    }
 
-   public DirectClassInterceptionHandler(Object targetInstance, InterceptorClassMetadata targetClassInterceptorMetadata)
-   {
-      super(targetClassInterceptorMetadata);
-      this.interceptorInstance = targetInstance;
-   }
-
-
    public Object getInterceptorInstance()
    {
       return interceptorInstance;

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandlerFactory.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandlerFactory.java	2010-02-03 22:24:32 UTC (rev 100378)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandlerFactory.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -17,12 +17,23 @@
 
 package org.jboss.interceptor.proxy;
 
+import org.jboss.interceptor.model.metadata.ClassReference;
+import org.jboss.interceptor.registry.InterceptorMetadataRegistry;
+
 /**
  * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
  */
-public class DirectClassInterceptionHandlerFactory implements InterceptionHandlerFactory<Class<?>> {
+public class DirectClassInterceptionHandlerFactory implements InterceptionHandlerFactory<Class<?>>
+{
+   private InterceptorMetadataRegistry interceptorMetadataRegistry;
 
-    public InterceptionHandler createFor(Class<?> clazz) {
-        return new DirectClassInterceptionHandler(clazz);
-    }
+   public DirectClassInterceptionHandlerFactory(InterceptorMetadataRegistry interceptorMetadataRegistry)
+   {
+      this.interceptorMetadataRegistry = interceptorMetadataRegistry;
+   }
+
+   public InterceptionHandler createFor(Class<?> clazz)
+   {
+      return new DirectClassInterceptionHandler(clazz, interceptorMetadataRegistry.getInterceptorClassMetadata(clazz));
+   }
 }

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-02-03 22:24:32 UTC (rev 100378)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorMethodHandler.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -6,26 +6,18 @@
 import java.io.ObjectInputStream;
 import java.util.Map;
 import java.util.HashMap;
-import java.util.Set;
-import java.util.HashSet;
 import java.util.List;
 import java.util.ArrayList;
 import java.lang.reflect.Method;
 
-import org.jboss.interceptor.model.InterceptorClassMetadata;
+import org.jboss.interceptor.model.InterceptorMetadata;
 import org.jboss.interceptor.model.InterceptionModel;
-import org.jboss.interceptor.model.InterceptorClassMetadataImpl;
-import org.jboss.interceptor.model.MethodHolder;
 import org.jboss.interceptor.model.InterceptionType;
 import org.jboss.interceptor.model.InterceptionTypeRegistry;
-import org.jboss.interceptor.registry.InterceptorClassMetadataRegistry;
 import org.jboss.interceptor.util.ReflectionUtils;
 import org.jboss.interceptor.util.InterceptionUtils;
-import org.jboss.interceptor.util.proxy.TargetInstanceProxy;
 import org.jboss.interceptor.util.proxy.TargetInstanceProxyMethodHandler;
 
-import javassist.util.proxy.MethodHandler;
-
 /**
  * @author Marius Bogoevici
  */
@@ -33,10 +25,10 @@
 {
 
    private Map<Object, InterceptionHandler> interceptorHandlerInstances = new HashMap<Object, InterceptionHandler>();
-   private InterceptorClassMetadata targetClassInterceptorMetadata;
+   private InterceptorMetadata targetClassInterceptorMetadata;
    private List<InterceptionModel<Class<?>, ?>> interceptionModels;
 
-   public InterceptorMethodHandler(Object target, Class<?> targetClass, List<InterceptionModel<Class<?>, ?>> interceptionModels, List<InterceptionHandlerFactory<?>> interceptionHandlerFactories, boolean includeTargetClass)
+   public InterceptorMethodHandler(Object target, Class<?> targetClass, List<InterceptionModel<Class<?>, ?>> interceptionModels, List<InterceptionHandlerFactory<?>> interceptionHandlerFactories, InterceptorMetadata targetClassMetadata)
    {
       super(target, targetClass != null ? targetClass : target.getClass());
       if (interceptionModels == null)
@@ -63,10 +55,7 @@
             interceptorHandlerInstances.put(interceptorReference, ((InterceptionHandlerFactory) interceptionHandlerFactories.get(i)).createFor((Object) interceptorReference));
          }
       }
-      if (includeTargetClass)
-      {
-         targetClassInterceptorMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(getTargetClass(), true);
-      }
+      targetClassInterceptorMetadata = targetClassMetadata;
    }
 
    public Object doInvoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreator.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreator.java	2010-02-03 22:24:32 UTC (rev 100378)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreator.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -18,18 +18,14 @@
 package org.jboss.interceptor.proxy;
 
 import javassist.util.proxy.MethodHandler;
+import org.jboss.interceptor.model.InterceptorMetadata;
 
 /**
  * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
  */
 public interface InterceptorProxyCreator {
-    <T> T createProxyFromInstance(Object target, Class<T> proxyClass, Class<?>[] constructorTypes, Object[] constructorArguments) ;
 
-    //<T> T createInstrumentedInstance(Class<T> proxyClass, Class<?>[] constructorTypes, Object[] constructorArguments) ;
-
-    <T> T createProxyFromInstance(Object target, Class<T> proxyClass) throws IllegalAccessException, InstantiationException;
-
    <T> T createProxyInstance(Class<T> proxyClass, MethodHandler interceptorMethodHandler);
 
-   <T> MethodHandler getMethodHandler(Object target, Class<T> proxyClass);
+   <T> MethodHandler createMethodHandler(Object target, Class<T> proxyClass, InterceptorMetadata interceptorMetadata);
 }

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-02-03 22:24:32 UTC (rev 100378)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreatorImpl.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -20,17 +20,13 @@
 import javassist.util.proxy.MethodHandler;
 import javassist.util.proxy.ProxyFactory;
 import javassist.util.proxy.ProxyObject;
-import org.jboss.interceptor.model.InterceptionType;
-import org.jboss.interceptor.model.InterceptorClassMetadata;
 import org.jboss.interceptor.model.InterceptionModel;
+import org.jboss.interceptor.model.InterceptorMetadata;
 import org.jboss.interceptor.registry.InterceptorRegistry;
-import org.jboss.interceptor.registry.InterceptorClassMetadataRegistry;
 import org.jboss.interceptor.InterceptorException;
 import org.jboss.interceptor.util.InterceptionUtils;
 import org.jboss.interceptor.util.proxy.TargetInstanceProxy;
 
-import javax.interceptor.AroundInvoke;
-import java.lang.reflect.Method;
 import java.lang.reflect.Constructor;
 import java.util.*;
 
@@ -59,10 +55,10 @@
    }
 
 
-   public <T> T createProxyFromInstance(final Object target, Class<T> proxifiedClass, Class<?>[] constructorTypes, Object[] constructorArguments)
+   public <T> T createProxyFromInstance(final Object target, Class<T> proxifiedClass, Class<?>[] constructorTypes, Object[] constructorArguments, InterceptorMetadata interceptorClassMetadata)
    {
-      MethodHandler interceptorMethodHandler = getMethodHandler(target, proxifiedClass);
-      return createProxyInstance(createProxyClassWithHandler(proxifiedClass, interceptorMethodHandler), interceptorMethodHandler);
+      MethodHandler interceptorMethodHandler = createMethodHandler(target, proxifiedClass, interceptorClassMetadata);
+      return createProxyInstance(InterceptionUtils.createProxyClassWithHandler(proxifiedClass, interceptorMethodHandler), interceptorMethodHandler);
    }
 
    public <T> T createProxyInstance(Class<T> proxyClass, MethodHandler interceptorMethodHandler)
@@ -84,42 +80,11 @@
       }
    }
 
-   public static <T> Class<T> createProxyClass(Class<T> proxyClass)
+   public <T> MethodHandler createMethodHandler(Object target, Class<T> proxyClass, InterceptorMetadata interceptorMetadata)
    {
-      ProxyFactory proxyFactory = new ProxyFactory();
-      if (proxyClass != null)
-      {
-         proxyFactory.setSuperclass(proxyClass);
-      }
-      proxyFactory.setInterfaces(new Class<?>[]{LifecycleMixin.class, TargetInstanceProxy.class});
-      Class<T> clazz = proxyFactory.createClass();
-      return clazz;
+      return new InterceptorMethodHandler(target, proxyClass, getModelsFor(proxyClass), interceptionHandlerFactories, interceptorMetadata);
    }
 
-   public static <T> Class<T> createProxyClassWithHandler(Class<T> proxyClass, MethodHandler methodHandler)
-   {
-      ProxyFactory proxyFactory = new ProxyFactory();
-      if (proxyClass != null)
-      {
-         proxyFactory.setSuperclass(proxyClass);
-      }
-      proxyFactory.setInterfaces(new Class<?>[]{LifecycleMixin.class, TargetInstanceProxy.class});
-      proxyFactory.setHandler(methodHandler);
-      Class<T> clazz = proxyFactory.createClass();
-      return clazz;
-   }
-
-
-   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 this.getMethodHandler(target, proxyClass, true);
-   }
-
    private <T> List<InterceptionModel<Class<?>, ?>> getModelsFor(Class<T> proxyClass)
    {
       List<InterceptionModel<Class<?>, ?>> interceptionModels = new ArrayList<InterceptionModel<Class<?>, ?>>();
@@ -130,9 +95,9 @@
       return interceptionModels;
    }
 
-   public <T> T createProxyFromInstance(final Object target, Class<T> proxyClass) throws IllegalAccessException, InstantiationException
+   public <T> T createProxyFromInstance(final Object target, Class<T> proxyClass, InterceptorMetadata targetClassMetadata) throws IllegalAccessException, InstantiationException
    {
-      return createProxyFromInstance(target, proxyClass, new Class[0], new Object[0]);
+      return createProxyFromInstance(target, proxyClass, new Class[0], new Object[0], targetClassMetadata);
    }
 
 }

Added: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/registry/ClassMetadataReader.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/registry/ClassMetadataReader.java	                        (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/registry/ClassMetadataReader.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.interceptor.registry;
+
+import org.jboss.interceptor.model.InterceptorMetadata;
+
+/**
+ * @author Marius Bogoevici
+ */
+public interface ClassMetadataReader
+{
+   InterceptorMetadata getInterceptorMetadata(Class<?> clazz, boolean isTargetClass);
+}

Deleted: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/registry/InterceptorClassMetadataRegistry.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/registry/InterceptorClassMetadataRegistry.java	2010-02-03 22:24:32 UTC (rev 100378)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/registry/InterceptorClassMetadataRegistry.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -1,126 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
- * contributors by the @authors tag. See the copyright.txt in the
- * distribution for a full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.interceptor.registry;
-
-import org.jboss.interceptor.model.InterceptorClassMetadataImpl;
-import org.jboss.interceptor.model.InterceptorClassMetadata;
-
-import java.util.Map;
-import java.util.WeakHashMap;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-/**
- * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
- */
-public class InterceptorClassMetadataRegistry
-{
-   private static InterceptorClassMetadataRegistry interceptorMetadataRegistry;
-
-   private final Map<Key, InterceptorClassMetadata> interceptorClassMetadataMap = new ConcurrentHashMap<Key, InterceptorClassMetadata>();
-
-   private final Lock lock = new ReentrantLock();
-
-   static
-   {
-      interceptorMetadataRegistry = new InterceptorClassMetadataRegistry();
-   }
-
-   public static InterceptorClassMetadataRegistry getRegistry()
-   {
-      return interceptorMetadataRegistry;
-   }
-
-   public InterceptorClassMetadata getInterceptorClassMetadata(Class<?> interceptorClass)
-   {
-      return this.getInterceptorClassMetadata(interceptorClass, false);
-   }
-
-   public InterceptorClassMetadata getInterceptorClassMetadata(Class<?> interceptorClass, boolean isInterceptorTargetClass)
-   {
-      Key key = new Key(interceptorClass, isInterceptorTargetClass);
-      if (!interceptorClassMetadataMap.containsKey(key))
-      {
-         try
-         {
-            lock.lock();
-            //verify that metadata hasn't been added while waiting for the lock            
-            if (!interceptorClassMetadataMap.containsKey(key))
-            {
-               interceptorClassMetadataMap.put(key, new InterceptorClassMetadataImpl(interceptorClass, isInterceptorTargetClass));
-            }
-         }
-         finally 
-         {
-            lock.unlock();
-         }
-      }
-
-      return interceptorClassMetadataMap.get(key);
-
-   }
-
-   private static class Key
-   {
-      private Class<?> clazz;
-
-      private boolean isInterceptorTargetClass;
-
-      private Key(Class<?> clazz, boolean interceptorTargetClass)
-      {
-         this.clazz = clazz;
-         isInterceptorTargetClass = interceptorTargetClass;
-      }
-
-      @Override
-      public boolean equals(Object o)
-      {
-         if (this == o)
-         {
-            return true;
-         }
-         if (o == null || getClass() != o.getClass())
-         {
-            return false;
-         }
-
-         Key key = (Key) o;
-
-         if (isInterceptorTargetClass != key.isInterceptorTargetClass)
-         {
-            return false;
-         }
-         if (clazz != null ? !clazz.equals(key.clazz) : key.clazz != null)
-         {
-            return false;
-         }
-
-         return true;
-      }
-
-      @Override
-      public int hashCode()
-      {
-         int result = clazz != null ? clazz.hashCode() : 0;
-         result = 31 * result + (isInterceptorTargetClass ? 1 : 0);
-         return result;
-      }
-   }
-
-}

Copied: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/registry/InterceptorMetadataRegistry.java (from rev 100310, projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/registry/InterceptorClassMetadataRegistry.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/registry/InterceptorMetadataRegistry.java	                        (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/registry/InterceptorMetadataRegistry.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.interceptor.registry;
+
+import org.jboss.interceptor.model.metadata.AbstractInterceptorMetadata;
+import org.jboss.interceptor.model.InterceptorMetadata;
+import org.jboss.interceptor.model.metadata.ClassReference;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class InterceptorMetadataRegistry
+{
+   private final Map<Key, InterceptorMetadata> interceptorClassMetadataMap = new ConcurrentHashMap<Key, InterceptorMetadata>();
+
+   private ClassMetadataReader classMetadataReader;
+
+   private final Lock lock = new ReentrantLock();
+
+   public InterceptorMetadataRegistry(ClassMetadataReader classMetadataReader)
+   {
+      this.classMetadataReader = classMetadataReader;
+   }
+
+   public InterceptorMetadata getInterceptorClassMetadata(Class<?> interceptorClass)
+   {
+      return this.getInterceptorClassMetadata(interceptorClass, false);
+   }
+
+   public InterceptorMetadata getInterceptorClassMetadata(Class<?> interceptorClass, boolean isInterceptorTargetClass)
+   {
+      Key key = new Key(interceptorClass, isInterceptorTargetClass);
+      if (!interceptorClassMetadataMap.containsKey(key))
+      {
+         try
+         {
+            lock.lock();
+            //verify that metadata hasn't been added while waiting for the lock
+            if (!interceptorClassMetadataMap.containsKey(key))
+            {
+               interceptorClassMetadataMap.put(key, classMetadataReader.getInterceptorMetadata(interceptorClass, isInterceptorTargetClass));
+            }
+         }
+         finally
+         {
+            lock.unlock();
+         }
+      }
+
+      return interceptorClassMetadataMap.get(key);
+
+   }
+
+   public static final class Key
+   {
+      private String className;
+
+      private boolean isInterceptorTargetClass;
+
+      private Key(Class<?> clazz, boolean interceptorTargetClass)
+      {
+         this.className = clazz.getName();
+         isInterceptorTargetClass = interceptorTargetClass;
+      }
+
+      @Override
+      public boolean equals(Object o)
+      {
+         if (this == o)
+         {
+            return true;
+         }
+         if (o == null || getClass() != o.getClass())
+         {
+            return false;
+         }
+
+         Key key = (Key) o;
+
+         if (isInterceptorTargetClass != key.isInterceptorTargetClass)
+         {
+            return false;
+         }
+         if (className != null ? !className.equals(key.className) : key.className != null)
+         {
+            return false;
+         }
+
+         return true;
+      }
+
+      @Override
+      public int hashCode()
+      {
+         int result = className != null ? className.hashCode() : 0;
+         result = 31 * result + (isInterceptorTargetClass ? 1 : 0);
+         return result;
+      }
+   }
+
+}

Added: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/registry/SimpleClassMetadataReader.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/registry/SimpleClassMetadataReader.java	                        (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/registry/SimpleClassMetadataReader.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.interceptor.registry;
+
+import org.jboss.interceptor.InterceptorException;
+import org.jboss.interceptor.model.InterceptorMetadata;
+import org.jboss.interceptor.model.metadata.AbstractInterceptorMetadata;
+import org.jboss.interceptor.model.metadata.AbstractInterceptorMetadataSerializationProxy;
+import org.jboss.interceptor.model.metadata.ReflectiveClassReference;
+import org.jboss.interceptor.util.ReflectionUtils;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class SimpleClassMetadataReader implements ClassMetadataReader
+{
+   private static SimpleClassMetadataReader instance = new SimpleClassMetadataReader();
+
+   public InterceptorMetadata getInterceptorMetadata(Class<?> clazz, final boolean isInterceptorTargetClass)
+   {
+      return new AbstractInterceptorMetadata(ReflectiveClassReference.of(clazz), isInterceptorTargetClass)
+      {
+         @Override
+         protected Object createSerializableProxy()
+         {
+            return new SimpleInterceptorMetadataSerializationProxy(getInterceptorClass().getClassName(), isTargetClass());
+         }
+
+         private Object writeReplace()
+         {
+            return createSerializableProxy();
+         }
+
+      };
+   }
+
+   public static ClassMetadataReader getInstance()
+   {
+      return instance;
+   }
+
+   private static class SimpleInterceptorMetadataSerializationProxy extends AbstractInterceptorMetadataSerializationProxy
+   {
+      public SimpleInterceptorMetadataSerializationProxy(String className, boolean targetClass)
+      {
+         super(className, targetClass);
+      }
+
+      @Override
+      protected InterceptorMetadata loadInterceptorMetadata() throws ClassNotFoundException
+      {
+         Class<?> clazz = ReflectionUtils.classForName(getClassName());
+         return SimpleClassMetadataReader.instance.getInterceptorMetadata(clazz, isInterceptionTargetClass());
+      }
+
+      private Object readResolve()
+      {
+         try
+         {
+            return loadInterceptorMetadata();
+         }
+         catch (ClassNotFoundException e)
+         {
+            throw new InterceptorException("Failed to deserialize the interceptor class metadata", e);
+         }
+      }
+
+   }
+}

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-02-03 22:24:32 UTC (rev 100378)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -17,8 +17,11 @@
 
 package org.jboss.interceptor.util;
 
+import javassist.util.proxy.MethodHandler;
+import javassist.util.proxy.ProxyFactory;
 import org.jboss.interceptor.model.InterceptionType;
 import org.jboss.interceptor.model.InterceptionTypeRegistry;
+import org.jboss.interceptor.model.metadata.MethodReference;
 import org.jboss.interceptor.proxy.InterceptionHandlerFactory;
 import org.jboss.interceptor.proxy.InterceptorProxyCreatorImpl;
 import org.jboss.interceptor.proxy.LifecycleMixin;
@@ -142,7 +145,7 @@
     * @param forTargetClass
     * @return
     */
-   public static boolean isInterceptorMethod(InterceptionType interceptionType, Method method, boolean forTargetClass)
+   public static boolean isInterceptorMethod(InterceptionType interceptionType, MethodReference method, boolean forTargetClass)
    {
 
       if (method.getAnnotation(InterceptionTypeRegistry.getAnnotationClass(interceptionType)) == null)
@@ -152,22 +155,22 @@
 
       if (interceptionType.isLifecycleCallback())
       {
-         if (!Void.TYPE.equals(method.getReturnType()))
+         if (!Void.TYPE.equals(method.getReturnType().getJavaClass()))
          {
             if (LOG.isDebugEnabled())
             {
-             LOG.debug(getStandardIgnoredMessage(interceptionType, method) + "does not have a void return type");
+             LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not have a void return type");
             }
             return false;
          }
 
-         Class<?>[] parameterTypes = method.getParameterTypes();
+         Class<?>[] parameterTypes = method.getJavaMethod().getParameterTypes();
 
          if (forTargetClass && parameterTypes.length != 0)
          {
             if (LOG.isDebugEnabled())
             {
-               LOG.debug(getStandardIgnoredMessage(interceptionType, method) + "is defined on the target class and does not have 0 arguments");
+               LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "is defined on the target class and does not have 0 arguments");
             }
             return false;
          }
@@ -176,7 +179,7 @@
          {
             if (LOG.isDebugEnabled())
             {
-               LOG.debug(getStandardIgnoredMessage(interceptionType, method) + "does not have exactly one parameter");
+               LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not have exactly one parameter");
             }
             return false;
          }
@@ -185,7 +188,7 @@
          {
             if (LOG.isDebugEnabled())
             {
-               LOG.debug(getStandardIgnoredMessage(interceptionType, method) + "its single argument is not a " + InvocationContext.class.getName());
+               LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "its single argument is not a " + InvocationContext.class.getName());
             }
             return false;
          }
@@ -194,22 +197,22 @@
       }
       else
       {
-         if (!Object.class.equals(method.getReturnType()))
+         if (!Object.class.equals(method.getReturnType().getJavaClass()))
          {
             if (LOG.isDebugEnabled())
             {
-               LOG.debug(getStandardIgnoredMessage(interceptionType, method) + "does not return a " + Object.class.getName());
+               LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not return a " + Object.class.getName());
             }
             return false;
          }
 
-         Class<?>[] parameterTypes = method.getParameterTypes();
+         Class<?>[] parameterTypes = method.getJavaMethod().getParameterTypes();
 
          if (parameterTypes.length != 1)
          {
             if (LOG.isDebugEnabled())
             {
-               LOG.debug(getStandardIgnoredMessage(interceptionType, method) + "does not have exactly 1 parameter");
+               LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not have exactly 1 parameter");
             }
             return false;
          }
@@ -218,7 +221,7 @@
          {
             if (LOG.isDebugEnabled())
             {
-               LOG.debug(getStandardIgnoredMessage(interceptionType, method) + "does not have a " + InvocationContext.class.getName() + " parameter ");
+               LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not have a " + InvocationContext.class.getName() + " parameter ");
             }
             return false;
          }
@@ -234,32 +237,6 @@
             + interceptionType.annotationClassName() + ", but ";
    }
 
-   public static <T> T proxifyInstance(T instance, Class<?> superClass, List<InterceptorRegistry<Class<?>, ?>> interceptorRegistries, List<InterceptionHandlerFactory<?>> interceptionHandlerFactory)
-   {
-      try
-      {
-        InterceptorProxyCreatorImpl proxyCreator = new InterceptorProxyCreatorImpl(interceptorRegistries, interceptionHandlerFactory);
-         return (T) proxyCreator.createProxyFromInstance(instance, superClass);
-      }
-      catch (Exception e)
-      {
-         throw new InterceptorException(e);
-      }
-   }
-
-    public static <T> T proxifyInstance(T instance, Class<?> superClass, InterceptorRegistry<Class<?>, ?> interceptorRegistry, InterceptionHandlerFactory<?> interceptionHandlerFactory)
-   {
-      try
-      {
-        InterceptorProxyCreatorImpl proxyCreator = new InterceptorProxyCreatorImpl(Collections.<InterceptorRegistry<Class<?>, ?>>singletonList(interceptorRegistry), Collections.<InterceptionHandlerFactory<?>>singletonList(interceptionHandlerFactory));
-         return (T) proxyCreator.createProxyFromInstance(instance, superClass);
-      }
-      catch (Exception e)
-      {
-         throw new InterceptorException(e);
-      }
-   }
-
    public static boolean supportsEjb3InterceptorDeclaration()
    {
       return INTERCEPTORS_ANNOTATION_CLASS != null && EXCLUDE_CLASS_INTERCEPTORS_ANNOTATION_CLASS != null;
@@ -285,4 +262,29 @@
       return proxy;
    }
 
+
+   public static <T> Class<T> createProxyClass(Class<T> proxyClass)
+   {
+      ProxyFactory proxyFactory = new ProxyFactory();
+      if (proxyClass != null)
+      {
+         proxyFactory.setSuperclass(proxyClass);
+      }
+      proxyFactory.setInterfaces(new Class<?>[]{LifecycleMixin.class, TargetInstanceProxy.class});
+      Class<T> clazz = proxyFactory.createClass();
+      return clazz;
+   }
+
+   public static <T> Class<T> createProxyClassWithHandler(Class<T> proxyClass, MethodHandler methodHandler)
+   {
+      ProxyFactory proxyFactory = new ProxyFactory();
+      if (proxyClass != null)
+      {
+         proxyFactory.setSuperclass(proxyClass);
+      }
+      proxyFactory.setInterfaces(new Class<?>[]{LifecycleMixin.class, TargetInstanceProxy.class});
+      proxyFactory.setHandler(methodHandler);
+      Class<T> clazz = proxyFactory.createClass();
+      return clazz;
+   }
 }

Modified: projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/metadata/InterceptorClassMetadataTestCase.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/metadata/InterceptorClassMetadataTestCase.java	2010-02-03 22:24:32 UTC (rev 100378)
+++ projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/metadata/InterceptorClassMetadataTestCase.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -17,13 +17,17 @@
 
 package org.jboss.interceptors.metadata;
 
+import org.jboss.interceptor.model.InterceptorMetadata;
+import org.jboss.interceptor.model.metadata.MethodReference;
+import org.jboss.interceptor.model.metadata.ReflectiveClassReference;
+import org.jboss.interceptor.registry.SimpleClassMetadataReader;
+import org.junit.Before;
 import org.junit.Test;
 import static org.junit.Assert.assertEquals;
-import org.jboss.interceptor.model.InterceptorClassMetadata;
+
 import org.jboss.interceptor.model.InterceptionType;
 import org.jboss.interceptor.model.InterceptorMetadataException;
-import org.jboss.interceptor.registry.InterceptorClassMetadataRegistry;
-import org.jboss.interceptor.InterceptorException;
+import org.jboss.interceptor.registry.InterceptorMetadataRegistry;
 
 import java.lang.reflect.Method;
 import java.util.List;
@@ -34,56 +38,62 @@
 public class InterceptorClassMetadataTestCase
 {
 
+   InterceptorMetadataRegistry interceptorMetadataRegistry;
+
+   @Before
+   public void setUp()
+   {
+      interceptorMetadataRegistry = new InterceptorMetadataRegistry(SimpleClassMetadataReader.getInstance());
+   }
+
    @Test
    public void testInterceptorWithAllMethods()
    {
-      InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(InterceptorWithAllMethods.class);
+      InterceptorMetadata interceptorClassMetadata = interceptorMetadataRegistry.getInterceptorClassMetadata(InterceptorWithAllMethods.class);
 
-      List<Method> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
+      List<MethodReference> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
       assertEquals(true, postConstructMethods.size() == 1);
-      assertEquals(postConstructMethods.get(0).getName(), "doPostConstruct");
+      assertEquals(postConstructMethods.get(0).getJavaMethod().getName(), "doPostConstruct");
 
-      List<Method> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
+      List<MethodReference> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
       assertEquals(true, preDestroyMethods.size() == 1);
-      assertEquals(preDestroyMethods.get(0).getName(), "doPreDestroy");
+      assertEquals(preDestroyMethods.get(0).getJavaMethod().getName(), "doPreDestroy");
 
-      List<Method> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
+      List<MethodReference> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
       assertEquals(true, aroundInvokeMethods.size() == 1);
-      assertEquals(aroundInvokeMethods.get(0).getName(), "doAroundInvoke");
+      assertEquals(aroundInvokeMethods.get(0).getJavaMethod().getName(), "doAroundInvoke");
 
-      List<Method> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
+      List<MethodReference> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
       assertEquals(true, postActivateMethods.size() == 1);
-      assertEquals(postActivateMethods.get(0).getName(), "doPostActivate");
+      assertEquals(postActivateMethods.get(0).getJavaMethod().getName(), "doPostActivate");
 
-
-      List<Method> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
+      List<MethodReference> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
       assertEquals(true, prePassivateMethods.size() == 1);
-      assertEquals(prePassivateMethods.get(0).getName(), "doPrePassivate");
+      assertEquals(prePassivateMethods.get(0).getJavaMethod().getName(), "doPrePassivate");
 
    }
 
    @Test
    public void testInterceptorWithSomeMethods()
    {
-      InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(InterceptorWithSomeMethods.class);
+      InterceptorMetadata interceptorClassMetadata = interceptorMetadataRegistry.getInterceptorClassMetadata(InterceptorWithSomeMethods.class);
 
-      List<Method> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
+      List<MethodReference> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
       assertEquals(true, postConstructMethods.size() == 0);
 
-      List<Method> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
+      List<MethodReference> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
       assertEquals(true, preDestroyMethods.size() == 1);
-      assertEquals(preDestroyMethods.get(0).getName(), "doPreDestroy");
+      assertEquals(preDestroyMethods.get(0).getJavaMethod().getName(), "doPreDestroy");
 
-      List<Method> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
+      List<MethodReference> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
       assertEquals(true, aroundInvokeMethods.size() == 1);
-      assertEquals(aroundInvokeMethods.get(0).getName(), "doAroundInvoke");
+      assertEquals(aroundInvokeMethods.get(0).getJavaMethod().getName(), "doAroundInvoke");
 
-      List<Method> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
+      List<MethodReference> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
       assertEquals(true, postActivateMethods.size() == 1);
-      assertEquals(postActivateMethods.get(0).getName(), "doPostActivate");
+      assertEquals(postActivateMethods.get(0).getJavaMethod().getName(), "doPostActivate");
 
-
-      List<Method> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
+      List<MethodReference> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
       assertEquals(true, prePassivateMethods.size() == 0);
 
    }
@@ -91,23 +101,23 @@
    @Test
    public void testSimpleInheritance()
    {
-      InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(SimpleInheritanceChildInterceptor.class);
+      InterceptorMetadata interceptorClassMetadata = interceptorMetadataRegistry.getInterceptorClassMetadata(SimpleInheritanceChildInterceptor.class);
 
-      List<Method> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
+      List<MethodReference> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
       assertEquals(1, postConstructMethods.size());
-      assertEquals(postConstructMethods.get(0).getName(), "doPostConstruct");
+      assertEquals(postConstructMethods.get(0).getJavaMethod().getName(), "doPostConstruct");
 
-      List<Method> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
+      List<MethodReference> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
       assertEquals(true, preDestroyMethods.size() == 0);
 
-      List<Method> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
+      List<MethodReference> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
       assertEquals(true, aroundInvokeMethods.size() == 1);
-      assertEquals(aroundInvokeMethods.get(0).getName(), "doAroundInvoke");
+      assertEquals(aroundInvokeMethods.get(0).getJavaMethod().getName(), "doAroundInvoke");
 
-      List<Method> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
+      List<MethodReference> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
       assertEquals(true, postActivateMethods.size() == 0);
 
-      List<Method> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
+      List<MethodReference> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
       assertEquals(true, prePassivateMethods.size() == 0);
 
    }
@@ -115,25 +125,25 @@
    @Test
    public void testInheritanceWithAndWithoutOverriding()
    {
-      InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(OverrideChildInterceptor.class);
+      InterceptorMetadata interceptorClassMetadata = interceptorMetadataRegistry.getInterceptorClassMetadata(OverrideChildInterceptor.class);
 
-      List<Method> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
+      List<MethodReference> postConstructMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_CONSTRUCT);
       assertEquals(true, postConstructMethods.size() == 1);
-      assertEquals(postConstructMethods.get(0).getName(), "methodOverriddenAndUsedAsInterceptor");
+      assertEquals(postConstructMethods.get(0).getJavaMethod().getName(), "methodOverriddenAndUsedAsInterceptor");
 
-      List<Method> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
+      List<MethodReference> preDestroyMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_DESTROY);
       assertEquals(true, preDestroyMethods.size() == 0);
 
-      List<Method> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
+      List<MethodReference> aroundInvokeMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.AROUND_INVOKE);
       assertEquals(true, aroundInvokeMethods.size() == 2);
-      assertEquals(aroundInvokeMethods.get(0).getName(), "methodDefinedOnParentAndUsedAsInterceptor");
-      assertEquals(aroundInvokeMethods.get(1).getName(), "methodDefinedOnChildAndUsedAsInterceptor");
+      assertEquals(aroundInvokeMethods.get(0).getJavaMethod().getName(), "methodDefinedOnParentAndUsedAsInterceptor");
+      assertEquals(aroundInvokeMethods.get(1).getJavaMethod().getName(), "methodDefinedOnChildAndUsedAsInterceptor");
 
-      List<Method> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
+      List<MethodReference> postActivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.POST_ACTIVATE);
       assertEquals(true, postActivateMethods.size() == 0);
 
 
-      List<Method> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
+      List<MethodReference> prePassivateMethods = interceptorClassMetadata.getInterceptorMethods(InterceptionType.PRE_PASSIVATE);
       assertEquals(true, prePassivateMethods.size() == 0);
 
    }
@@ -141,7 +151,7 @@
    @Test(expected = InterceptorMetadataException.class)
    public void testDuplicateAnnotations()
    {
-      InterceptorClassMetadata interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(InterceptorWithDuplicateAnnotations.class);
+      InterceptorMetadata interceptorClassMetadata = interceptorMetadataRegistry.getInterceptorClassMetadata(InterceptorWithDuplicateAnnotations.class);
 
    }
 

Modified: projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTestCase.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTestCase.java	2010-02-03 22:24:32 UTC (rev 100378)
+++ projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTestCase.java	2010-02-03 23:58:45 UTC (rev 100379)
@@ -17,19 +17,24 @@
 
 package org.jboss.interceptors.proxy;
 
+import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ByteArrayInputStream;
-import java.lang.reflect.Array;
 
+import javassist.util.proxy.MethodHandler;
+import org.jboss.interceptor.model.InterceptionModel;
 import org.jboss.interceptor.model.InterceptionModelBuilder;
-import org.jboss.interceptor.model.InterceptionModel;
+import org.jboss.interceptor.model.metadata.ReflectiveClassReference;
 import org.jboss.interceptor.proxy.DirectClassInterceptionHandlerFactory;
+import org.jboss.interceptor.proxy.InterceptorProxyCreator;
+import org.jboss.interceptor.proxy.InterceptorProxyCreatorImpl;
+import org.jboss.interceptor.registry.InterceptorMetadataRegistry;
 import org.jboss.interceptor.registry.InterceptorRegistry;
+import org.jboss.interceptor.registry.SimpleClassMetadataReader;
 import org.jboss.interceptor.util.InterceptionUtils;
-
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
 
 /**
@@ -84,11 +89,19 @@
          "org.jboss.interceptors.proxy.FootballTeam_getName",
    };
 
+   private InterceptorRegistry<Class<?>, Class<?>> interceptorRegistry;
 
+   private DirectClassInterceptionHandlerFactory interceptionHandlerFactory;
 
-   private InterceptionModel<Class<?>, Class<?>> interceptionModel;
-   private InterceptorRegistry<Class<?>, Class<?>> interceptorRegistry;
+   private InterceptorMetadataRegistry interceptorMetadataRegistry;
 
+   @Before
+   public void setUp()
+   {
+      interceptorMetadataRegistry = new InterceptorMetadataRegistry(SimpleClassMetadataReader.getInstance());
+      interceptionHandlerFactory = new DirectClassInterceptionHandlerFactory(interceptorMetadataRegistry);
+   }
+
    public void resetLogAndSetupClassesForMethod() throws Exception
    {
       InterceptorTestLogger.reset();
@@ -96,6 +109,7 @@
       builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(FirstInterceptor.class, SecondInterceptor.class);
       builder.interceptPostConstruct().with(FirstInterceptor.class);
       builder.interceptPreDestroy().with(SecondInterceptor.class);
+      InterceptionModel<Class<?>, Class<?>> interceptionModel;      
       interceptionModel = builder.build();
       this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
       this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
@@ -109,6 +123,7 @@
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
 
       builder.interceptAll().with(FirstInterceptor.class, SecondInterceptor.class);
+      InterceptionModel<Class<?>, Class<?>> interceptionModel;      
       interceptionModel = builder.build();
       this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
       this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
@@ -123,6 +138,7 @@
       builder.interceptAll().with(FirstInterceptor.class);
       builder.interceptPreDestroy().with(SecondInterceptor.class);
       builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(SecondInterceptor.class);
+      InterceptionModel<Class<?>, Class<?>> interceptionModel;      
       interceptionModel = builder.build();
       this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
       this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
@@ -138,6 +154,7 @@
       builder.interceptPreDestroy().with(SecondInterceptor.class);
       builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(SecondInterceptor.class);
       builder.ignoreGlobalInterceptors(FootballTeam.class.getMethod("getName"));
+      InterceptionModel<Class<?>, Class<?>> interceptionModel;      
       interceptionModel = builder.build();
       this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
       this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
@@ -149,7 +166,7 @@
    public void testInterceptionWithMethodRegisteredInterceptors() throws Exception
    {
       resetLogAndSetupClassesForMethod();
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
       InterceptionUtils.executePostConstruct(proxy);
       Assert.assertEquals(TEAM_NAME, proxy.getName());
       InterceptionUtils.executePredestroy(proxy);
@@ -162,7 +179,7 @@
    public void testInterceptionWithGlobalInterceptors() throws Exception
    {
       resetLogAndSetupClassesGlobally();
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
       InterceptionUtils.executePostConstruct(proxy);
       Assert.assertEquals(TEAM_NAME, proxy.getName());
       InterceptionUtils.executePredestroy(proxy);
@@ -173,7 +190,7 @@
    public void testInterceptionWithMixedInterceptors() throws Exception
    {
       resetLogAndSetupClassesMixed();
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
       InterceptionUtils.executePostConstruct(proxy);
       Assert.assertEquals(TEAM_NAME, proxy.getName());
       InterceptionUtils.executePredestroy(proxy);
@@ -186,7 +203,7 @@
    public void testInterceptionWithGlobalsIgnored() throws Exception
    {
       resetLogAndSetupClassesWithGlobalsIgnored();
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
       InterceptionUtils.executePostConstruct(proxy);
       Assert.assertEquals(TEAM_NAME, proxy.getName());
       InterceptionUtils.executePredestroy(proxy);
@@ -200,7 +217,7 @@
    public void testInterceptionWithSerializedProxy() throws Exception
    {
       resetLogAndSetupClassesForMethod();
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
       InterceptionUtils.executePostConstruct(proxy);
       ByteArrayOutputStream baos = new ByteArrayOutputStream();
       new ObjectOutputStream(baos).writeObject(proxy);
@@ -220,11 +237,11 @@
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
 
       builder.interceptAroundInvoke(FootballTeam.class.getMethod("echo", String.class)).with(ParameterOverridingInterceptor.class);
-      interceptionModel = builder.build();
+      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
       this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
       this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
 
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
       Assert.assertEquals(42, proxy.echo("1"));
    }
 
@@ -236,11 +253,11 @@
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
 
       builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoInt", int.class)).with(ParameterOverridingInterceptorWithInteger.class);
-      interceptionModel = builder.build();
+      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
       this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
       this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
 
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
       Assert.assertEquals(42, proxy.echoInt(1));
    }
 
@@ -252,11 +269,11 @@
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
 
       builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLongAsObject", Long.class)).with(ParameterOverridingInterceptorWithInteger.class);
-      interceptionModel = builder.build();
+      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
       this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
       this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
 
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
       Assert.assertEquals(new Long(42), proxy.echoLongAsObject(1l));
    }
 
@@ -268,11 +285,11 @@
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
 
       builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLongAsObject", Long.class)).with(ParameterOverridingInterceptorWithLong.class);
-      interceptionModel = builder.build();
+      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
       this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
       this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
 
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
       Assert.assertEquals(new Long(42), proxy.echoLongAsObject(1l));
    }
 
@@ -284,11 +301,11 @@
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
 
       builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLong", long.class)).with(ParameterOverridingInterceptorWithInteger.class);
-      interceptionModel = builder.build();
+      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
       this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
       this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
 
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
       Assert.assertEquals(42, proxy.echoLong(1));
    }
 
@@ -300,11 +317,11 @@
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
 
       builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoInt", int.class)).with(ParameterOverridingInterceptorWithLong.class);
-      interceptionModel = builder.build();
+      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
       this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
       this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
 
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      FootballTeam proxy =proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
       Assert.assertEquals(42, proxy.echoInt(1));
    }
 
@@ -316,11 +333,11 @@
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
 
       builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoObjectArray", Object[].class)).with(ParameterOverridingInterceptorWithLongArray.class);
-      interceptionModel = builder.build();
+      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
       this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
       this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
 
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
       Assert.assertEquals(new Long[]{42l}, proxy.echoObjectArray(new Object[]{}));
    }
 
@@ -332,11 +349,11 @@
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
 
       builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoStringArray", String[].class)).with(ParameterOverridingInterceptorWithLongArray.class);
-      interceptionModel = builder.build();
+      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
       this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
       this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
 
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
       Assert.assertEquals(new Long[]{42l}, proxy.echoStringArray(new String[]{}));
    }
 
@@ -349,11 +366,11 @@
       InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
 
       builder.interceptAroundInvoke(FootballTeam.class.getMethod("echo2", ValueBearer.class)).with(ParameterOverridingInterceptor2.class);
-      interceptionModel = builder.build();
+      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
       this.interceptorRegistry = new InterceptorRegistry<Class<?>, Class<?>>();
-      this.interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
-
-      FootballTeam proxy = InterceptionUtils.proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class, interceptorRegistry, new DirectClassInterceptionHandlerFactory());
+      interceptorRegistry.registerInterceptionModel(FootballTeam.class, interceptionModel);
+      
+      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
       Assert.assertEquals(42, proxy.echo2(new ValueBearerImpl(1)));
    }
 
@@ -378,4 +395,10 @@
    }
 
 
+   private <T> T proxifyInstance(T instance, Class<? extends T> targetClass)
+   {
+      InterceptorProxyCreator ipc = new InterceptorProxyCreatorImpl(interceptorRegistry, interceptionHandlerFactory);
+      MethodHandler methodHandler = ipc.createMethodHandler(instance, targetClass, interceptorMetadataRegistry.getInterceptorClassMetadata(targetClass, true));
+      return ipc.createProxyInstance(InterceptionUtils.createProxyClassWithHandler(targetClass, methodHandler), methodHandler);
+   }
 }




More information about the jboss-cvs-commits mailing list