[jboss-cvs] JBossAS SVN: r107123 - in projects/interceptors/trunk: jboss-interceptor/src/main/java/org/jboss/interceptor/reader and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jul 27 15:56:32 EDT 2010


Author: marius.bogoevici
Date: 2010-07-27 15:56:31 -0400 (Tue, 27 Jul 2010)
New Revision: 107123

Added:
   projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/instance/
   projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/instance/InterceptorInstantiator.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptorInstantiator.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorInvocation.java
Removed:
   projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/handler/
   projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/instance/InterceptionHandler.java
   projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/instance/InterceptionHandlerFactory.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
Modified:
   projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/ClassMetadata.java
   projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/InterceptorMetadataReader.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionChain.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/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/proxy/SubclassingInterceptorMethodHandler.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/InterceptorMetadataUtils.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/ReflectiveClassMetadata.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/ReflectiveMethodMetadata.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/SimpleInterceptorMetadata.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/util/InterceptionUtils.java
   projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/proxy/TargetInstanceProxyMethodHandler.java
   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/SubclassingInterceptionTestCase.java
Log:
removed InterceptorHandler, made all proxy creators work with ClassMetadata directly, interceptormodels too

Deleted: 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-07-27 19:06:49 UTC (rev 107122)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/AbstractClassInterceptionHandler.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -1,165 +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.proxy;
-
-import java.io.Serializable;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Queue;
-import java.util.concurrent.ConcurrentLinkedQueue;
-
-import javax.interceptor.InvocationContext;
-
-import org.jboss.interceptor.spi.handler.InterceptionHandler;
-import org.jboss.interceptor.spi.metadata.InterceptorMetadata;
-import org.jboss.interceptor.spi.metadata.MethodMetadata;
-import org.jboss.interceptor.spi.model.InterceptionType;
-import org.jboss.interceptor.util.ReflectionUtils;
-
-/**
- * @author Marius Bogoevici
- */
-public abstract class AbstractClassInterceptionHandler implements InterceptionHandler, Serializable
-{
-   private InterceptorMetadata interceptorMetadata;
-
-   public abstract Object getInterceptorInstance();
-
-   public AbstractClassInterceptionHandler(InterceptorMetadata interceptorMetadata)
-   {
-      this.interceptorMetadata = interceptorMetadata;
-   }
-
-
-   public Object intercept(Object target, InterceptionType interceptionType, InvocationContext invocationContext) throws Exception
-   {
-      List<MethodMetadata> methods = interceptorMetadata.getInterceptorMethods(interceptionType);
-      if (methods != null)
-      {
-         DelegatingInvocationContext delegatingInvocationContext = new DelegatingInvocationContext(invocationContext, getInterceptorInstance(), methods, interceptionType);
-         return delegatingInvocationContext.proceed();
-      }
-      else
-      {
-         throw new InterceptorException(target.toString() + " was requested to perform " + interceptionType.name() + " but no such method is defined on it");
-      }
-   }
-
-   public class DelegatingInvocationContext implements InvocationContext
-   {
-
-      private InvocationContext delegateInvocationContext;
-
-      private Object targetObject;
-      private InterceptionType interceptionType;
-
-      private Queue<MethodMetadata> invocationQueue;
-
-      public DelegatingInvocationContext(InvocationContext delegateInvocationContext, Object targetObject, List<MethodMetadata> methods, InterceptionType interceptionType)
-      {
-         this.delegateInvocationContext = delegateInvocationContext;
-         this.targetObject = targetObject;
-         this.interceptionType = interceptionType;
-         this.invocationQueue = new ConcurrentLinkedQueue<MethodMetadata>(methods);
-      }
-
-      public Map<String, Object> getContextData()
-      {
-         return delegateInvocationContext.getContextData();
-      }
-
-      public Method getMethod()
-      {
-         return delegateInvocationContext.getMethod();
-      }
-
-      public Object[] getParameters()
-      {
-         return delegateInvocationContext.getParameters();
-      }
-
-      public Object getTarget()
-      {
-         return delegateInvocationContext.getTarget();
-      }
-
-      public Object proceed() throws Exception
-      {
-         if (!invocationQueue.isEmpty())
-         {
-            try
-            {
-               if (AbstractClassInterceptionHandler.this.interceptorMetadata.isTargetClass() && interceptionType.isLifecycleCallback())
-               {
-                  Iterator<MethodMetadata> methodIterator = invocationQueue.iterator();
-                  while (methodIterator.hasNext())
-                  {
-                     MethodMetadata interceptorMethod = methodIterator.next();
-                     ReflectionUtils.ensureAccessible(interceptorMethod.getJavaMethod());
-                     // interceptor methods defined on
-                     interceptorMethod.getJavaMethod().invoke(targetObject);
-                  }
-                  return null;
-               }
-               else
-               {
-                  MethodMetadata interceptorMethod = invocationQueue.remove();
-                  ReflectionUtils.ensureAccessible(interceptorMethod.getJavaMethod());
-                  if (interceptorMethod.getJavaMethod().getParameterTypes().length == 0)
-                  {
-                     return interceptorMethod.getJavaMethod().invoke(targetObject);
-                  }
-                  else
-                  {
-                     return interceptorMethod.getJavaMethod().invoke(targetObject, this);
-                  }
-               }
-            }
-            catch (InvocationTargetException e)
-            {
-               if (e.getCause() instanceof Exception)
-               {
-                  throw (Exception) e.getCause();
-               }
-               else
-               {
-                  throw new InterceptorException(e);
-               }
-            }
-         }
-         else
-         {
-            return delegateInvocationContext.proceed();
-         }
-      }
-
-      public void setParameters(Object[] params)
-      {
-         delegateInvocationContext.setParameters(params);
-      }
-
-      public Object getTimer()
-      {
-         return delegateInvocationContext.getTimer();
-      }
-
-   }
-}

Deleted: 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-07-27 19:06:49 UTC (rev 107122)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandler.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -1,60 +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.proxy;
-
-import org.jboss.interceptor.spi.metadata.InterceptorMetadata;
-
-
-/**
- * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
- */
-public class DirectClassInterceptionHandler<I> extends AbstractClassInterceptionHandler
-{
-
-   private final Object interceptorInstance;
-
-   public DirectClassInterceptionHandler(Object interceptorInstance, InterceptorMetadata interceptorMetadata)
-   {
-      super(interceptorMetadata);
-      this.interceptorInstance = interceptorInstance;
-   }
-
-   public DirectClassInterceptionHandler(Class<?> simpleInterceptorClass, InterceptorMetadata interceptorMetadata)
-   {
-      super(interceptorMetadata);
-      if (simpleInterceptorClass == null)
-         throw new IllegalArgumentException("Class must not be null");
-      try
-      {
-         this.interceptorInstance = simpleInterceptorClass.newInstance();
-      }
-      catch (Exception e)
-      {
-         throw new InterceptorException("Cannot create interceptor instance:", e);
-      }
-
-   }
-
-   public Object getInterceptorInstance()
-   {
-      return interceptorInstance;
-   }
-
-
-}
-

Deleted: 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-07-27 19:06:49 UTC (rev 107122)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptionHandlerFactory.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -1,41 +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.proxy;
-
-import org.jboss.interceptor.registry.InterceptorMetadataRegistry;
-import org.jboss.interceptor.reader.ReflectiveClassMetadata;
-import org.jboss.interceptor.spi.handler.InterceptionHandler;
-import org.jboss.interceptor.spi.handler.InterceptionHandlerFactory;
-
-/**
- * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
- */
-public class DirectClassInterceptionHandlerFactory implements InterceptionHandlerFactory<Class<?>>
-{
-   private InterceptorMetadataRegistry interceptorMetadataRegistry;
-
-   public DirectClassInterceptionHandlerFactory(InterceptorMetadataRegistry interceptorMetadataRegistry)
-   {
-      this.interceptorMetadataRegistry = interceptorMetadataRegistry;
-   }
-
-   public InterceptionHandler createFor(Class<?> clazz)
-   {
-      return new DirectClassInterceptionHandler(clazz, interceptorMetadataRegistry.getInterceptorClassMetadata(ReflectiveClassMetadata.of(clazz)));
-   }
-}

Copied: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptorInstantiator.java (from rev 106597, 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/DirectClassInterceptorInstantiator.java	                        (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/DirectClassInterceptorInstantiator.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -0,0 +1,51 @@
+/*
+ * 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.proxy;
+
+import org.jboss.interceptor.registry.InterceptorMetadataRegistry;
+import org.jboss.interceptor.spi.instance.InterceptorInstantiator;
+import org.jboss.interceptor.spi.metadata.ClassMetadata;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class DirectClassInterceptorInstantiator implements InterceptorInstantiator<ClassMetadata<?>, Object>
+{
+   private InterceptorMetadataRegistry interceptorMetadataRegistry;
+
+   public DirectClassInterceptorInstantiator(InterceptorMetadataRegistry interceptorMetadataRegistry)
+   {
+      this.interceptorMetadataRegistry = interceptorMetadataRegistry;
+   }
+
+   public Object createFor(ClassMetadata<?> clazz)
+   {
+      try
+      {
+         return clazz.getJavaClass().newInstance();
+      }
+      catch (InstantiationException e)
+      {
+         throw new InterceptorException(e);
+      }
+      catch (IllegalAccessException e)
+      {
+         throw new InterceptorException(e);
+      }
+   }
+}

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionChain.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionChain.java	2010-07-27 19:06:49 UTC (rev 107122)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptionChain.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -19,11 +19,12 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 
 import javax.interceptor.InvocationContext;
 
-import org.jboss.interceptor.spi.handler.InterceptionHandler;
 import org.jboss.interceptor.spi.model.InterceptionType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -42,55 +43,81 @@
 
    private int currentPosition;
 
-   private List<InterceptionHandler> interceptorHandlers;
-
    private final InterceptionType interceptionType;
 
-   public InterceptionChain(List<InterceptionHandler> interceptorHandlers, InterceptionType interceptionType, Object target, Method targetMethod)
+   private List<InterceptorInvocation.InterceptorMethodInvocation> interceptorMethodInvocations;
+
+   public InterceptionChain(Collection<InterceptorInvocation<?>> interceptorInvocations, InterceptionType interceptionType, Object target, Method targetMethod)
    {
-      this.interceptorHandlers = interceptorHandlers;
       this.interceptionType = interceptionType;
       this.target = target;
       this.targetMethod = targetMethod;
       this.currentPosition = 0;
+      interceptorMethodInvocations = new ArrayList<InterceptorInvocation.InterceptorMethodInvocation>();
+      for (InterceptorInvocation<?> interceptorInvocation : interceptorInvocations)
+      {
+         interceptorMethodInvocations.addAll(interceptorInvocation.getInterceptorMethodInvocations());
+      }
    }
 
    public Object invokeNext(InvocationContext invocationContext) throws Throwable
    {
 
-      if (hasNext())
+      try
       {
-         InterceptionHandler nextInterceptorHandler = interceptorHandlers.get(currentPosition++);
-         if (log.isTraceEnabled())
+         if (hasNext())
          {
-            log.trace("Invoking next interceptor in chain:" + nextInterceptorHandler.getClass().getName());
+            InterceptorInvocation.InterceptorMethodInvocation nextInterceptorMethodInvocation = interceptorMethodInvocations.get(currentPosition++);
+            if (log.isTraceEnabled())
+            {
+               log.trace("Invoking next interceptor in chain:" + nextInterceptorMethodInvocation.method.toString());
+            }
+            if (nextInterceptorMethodInvocation.method.getJavaMethod().getParameterTypes().length == 1)
+            {
+               return nextInterceptorMethodInvocation.invoke(invocationContext);
+            }
+            else if (nextInterceptorMethodInvocation.method.getJavaMethod().getParameterTypes().length == 0)
+            {
+               nextInterceptorMethodInvocation.invoke(null);
+               while (hasNext())
+               {
+                  nextInterceptorMethodInvocation = interceptorMethodInvocations.get(currentPosition++);
+                  if (nextInterceptorMethodInvocation.method.getJavaMethod().getParameterTypes().length != 0)
+                  {
+                     throw new IllegalStateException("Impossible state: lifecycle callback interceptor method on target class has more than one argument:" + nextInterceptorMethodInvocation.getMethod());
+                  }
+                  nextInterceptorMethodInvocation.invoke(null);
+               }
+               return null;
+            }
+            else
+            {
+               throw new IllegalStateException("Impossible state: interceptor method has more than one argument:" + nextInterceptorMethodInvocation.getMethod());
+            }
          }
-         return nextInterceptorHandler.intercept(target, interceptionType, invocationContext);
-      }
-      else
-      {
-         if (targetMethod != null)
+         else
          {
-            try
+            if (targetMethod != null)
             {
+
                return targetMethod.invoke(target, invocationContext.getParameters());
+
             }
-            catch (InvocationTargetException e)
+            else
             {
-               throw e.getCause();
+               return null;
             }
          }
-         else
-         {
-            return null;
-         }
       }
+      catch (InvocationTargetException e)
+      {
+         throw e.getCause();
+      }
    }
 
    public boolean hasNext()
    {
-      return currentPosition < interceptorHandlers.size();
+      return currentPosition < interceptorMethodInvocations.size();
    }
 
-
 }

Added: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorInvocation.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorInvocation.java	                        (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorInvocation.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -0,0 +1,81 @@
+/*
+ * 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.proxy;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.interceptor.InvocationContext;
+
+import org.jboss.interceptor.spi.metadata.InterceptorMetadata;
+import org.jboss.interceptor.spi.metadata.MethodMetadata;
+import org.jboss.interceptor.spi.model.InterceptionType;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class InterceptorInvocation<T>
+{
+   private T instance;
+
+   private InterceptorMetadata interceptorMetadata;
+   private InterceptionType interceptionType;
+
+   public InterceptorInvocation(T instance, InterceptorMetadata interceptorMetadata, InterceptionType interceptionType)
+   {
+      this.instance = instance;
+      this.interceptorMetadata = interceptorMetadata;
+      this.interceptionType = interceptionType;
+   }
+
+   public Collection<InterceptorMethodInvocation> getInterceptorMethodInvocations()
+   {
+      Collection<InterceptorMethodInvocation> interceptorMethodInvocations = new ArrayList<InterceptorMethodInvocation>();
+      for (MethodMetadata method: interceptorMetadata.getInterceptorMethods(interceptionType))
+      {
+         interceptorMethodInvocations.add(new InterceptorMethodInvocation(instance, method));
+      }
+      return interceptorMethodInvocations;
+   }
+
+   public class InterceptorMethodInvocation
+   {
+      T instance;
+
+      MethodMetadata method;
+
+      InterceptorMethodInvocation(T instance, MethodMetadata method)
+      {
+         this.instance = instance;
+         this.method = method;
+      }
+
+      Object invoke(InvocationContext invocationContext) throws Exception
+      {
+         if (invocationContext != null)
+            return method.getJavaMethod().invoke(instance, invocationContext);
+         else
+            return method.getJavaMethod().invoke(instance);
+      }
+
+      public MethodMetadata getMethod()
+      {
+         return method;
+      }
+   }
+}

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-07-27 19:06:49 UTC (rev 107122)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorMethodHandler.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -6,16 +6,19 @@
 import java.io.Serializable;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.jboss.interceptor.util.InterceptionTypeRegistry;
-import org.jboss.interceptor.spi.handler.InterceptionHandler;
-import org.jboss.interceptor.spi.handler.InterceptionHandlerFactory;
+import org.jboss.interceptor.reader.InterceptorMetadataUtils;
+import org.jboss.interceptor.reader.ReflectiveClassMetadata;
+import org.jboss.interceptor.spi.instance.InterceptorInstantiator;
+import org.jboss.interceptor.spi.metadata.ClassMetadata;
 import org.jboss.interceptor.spi.metadata.InterceptorMetadata;
 import org.jboss.interceptor.spi.model.InterceptionModel;
 import org.jboss.interceptor.spi.model.InterceptionType;
+import org.jboss.interceptor.util.InterceptionTypeRegistry;
 import org.jboss.interceptor.util.InterceptionUtils;
 import org.jboss.interceptor.util.ReflectionUtils;
 import org.jboss.interceptor.util.proxy.TargetInstanceProxyMethodHandler;
@@ -26,18 +29,18 @@
 public class InterceptorMethodHandler extends TargetInstanceProxyMethodHandler implements Serializable
 {
 
-   private Map<Object, InterceptionHandler> interceptorHandlerInstances = new HashMap<Object, InterceptionHandler>();
+   private Map<ClassMetadata<?>, Object> interceptorHandlerInstances = new HashMap<ClassMetadata<?>, Object>();
    private InterceptorMetadata targetClassInterceptorMetadata;
-   private InterceptionModel<Class<?>, ?> interceptionModel;
+   private InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
 
-   public InterceptorMethodHandler(Object target, Class<?> targetClass, InterceptionModel<Class<?>, ?> interceptionModel, InterceptionHandlerFactory<?> interceptionHandlerFactory, InterceptorMetadata targetClassMetadata)
+   public InterceptorMethodHandler(Object target, ClassMetadata<?> targetClass, InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel, InterceptorInstantiator<ClassMetadata<?>, ?> interceptorInstantiator, InterceptorMetadata targetClassMetadata)
    {
-      super(target, targetClass != null ? targetClass : target.getClass());
+      super(target, targetClass != null ? targetClass : ReflectiveClassMetadata.of(target.getClass()));
       if (interceptionModel == null)
       {
          throw new IllegalArgumentException("Interception model must not be null");
       }
-      if (interceptionHandlerFactory == null)
+      if (interceptorInstantiator == null)
       {
          throw new IllegalArgumentException("Interception handler factory must not be null");
       }
@@ -45,9 +48,9 @@
 
       this.interceptionModel = interceptionModel;
 
-      for (Object interceptorReference : this.interceptionModel.getAllInterceptors())
+      for (ClassMetadata<?> interceptorReference : this.interceptionModel.getAllInterceptors())
       {
-         interceptorHandlerInstances.put(interceptorReference, ((InterceptionHandlerFactory) interceptionHandlerFactory).createFor(interceptorReference));
+         interceptorHandlerInstances.put(interceptorReference, ((InterceptorInstantiator) interceptorInstantiator).createFor(interceptorReference));
       }
       targetClassInterceptorMetadata = targetClassMetadata;
    }
@@ -88,19 +91,20 @@
    private Object executeInterception(Method thisMethod, Object[] args, InterceptionType interceptionType) throws Throwable
    {
 
-      List<InterceptionHandler> interceptionHandlers = new ArrayList<InterceptionHandler>();
-         List<?> interceptorList = interceptionModel.getInterceptors(interceptionType, thisMethod);
-         for (Object interceptorReference : interceptorList)
-         {
-            interceptionHandlers.add(interceptorHandlerInstances.get(interceptorReference));
-         }
+      List<ClassMetadata> interceptorList = interceptionModel.getInterceptors(interceptionType, thisMethod);
+      Collection<InterceptorInvocation<?>> interceptorInvocations = new ArrayList<InterceptorInvocation<?>>();
 
+      for (ClassMetadata<?> interceptorReference : interceptorList)
+      {
+         interceptorInvocations.add(new InterceptorInvocation(interceptorHandlerInstances.get(interceptorReference), InterceptorMetadataUtils.readMetadataForInterceptorClass(interceptorReference), interceptionType));
+      }
+
       if (targetClassInterceptorMetadata != null && targetClassInterceptorMetadata.getInterceptorMethods(interceptionType) != null && !targetClassInterceptorMetadata.getInterceptorMethods(interceptionType).isEmpty())
       {
-         interceptionHandlers.add(new DirectClassInterceptionHandler<Class<?>>(getTargetInstance(), targetClassInterceptorMetadata));
+         interceptorInvocations.add(new InterceptorInvocation(getTargetInstance(), InterceptorMetadataUtils.readMetadataForTargetClass(getTargetClass()), interceptionType));
       }
 
-      InterceptionChain chain = new InterceptionChain(interceptionHandlers, interceptionType, getTargetInstance(), thisMethod);
+      InterceptionChain chain = new InterceptionChain(interceptorInvocations, interceptionType, getTargetInstance(), thisMethod);
       return chain.invokeNext(new InterceptorInvocationContext(chain, getTargetInstance(), thisMethod, args));
    }
 

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-07-27 19:06:49 UTC (rev 107122)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreator.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -18,6 +18,7 @@
 package org.jboss.interceptor.proxy;
 
 import javassist.util.proxy.MethodHandler;
+import org.jboss.interceptor.spi.metadata.ClassMetadata;
 import org.jboss.interceptor.spi.metadata.InterceptorMetadata;
 
 /**
@@ -26,11 +27,8 @@
 public interface InterceptorProxyCreator
 {
 
-   <T> T createProxyInstance(Class<T> proxyClass, MethodHandler interceptorMethodHandler);
+   <T> MethodHandler createMethodHandler(Object target, ClassMetadata<T> proxyClass, InterceptorMetadata interceptorMetadata);
 
-   <T> MethodHandler createMethodHandler(Object target, Class<T> proxyClass, InterceptorMetadata interceptorMetadata);
+   <T> MethodHandler createSubclassingMethodHandler(Object targetInstance, ClassMetadata<T> proxyClass, InterceptorMetadata interceptorMetadata);
 
-   <T> MethodHandler createSubclassingMethodHandler(Object targetInstance, Class<T> proxyClass, InterceptorMetadata interceptorMetadata);
-
-   <T> T createProxyFromClass(Class<T> proxifiedClass, Class<?>[] constructorTypes, Object[] constructorArguments, InterceptorMetadata interceptorClassMetadata);
 }

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-07-27 19:06:49 UTC (rev 107122)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreatorImpl.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -23,7 +23,8 @@
 import javassist.util.proxy.MethodHandler;
 import javassist.util.proxy.ProxyObject;
 import org.jboss.interceptor.proxy.javassist.CompositeHandler;
-import org.jboss.interceptor.spi.handler.InterceptionHandlerFactory;
+import org.jboss.interceptor.spi.instance.InterceptorInstantiator;
+import org.jboss.interceptor.spi.metadata.ClassMetadata;
 import org.jboss.interceptor.spi.metadata.InterceptorMetadata;
 import org.jboss.interceptor.spi.model.InterceptionModel;
 import org.jboss.interceptor.util.InterceptionUtils;
@@ -35,24 +36,24 @@
 public class InterceptorProxyCreatorImpl implements InterceptorProxyCreator
 {
 
-   private InterceptionModel<Class<?>,?> interceptionModel;
+   private InterceptionModel<ClassMetadata<?>,ClassMetadata> interceptionModel;
 
-   private InterceptionHandlerFactory<?> interceptionHandlerFactory;
+   private InterceptorInstantiator<ClassMetadata<?>, Object> interceptorInstantiator;
 
-      public InterceptorProxyCreatorImpl(InterceptionHandlerFactory<?> interceptionHandlerFactory, InterceptionModel<Class<?>, ?> interceptionModel)
+      public InterceptorProxyCreatorImpl(InterceptorInstantiator<ClassMetadata<?>, Object> interceptorInstantiator, InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel)
    {
-      this.interceptionHandlerFactory = interceptionHandlerFactory;
+      this.interceptorInstantiator = interceptorInstantiator;
       this.interceptionModel = interceptionModel;
    }
 
 
-   public <T> T createProxyFromInstance(final Object target, Class<T> proxifiedClass, Class<?>[] constructorTypes, Object[] constructorArguments, InterceptorMetadata interceptorClassMetadata)
+   public <T> T createProxyFromInstance(final Object target, ClassMetadata<T> proxifiedClass, Class<?>[] constructorTypes, Object[] constructorArguments, InterceptorMetadata interceptorClassMetadata)
    {
-       MethodHandler interceptorMethodHandler = createMethodHandler(target, proxifiedClass, interceptorClassMetadata);
+      MethodHandler interceptorMethodHandler = createMethodHandler(target, proxifiedClass, interceptorClassMetadata);
       return createProxyInstance(InterceptionUtils.createProxyClassWithHandler(proxifiedClass, interceptorMethodHandler), interceptorMethodHandler);
    }
 
-   public <T> T createProxyFromClass(Class<T> proxifiedClass, Class<?>[] constructorTypes, Object[] constructorArguments, InterceptorMetadata interceptorClassMetadata)
+   public <T> T createProxyFromClass(ClassMetadata<T> proxifiedClass, Class<?>[] constructorTypes, Object[] constructorArguments, InterceptorMetadata interceptorClassMetadata)
    {
       T instance = createAdvisedSubclassInstance(proxifiedClass, constructorTypes, constructorArguments);
       MethodHandler interceptorMethodHandler = createSubclassingMethodHandler(instance, proxifiedClass, interceptorClassMetadata);
@@ -61,11 +62,11 @@
       return instance;
    }
 
-   public <T> T createAdvisedSubclassInstance(Class<T> proxifiedClass, Class<?>[] constructorParameterTypes, Object[] constructorArguments)
+   public <T> T createAdvisedSubclassInstance(ClassMetadata<T> proxifiedClass, Class<?>[] constructorParameterTypes, Object[] constructorArguments)
    {
        try
        {
-           Class<T> clazz = InterceptionUtils.createProxyClass(proxifiedClass, true);
+           Class<T> clazz = InterceptionUtils.createProxyClass(((Class<T>) proxifiedClass.getJavaClass()), true);
            Constructor<T> constructor = clazz.getConstructor(constructorParameterTypes);
            return constructor.newInstance(constructorArguments);
        }
@@ -108,14 +109,14 @@
       }
    }
 
-   public <T> MethodHandler createMethodHandler(Object target, Class<T> proxyClass, InterceptorMetadata interceptorMetadata)
+   public <T> MethodHandler createMethodHandler(Object target, ClassMetadata<T> proxyClass, InterceptorMetadata interceptorMetadata)
    {
-      return new InterceptorMethodHandler(target, proxyClass, interceptionModel, interceptionHandlerFactory, interceptorMetadata);
+      return new InterceptorMethodHandler(target, proxyClass, interceptionModel, interceptorInstantiator, interceptorMetadata);
    }
 
-    public <T> MethodHandler createSubclassingMethodHandler(Object targetInstance, Class<T> proxyClass, InterceptorMetadata interceptorMetadata)
+    public <T> MethodHandler createSubclassingMethodHandler(Object targetInstance, ClassMetadata<T> proxyClass, InterceptorMetadata interceptorMetadata)
     {
-       return new SubclassingInterceptorMethodHandler(targetInstance, interceptionModel, interceptionHandlerFactory, interceptorMetadata);
+       return new SubclassingInterceptorMethodHandler(targetInstance, proxyClass, interceptionModel, interceptorInstantiator, interceptorMetadata);
     }
 
 

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/SubclassingInterceptorMethodHandler.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/SubclassingInterceptorMethodHandler.java	2010-07-27 19:06:49 UTC (rev 107122)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/proxy/SubclassingInterceptorMethodHandler.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -6,18 +6,20 @@
 import java.io.Serializable;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import javassist.util.proxy.MethodHandler;
 import javassist.util.proxy.ProxyObject;
-import org.jboss.interceptor.util.InterceptionTypeRegistry;
-import org.jboss.interceptor.spi.handler.InterceptionHandler;
-import org.jboss.interceptor.spi.handler.InterceptionHandlerFactory;
+import org.jboss.interceptor.reader.InterceptorMetadataUtils;
+import org.jboss.interceptor.spi.instance.InterceptorInstantiator;
+import org.jboss.interceptor.spi.metadata.ClassMetadata;
 import org.jboss.interceptor.spi.metadata.InterceptorMetadata;
 import org.jboss.interceptor.spi.model.InterceptionModel;
 import org.jboss.interceptor.spi.model.InterceptionType;
+import org.jboss.interceptor.util.InterceptionTypeRegistry;
 import org.jboss.interceptor.util.InterceptionUtils;
 import org.jboss.interceptor.util.ReflectionUtils;
 
@@ -27,9 +29,9 @@
 public class SubclassingInterceptorMethodHandler implements MethodHandler,Serializable
 {
 
-   private Map<Object, InterceptionHandler> interceptorHandlerInstances = new HashMap<Object, InterceptionHandler>();
+   private Map<ClassMetadata<?>, Object> interceptorHandlerInstances = new HashMap<ClassMetadata<?>, Object>();
    private InterceptorMetadata targetClassInterceptorMetadata;
-   private InterceptionModel<Class<?>, ?> interceptionModel;
+   private InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
    private Object targetInstance;
 
    private static MethodHandler DEFAULT_METHOD_HANDLER = new MethodHandler() {
@@ -42,24 +44,24 @@
         }
    };
 
-   public SubclassingInterceptorMethodHandler(Object targetInstance, InterceptionModel<Class<?>, ?> interceptionModel, InterceptionHandlerFactory<?> interceptionHandlerFactories, InterceptorMetadata targetClassMetadata)
+   public SubclassingInterceptorMethodHandler(Object target, ClassMetadata<?> targetClass, InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel, InterceptorInstantiator<ClassMetadata<?>, ?> interceptorInstantiator, InterceptorMetadata targetClassMetadata)
    {
-      this.targetInstance = targetInstance;
+      this.targetInstance = target;
       if (interceptionModel == null)
       {
          throw new IllegalArgumentException("Interception model must not be null");
       }
 
-      if (interceptionHandlerFactories == null)
+      if (interceptorInstantiator == null)
       {
          throw new IllegalArgumentException("Interception handler factory must not be null");
       }
 
       this.interceptionModel = interceptionModel;
 
-      for (Object interceptorReference : this.interceptionModel.getAllInterceptors())
+      for (ClassMetadata<?> interceptorReference : this.interceptionModel.getAllInterceptors())
       {
-         interceptorHandlerInstances.put(interceptorReference, ((InterceptionHandlerFactory) interceptionHandlerFactories).createFor(interceptorReference));
+         interceptorHandlerInstances.put(interceptorReference, (interceptorInstantiator).createFor(interceptorReference));
       }
       targetClassInterceptorMetadata = targetClassMetadata;
    }
@@ -99,19 +101,23 @@
 
    private Object executeInterception(Object self, Method proceedingMethod, Method thisMethod, Object[] args, InterceptionType interceptionType) throws Throwable
    {
-      List<InterceptionHandler> interceptionHandlers = new ArrayList<InterceptionHandler>();
-      List<?> interceptorList = interceptionModel.getInterceptors(interceptionType, thisMethod);
-      for (Object interceptorReference : interceptorList)
+
+      List<ClassMetadata> interceptorList = interceptionModel.getInterceptors(interceptionType, thisMethod);
+      Collection<InterceptorInvocation<?>> interceptorInvocations = new ArrayList<InterceptorInvocation<?>>();
+
+      for (ClassMetadata<?> interceptorReference : interceptorList)
       {
-         interceptionHandlers.add(interceptorHandlerInstances.get(interceptorReference));
+         interceptorInvocations.add(new InterceptorInvocation(interceptorHandlerInstances.get(interceptorReference), InterceptorMetadataUtils.readMetadataForInterceptorClass(interceptorReference), interceptionType));
       }
+
       if (targetClassInterceptorMetadata != null && targetClassInterceptorMetadata.getInterceptorMethods(interceptionType) != null && !targetClassInterceptorMetadata.getInterceptorMethods(interceptionType).isEmpty())
       {
-         interceptionHandlers.add(new DirectClassInterceptionHandler<Class<?>>(self, targetClassInterceptorMetadata));
+         interceptorInvocations.add(new InterceptorInvocation(self, targetClassInterceptorMetadata, interceptionType));
       }
 
-      InterceptionChain chain = new InterceptionChain(interceptionHandlers, interceptionType, self, proceedingMethod);
+      InterceptionChain chain = new InterceptionChain(interceptorInvocations, interceptionType, self,proceedingMethod);
       return chain.invokeNext(new InterceptorInvocationContext(chain, self, thisMethod, args));
+            
    }
 
    private void writeObject(ObjectOutputStream objectOutputStream) throws IOException

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/InterceptorMetadataUtils.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/InterceptorMetadataUtils.java	2010-07-27 19:06:49 UTC (rev 107122)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/InterceptorMetadataUtils.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -26,15 +26,17 @@
  */
 public class InterceptorMetadataUtils
 {
+   protected static final String OBJECT_CLASS_NAME = Object.class.getName();
 
    private static final Logger LOG = LoggerFactory.getLogger(InterceptorMetadataUtils.class);
 
-   public static InterceptorMetadata readMetadataForInterceptorClass(ClassMetadata classMetadata)
+
+   public static InterceptorMetadata readMetadataForInterceptorClass(ClassMetadata<?> classMetadata)
    {
       return new SimpleInterceptorMetadata(classMetadata, false, buildMethodMap(classMetadata, false));
    }
 
-   public static InterceptorMetadata readMetadataForTargetClass(ClassMetadata classMetadata)
+   public static InterceptorMetadata readMetadataForTargetClass(ClassMetadata<?> classMetadata)
    {
       return new SimpleInterceptorMetadata(classMetadata, true, buildMethodMap(classMetadata, true));
    }
@@ -95,7 +97,7 @@
          {
             if (LOG.isDebugEnabled())
             {
-               LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not return a " + Object.class.getName());
+               LOG.debug(getStandardIgnoredMessage(interceptionType, method.getJavaMethod()) + "does not return a " + OBJECT_CLASS_NAME);
             }
             return false;
          }
@@ -131,10 +133,10 @@
             + interceptionType.annotationClassName() + ", but ";
    }
 
-   static Map<InterceptionType, List<MethodMetadata>> buildMethodMap(ClassMetadata interceptorClass, boolean forTargetClass)
+   static Map<InterceptionType, List<MethodMetadata>> buildMethodMap(ClassMetadata<?> interceptorClass, boolean forTargetClass)
    {
       Map<InterceptionType, List<MethodMetadata>> methodMap = new HashMap<InterceptionType, List<MethodMetadata>>();
-      ClassMetadata currentClass = interceptorClass;
+      ClassMetadata<?> currentClass = interceptorClass;
       Set<MethodReference> foundMethods = new HashSet<MethodReference>();
       do
       {
@@ -170,7 +172,7 @@
          }
          currentClass = currentClass.getSuperclass();
       }
-      while (!Object.class.equals(currentClass.getJavaClass()));
+      while (currentClass != null && !OBJECT_CLASS_NAME.equals(currentClass.getJavaClass()));
       return methodMap;
    }
 }

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/ReflectiveClassMetadata.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/ReflectiveClassMetadata.java	2010-07-27 19:06:49 UTC (rev 107122)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/ReflectiveClassMetadata.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -29,17 +29,17 @@
 /**
  * @author Marius Bogoevici
  */
-public class ReflectiveClassMetadata implements ClassMetadata, Serializable
+public class ReflectiveClassMetadata<T> implements ClassMetadata<T>, Serializable
 {
 
-   private Class<?> clazz;
+   private Class<T> clazz;
 
-   private ReflectiveClassMetadata(Class<?> clazz)
+   private ReflectiveClassMetadata(Class<T> clazz)
    {
       this.clazz = clazz;
    }
 
-   public static ClassMetadata of(Class<?> clazz)
+   public static <T> ClassMetadata<T> of(Class<T> clazz)
    {
       return new ReflectiveClassMetadata(clazz);
    }
@@ -67,12 +67,12 @@
       };     
    }
 
-   public Class<?> getJavaClass()
+   public Class<T> getJavaClass()
    {
       return clazz;
    }   
 
-   public ClassMetadata getSuperclass()
+   public ClassMetadata<?> getSuperclass()
    {
       Class<?> superClass = clazz.getSuperclass();
       return superClass == null? null : new ReflectiveClassMetadata(superClass);

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/ReflectiveMethodMetadata.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/ReflectiveMethodMetadata.java	2010-07-27 19:06:49 UTC (rev 107122)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/ReflectiveMethodMetadata.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -51,7 +51,7 @@
       return javaMethod;
    }
 
-   public ClassMetadata getReturnType()
+   public ClassMetadata<?> getReturnType()
    {
       return ReflectiveClassMetadata.of(javaMethod.getReturnType());
    }

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/SimpleInterceptorMetadata.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/SimpleInterceptorMetadata.java	2010-07-27 19:06:49 UTC (rev 107122)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/reader/SimpleInterceptorMetadata.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -34,13 +34,13 @@
 public class SimpleInterceptorMetadata implements InterceptorMetadata, Serializable
 {
 
-   private ClassMetadata interceptorClass;
+   private ClassMetadata<?> interceptorClass;
 
    private Map<InterceptionType, List<MethodMetadata>> interceptorMethodMap;
 
    private boolean targetClass;
 
-   public SimpleInterceptorMetadata(ClassMetadata interceptorClass, boolean targetClass, Map<InterceptionType, List<MethodMetadata>> interceptorMethodMap)
+   public SimpleInterceptorMetadata(ClassMetadata<?> interceptorClass, boolean targetClass, Map<InterceptionType, List<MethodMetadata>> interceptorMethodMap)
    {
       this.interceptorClass = interceptorClass;
       this.targetClass = targetClass;
@@ -73,10 +73,10 @@
    private static class MetadataSerializationProxy implements Serializable
    {
 
-      private ClassMetadata classMetadata;
+      private ClassMetadata<?> classMetadata;
       private boolean targetClass;
 
-      MetadataSerializationProxy(ClassMetadata classMetadata, boolean targetClass)
+      MetadataSerializationProxy(ClassMetadata<?> classMetadata, boolean targetClass)
       {
          this.classMetadata = classMetadata;
          this.targetClass = targetClass;

Modified: 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/InterceptorMetadataRegistry.java	2010-07-27 19:06:49 UTC (rev 107122)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/registry/InterceptorMetadataRegistry.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -11,8 +11,8 @@
  */
 public interface InterceptorMetadataRegistry
 {
-   InterceptorMetadata getInterceptorClassMetadata(ClassMetadata interceptorClass);
+   InterceptorMetadata getInterceptorClassMetadata(ClassMetadata<?> interceptorClass);
 
-   InterceptorMetadata getInterceptorClassMetadata(ClassMetadata interceptorClass, boolean isInterceptorTargetClass);
+   InterceptorMetadata getInterceptorClassMetadata(ClassMetadata<?> interceptorClass, boolean isInterceptorTargetClass);
 
 }

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-07-27 19:06:49 UTC (rev 107122)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/InterceptionUtils.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -26,10 +26,9 @@
 import javassist.util.proxy.ProxyFactory;
 import org.jboss.interceptor.proxy.InterceptorException;
 import org.jboss.interceptor.proxy.LifecycleMixin;
+import org.jboss.interceptor.spi.metadata.ClassMetadata;
 import org.jboss.interceptor.spi.model.InterceptionType;
 import org.jboss.interceptor.util.proxy.TargetInstanceProxy;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
@@ -164,13 +163,13 @@
       return clazz;
    }
 
-   public static <T> Class<T> createProxyClassWithHandler(Class<T> proxyClass, MethodHandler methodHandler)
+   public static <T> Class<T> createProxyClassWithHandler(ClassMetadata<T> proxyClass, MethodHandler methodHandler)
    {
       ProxyFactory proxyFactory = new ProxyFactory();
       proxyFactory.setUseWriteReplace(false);
       if (proxyClass != null)
       {
-         proxyFactory.setSuperclass(proxyClass);
+         proxyFactory.setSuperclass(proxyClass.getJavaClass());
       }
       proxyFactory.setInterfaces(new Class<?>[]{LifecycleMixin.class, TargetInstanceProxy.class});
       proxyFactory.setHandler(methodHandler);

Modified: projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/proxy/TargetInstanceProxyMethodHandler.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/proxy/TargetInstanceProxyMethodHandler.java	2010-07-27 19:06:49 UTC (rev 107122)
+++ projects/interceptors/trunk/jboss-interceptor/src/main/java/org/jboss/interceptor/util/proxy/TargetInstanceProxyMethodHandler.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -21,6 +21,7 @@
 import java.io.Serializable;
 
 import javassist.util.proxy.MethodHandler;
+import org.jboss.interceptor.spi.metadata.ClassMetadata;
 
 /**
  * @author Marius Bogoevici
@@ -29,9 +30,9 @@
 {
    private T targetInstance;
 
-   private Class<? extends T> targetClass;
+   private ClassMetadata<?> targetClass;
    
-   public TargetInstanceProxyMethodHandler(T targetInstance, Class<? extends T> targetClass)
+   public TargetInstanceProxyMethodHandler(T targetInstance, ClassMetadata<?> targetClass)
    {
       this.targetInstance = targetInstance;
       this.targetClass = targetClass;
@@ -69,7 +70,7 @@
       return targetInstance;
    }
 
-   public Class<? extends T> getTargetClass()
+   public ClassMetadata getTargetClass()
    {
       return targetClass;
    }

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-07-27 19:06:49 UTC (rev 107122)
+++ projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/InterceptionTestCase.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -21,21 +21,27 @@
 import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 
 import javassist.util.proxy.MethodHandler;
+import javassist.util.proxy.ProxyObject;
 import org.jboss.interceptor.builder.InterceptionModelBuilder;
+import org.jboss.interceptor.proxy.DirectClassInterceptorInstantiator;
+import org.jboss.interceptor.proxy.InterceptorProxyCreatorImpl;
+import org.jboss.interceptor.proxy.javassist.CompositeHandler;
+import org.jboss.interceptor.reader.ReflectiveClassMetadata;
 import org.jboss.interceptor.registry.InterceptorMetadataRegistry;
 import org.jboss.interceptor.registry.SimpleInterceptorMetadataRegistry;
-import org.jboss.interceptor.proxy.DirectClassInterceptionHandlerFactory;
-import org.jboss.interceptor.proxy.InterceptorProxyCreator;
-import org.jboss.interceptor.proxy.InterceptorProxyCreatorImpl;
-import org.jboss.interceptor.reader.ReflectiveClassMetadata;
+import org.jboss.interceptor.spi.metadata.ClassMetadata;
+import org.jboss.interceptor.spi.metadata.InterceptorMetadata;
 import org.jboss.interceptor.spi.model.InterceptionModel;
 import org.jboss.interceptor.util.InterceptionUtils;
 import org.junit.Assert;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -90,9 +96,9 @@
          "org.jboss.interceptors.proxy.FootballTeam_getName",
    };
 
-   private Map<Class<?>, InterceptionModel<?,?>> interceptionModelRegistry;
+   private Map<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>> interceptionModelRegistry;
 
-   private DirectClassInterceptionHandlerFactory interceptionHandlerFactory;
+   private DirectClassInterceptorInstantiator interceptionHandlerFactory;
 
    private InterceptorMetadataRegistry interceptorMetadataRegistry;
 
@@ -100,19 +106,22 @@
    public void setUp()
    {
       interceptorMetadataRegistry = new SimpleInterceptorMetadataRegistry();
-      interceptionHandlerFactory = new DirectClassInterceptionHandlerFactory(interceptorMetadataRegistry);
+      interceptionHandlerFactory = new DirectClassInterceptorInstantiator(interceptorMetadataRegistry);
    }
 
    public void resetLogAndSetupClassesForMethod() throws Exception
    {
       InterceptorTestLogger.reset();
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-      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;      
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(
+            ReflectiveClassMetadata.of(FirstInterceptor.class), ReflectiveClassMetadata.of(SecondInterceptor.class));
+      builder.interceptPostConstruct().with(ReflectiveClassMetadata.of(FirstInterceptor.class));
+      builder.interceptPreDestroy().with(ReflectiveClassMetadata.of(SecondInterceptor.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
       interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
    }
@@ -121,12 +130,14 @@
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
 
-      builder.interceptAll().with(FirstInterceptor.class, SecondInterceptor.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel;      
+      builder.interceptAll().with(ReflectiveClassMetadata.of(FirstInterceptor.class), ReflectiveClassMetadata.of(SecondInterceptor.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
       interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>,InterceptionModel<?,?>>();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>, ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
    }
@@ -135,13 +146,15 @@
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-      builder.interceptAll().with(FirstInterceptor.class);
-      builder.interceptPreDestroy().with(SecondInterceptor.class);
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(SecondInterceptor.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel;      
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
+      builder.interceptAll().with(ReflectiveClassMetadata.of(FirstInterceptor.class));
+      builder.interceptPreDestroy().with(ReflectiveClassMetadata.of(SecondInterceptor.class));
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(ReflectiveClassMetadata.of(SecondInterceptor.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
       interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>,InterceptionModel<?,?>>();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
    }
@@ -150,14 +163,16 @@
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-      builder.interceptAll().with(FirstInterceptor.class);
-      builder.interceptPreDestroy().with(SecondInterceptor.class);
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(SecondInterceptor.class);
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
+      builder.interceptAll().with(ReflectiveClassMetadata.of(FirstInterceptor.class));
+      builder.interceptPreDestroy().with(ReflectiveClassMetadata.of(SecondInterceptor.class));
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(ReflectiveClassMetadata.of(SecondInterceptor.class));
       builder.ignoreGlobalInterceptors(FootballTeam.class.getMethod("getName"));
-      InterceptionModel<Class<?>, Class<?>> interceptionModel;      
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
       interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
    }
@@ -167,54 +182,59 @@
    public void testInterceptionWithMethodRegisteredInterceptors() throws Exception
    {
       resetLogAndSetupClassesForMethod();
-      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
+      FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
       InterceptionUtils.executePostConstruct(proxy);
       Assert.assertEquals(TEAM_NAME, proxy.getName());
       InterceptionUtils.executePredestroy(proxy);
       Object[] logValues = InterceptorTestLogger.getLog().toArray();
       Assert.assertArrayEquals(iterateAndDisplay(logValues), expectedLoggedValues, logValues);
+      assertRawObject(proxy);
    }
 
    @Test
    public void testInterceptionWithGlobalInterceptors() throws Exception
    {
       resetLogAndSetupClassesGlobally();
-      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
+      FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
       InterceptionUtils.executePostConstruct(proxy);
       Assert.assertEquals(TEAM_NAME, proxy.getName());
       InterceptionUtils.executePredestroy(proxy);
+      assertRawObject(proxy);
    }
 
    @Test
    public void testInterceptionWithMixedInterceptors() throws Exception
    {
       resetLogAndSetupClassesMixed();
-      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
+      FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
       InterceptionUtils.executePostConstruct(proxy);
       Assert.assertEquals(TEAM_NAME, proxy.getName());
       InterceptionUtils.executePredestroy(proxy);
       Object[] logValues = InterceptorTestLogger.getLog().toArray();
       Assert.assertArrayEquals(iterateAndDisplay(logValues), expectedLoggedValues, logValues);
+      assertRawObject(proxy);
    }
 
    @Test
    public void testInterceptionWithGlobalsIgnored() throws Exception
    {
       resetLogAndSetupClassesWithGlobalsIgnored();
-      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
+      FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
       InterceptionUtils.executePostConstruct(proxy);
       Assert.assertEquals(TEAM_NAME, proxy.getName());
       InterceptionUtils.executePredestroy(proxy);
       Object[] logValues = InterceptorTestLogger.getLog().toArray();
       Assert.assertArrayEquals(iterateAndDisplay(logValues), expectedLoggedValuesWithGlobalsIgnored, logValues);
+      assertRawObject(proxy);
    }
 
 
    @Test
+   @Ignore
    public void testInterceptionWithSerializedProxy() throws Exception
    {
       resetLogAndSetupClassesForMethod();
-      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
+      FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
       InterceptionUtils.executePostConstruct(proxy);
       ByteArrayOutputStream baos = new ByteArrayOutputStream();
       new ObjectOutputStream(baos).writeObject(proxy);
@@ -222,22 +242,37 @@
       Assert.assertEquals(TEAM_NAME, proxy.getName());
       Object[] logValues = InterceptorTestLogger.getLog().toArray();
       Assert.assertArrayEquals(iterateAndDisplay(logValues), expectedLoggedValuesOnSerialization, logValues);
+      Assert.assertTrue(((ProxyObject)proxy).getHandler() instanceof CompositeHandler);
+      assertRawObject(proxy);
    }
 
 
    @Test
+   public void testSerialization() throws Exception
+   {
+      FootballTeam proxy = new FootballTeam("Ajax Amsterdam");
+      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+      new ObjectOutputStream(baos).writeObject(proxy);
+      proxy = (FootballTeam) new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())).readObject();
+      Assert.assertNotNull(proxy);
+   }
+
+
+   @Test
    public void testMethodParameterOverriding() throws Exception
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echo", String.class)).with(ParameterOverridingInterceptor.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echo", String.class)).with(ReflectiveClassMetadata.of(ParameterOverridingInterceptor.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
+      interceptionModel = builder.build();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
-      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
+      FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
       Assert.assertEquals(42, proxy.echo("1"));
    }
 
@@ -246,14 +281,17 @@
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
 
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoInt", int.class)).with(ParameterOverridingInterceptorWithInteger.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoInt", int.class)).with(ReflectiveClassMetadata.of(ParameterOverridingInterceptorWithInteger.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
+      interceptionModel = builder.build();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
-      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
+      FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
       Assert.assertEquals(42, proxy.echoInt(1));
    }
 
@@ -262,14 +300,17 @@
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
 
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLongAsObject", Long.class)).with(ParameterOverridingInterceptorWithInteger.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLongAsObject", Long.class)).with(ReflectiveClassMetadata.of(ParameterOverridingInterceptorWithInteger.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
+      interceptionModel = builder.build();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
-      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
+      FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
       Assert.assertEquals(new Long(42), proxy.echoLongAsObject(1l));
    }
 
@@ -278,14 +319,17 @@
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
 
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLongAsObject", Long.class)).with(ParameterOverridingInterceptorWithLong.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLongAsObject", Long.class)).with(ReflectiveClassMetadata.of(ParameterOverridingInterceptorWithLong.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
+      interceptionModel = builder.build();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
-      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
+      FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
       Assert.assertEquals(new Long(42), proxy.echoLongAsObject(1l));
    }
 
@@ -294,14 +338,17 @@
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
 
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLong", long.class)).with(ParameterOverridingInterceptorWithInteger.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLong", long.class)).with(ReflectiveClassMetadata.of(ParameterOverridingInterceptorWithInteger.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
+      interceptionModel = builder.build();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
-      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
+      FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
       Assert.assertEquals(42, proxy.echoLong(1));
    }
 
@@ -310,14 +357,17 @@
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
 
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoInt", int.class)).with(ParameterOverridingInterceptorWithLong.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoInt", int.class)).with(ReflectiveClassMetadata.of(ParameterOverridingInterceptorWithLong.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
+      interceptionModel = builder.build();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
-      FootballTeam proxy =proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
+      FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
       Assert.assertEquals(42, proxy.echoInt(1));
    }
 
@@ -326,14 +376,17 @@
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
 
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoObjectArray", Object[].class)).with(ParameterOverridingInterceptorWithLongArray.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoObjectArray", Object[].class)).with(ReflectiveClassMetadata.of(ParameterOverridingInterceptorWithLongArray.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
+      interceptionModel = builder.build();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
-      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
+      FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
       Assert.assertEquals(new Long[]{42l}, proxy.echoObjectArray(new Object[]{}));
    }
 
@@ -342,14 +395,17 @@
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
 
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoStringArray", String[].class)).with(ParameterOverridingInterceptorWithLongArray.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoStringArray", String[].class)).with(ReflectiveClassMetadata.of(ParameterOverridingInterceptorWithLongArray.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
+      interceptionModel = builder.build();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
-      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
+      FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
       Assert.assertEquals(new Long[]{42l}, proxy.echoStringArray(new String[]{}));
    }
 
@@ -359,18 +415,29 @@
       InterceptorTestLogger.reset();
 
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
 
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echo2", ValueBearer.class)).with(ParameterOverridingInterceptor2.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
-      interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
-      
-      FootballTeam proxy = proxifyInstance(new FootballTeam(TEAM_NAME), FootballTeam.class);
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echo2", ValueBearer.class)).with(ReflectiveClassMetadata.of(ParameterOverridingInterceptor2.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
+      interceptionModel = builder.build();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
+      this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
+
+      FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
       proxy.doNothing();
       Assert.assertEquals(42, proxy.echo2(new ValueBearerImpl(1)));
    }
 
+   public void assertRawObject(FootballTeam proxy)
+   {
+//      InterceptorTestLogger.reset();
+//      FootballTeam rawInstance = InterceptionUtils.getRawInstance(proxy);
+//      Assert.assertEquals(TEAM_NAME, rawInstance.getName());
+//      Object[] logValues = InterceptorTestLogger.getLog().toArray();
+//      Assert.assertArrayEquals(iterateAndDisplay(logValues), expectedLoggedValuesWhenRaw, logValues);logValues
+   }
 
    private String iterateAndDisplay(Object[] logValues)
    {
@@ -382,11 +449,25 @@
       return buffer.toString();
    }
 
+   private <T> T createAdvisedInstance(Class<? extends T> targetClass, Object... args) throws Exception
+   {
+      ArrayList<Class<?>> argumentTypes = new ArrayList<Class<?>>();
+      for (Object arg: args)
+      {
+         argumentTypes.add(arg.getClass());
+      }
+      Constructor<? extends T> constructor = targetClass.getConstructor(argumentTypes.toArray(new Class<?>[]{}));
+      T instance = constructor.newInstance(args);
+      return proxifyInstance(instance, targetClass);
+   }
 
    private <T> T proxifyInstance(T instance, Class<? extends T> targetClass)
    {
-      InterceptorProxyCreator ipc = new InterceptorProxyCreatorImpl(interceptionHandlerFactory, ((InterceptionModel<Class<?>, ?>) interceptionModelRegistry.get(targetClass)));
-      MethodHandler methodHandler = ipc.createMethodHandler(instance, targetClass, interceptorMetadataRegistry.getInterceptorClassMetadata(ReflectiveClassMetadata.of(targetClass), true));
-      return ipc.createProxyInstance(InterceptionUtils.createProxyClassWithHandler(targetClass, methodHandler), methodHandler);
+      InterceptorProxyCreatorImpl ipc = new InterceptorProxyCreatorImpl(interceptionHandlerFactory, interceptionModelRegistry.get(targetClass));
+      InterceptorMetadata classMetadata = interceptorMetadataRegistry.getInterceptorClassMetadata(ReflectiveClassMetadata.of(targetClass), true);
+      ClassMetadata<? extends T> targetClassMetadata = ReflectiveClassMetadata.of(targetClass);
+      MethodHandler methodHandler = ipc.createMethodHandler(instance, targetClassMetadata, classMetadata);
+      Class<? extends T> proxyClassWithHandler = InterceptionUtils.createProxyClassWithHandler(targetClassMetadata, methodHandler);
+      return ipc.createProxyInstance(proxyClassWithHandler, methodHandler);
    }
 }

Modified: projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/SubclassingInterceptionTestCase.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/SubclassingInterceptionTestCase.java	2010-07-27 19:06:49 UTC (rev 107122)
+++ projects/interceptors/trunk/jboss-interceptor/src/test/java/org/jboss/interceptors/proxy/SubclassingInterceptionTestCase.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -26,13 +26,13 @@
 
 import javassist.util.proxy.ProxyObject;
 import org.jboss.interceptor.builder.InterceptionModelBuilder;
-import org.jboss.interceptor.registry.InterceptorMetadataRegistry;
-import org.jboss.interceptor.registry.SimpleInterceptorMetadataRegistry;
-import org.jboss.interceptor.proxy.DirectClassInterceptionHandlerFactory;
-import org.jboss.interceptor.proxy.InterceptorProxyCreator;
+import org.jboss.interceptor.proxy.DirectClassInterceptorInstantiator;
 import org.jboss.interceptor.proxy.InterceptorProxyCreatorImpl;
 import org.jboss.interceptor.proxy.javassist.CompositeHandler;
 import org.jboss.interceptor.reader.ReflectiveClassMetadata;
+import org.jboss.interceptor.registry.InterceptorMetadataRegistry;
+import org.jboss.interceptor.registry.SimpleInterceptorMetadataRegistry;
+import org.jboss.interceptor.spi.metadata.ClassMetadata;
 import org.jboss.interceptor.spi.model.InterceptionModel;
 import org.jboss.interceptor.util.InterceptionUtils;
 import org.junit.Assert;
@@ -92,9 +92,9 @@
          "org.jboss.interceptors.proxy.FootballTeam_getName",
    };
 
-   private Map<Class<?>, InterceptionModel<?,?>> interceptionModelRegistry;
+   private Map<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>> interceptionModelRegistry;
 
-   private DirectClassInterceptionHandlerFactory interceptionHandlerFactory;
+   private DirectClassInterceptorInstantiator interceptionHandlerFactory;
 
    private InterceptorMetadataRegistry interceptorMetadataRegistry;
 
@@ -102,19 +102,22 @@
    public void setUp()
    {
       interceptorMetadataRegistry = new SimpleInterceptorMetadataRegistry();
-      interceptionHandlerFactory = new DirectClassInterceptionHandlerFactory(interceptorMetadataRegistry);
+      interceptionHandlerFactory = new DirectClassInterceptorInstantiator(interceptorMetadataRegistry);
    }
 
    public void resetLogAndSetupClassesForMethod() throws Exception
    {
       InterceptorTestLogger.reset();
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-      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;
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(
+            ReflectiveClassMetadata.of(FirstInterceptor.class), ReflectiveClassMetadata.of(SecondInterceptor.class));
+      builder.interceptPostConstruct().with(ReflectiveClassMetadata.of(FirstInterceptor.class));
+      builder.interceptPreDestroy().with(ReflectiveClassMetadata.of(SecondInterceptor.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
       interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
    }
@@ -123,12 +126,14 @@
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
 
-      builder.interceptAll().with(FirstInterceptor.class, SecondInterceptor.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel;
+      builder.interceptAll().with(ReflectiveClassMetadata.of(FirstInterceptor.class), ReflectiveClassMetadata.of(SecondInterceptor.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
       interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>, ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
    }
@@ -137,13 +142,15 @@
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-      builder.interceptAll().with(FirstInterceptor.class);
-      builder.interceptPreDestroy().with(SecondInterceptor.class);
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(SecondInterceptor.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel;
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
+      builder.interceptAll().with(ReflectiveClassMetadata.of(FirstInterceptor.class));
+      builder.interceptPreDestroy().with(ReflectiveClassMetadata.of(SecondInterceptor.class));
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(ReflectiveClassMetadata.of(SecondInterceptor.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
       interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
    }
@@ -152,14 +159,16 @@
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-      builder.interceptAll().with(FirstInterceptor.class);
-      builder.interceptPreDestroy().with(SecondInterceptor.class);
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(SecondInterceptor.class);
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
+      builder.interceptAll().with(ReflectiveClassMetadata.of(FirstInterceptor.class));
+      builder.interceptPreDestroy().with(ReflectiveClassMetadata.of(SecondInterceptor.class));
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("getName")).with(ReflectiveClassMetadata.of(SecondInterceptor.class));
       builder.ignoreGlobalInterceptors(FootballTeam.class.getMethod("getName"));
-      InterceptionModel<Class<?>, Class<?>> interceptionModel;
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
       interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
    }
@@ -250,11 +259,13 @@
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
-
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echo", String.class)).with(ParameterOverridingInterceptor.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echo", String.class)).with(ReflectiveClassMetadata.of(ParameterOverridingInterceptor.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
+      interceptionModel = builder.build();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
       FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
@@ -266,11 +277,14 @@
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
 
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoInt", int.class)).with(ParameterOverridingInterceptorWithInteger.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoInt", int.class)).with(ReflectiveClassMetadata.of(ParameterOverridingInterceptorWithInteger.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
+      interceptionModel = builder.build();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
       FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
@@ -282,11 +296,14 @@
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
 
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLongAsObject", Long.class)).with(ParameterOverridingInterceptorWithInteger.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLongAsObject", Long.class)).with(ReflectiveClassMetadata.of(ParameterOverridingInterceptorWithInteger.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
+      interceptionModel = builder.build();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
       FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
@@ -298,11 +315,14 @@
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
 
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLongAsObject", Long.class)).with(ParameterOverridingInterceptorWithLong.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLongAsObject", Long.class)).with(ReflectiveClassMetadata.of(ParameterOverridingInterceptorWithLong.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
+      interceptionModel = builder.build();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
       FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
@@ -314,11 +334,14 @@
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
 
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLong", long.class)).with(ParameterOverridingInterceptorWithInteger.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoLong", long.class)).with(ReflectiveClassMetadata.of(ParameterOverridingInterceptorWithInteger.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
+      interceptionModel = builder.build();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
       FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
@@ -330,11 +353,14 @@
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
 
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoInt", int.class)).with(ParameterOverridingInterceptorWithLong.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoInt", int.class)).with(ReflectiveClassMetadata.of(ParameterOverridingInterceptorWithLong.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
+      interceptionModel = builder.build();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
       FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
@@ -346,11 +372,14 @@
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
 
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoObjectArray", Object[].class)).with(ParameterOverridingInterceptorWithLongArray.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoObjectArray", Object[].class)).with(ReflectiveClassMetadata.of(ParameterOverridingInterceptorWithLongArray.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
+      interceptionModel = builder.build();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
       FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
@@ -362,11 +391,14 @@
    {
       InterceptorTestLogger.reset();
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
 
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoStringArray", String[].class)).with(ParameterOverridingInterceptorWithLongArray.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echoStringArray", String[].class)).with(ReflectiveClassMetadata.of(ParameterOverridingInterceptorWithLongArray.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
+      interceptionModel = builder.build();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
       this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
       FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
@@ -379,12 +411,15 @@
       InterceptorTestLogger.reset();
 
 
-      InterceptionModelBuilder<Class<?>, Class<?>> builder = InterceptionModelBuilder.newBuilderFor(FootballTeam.class, (Class) Class.class);
+      ClassMetadata<?> footballTeamClass = ReflectiveClassMetadata.of(FootballTeam.class);
+      InterceptionModelBuilder<ClassMetadata<?>, ClassMetadata> builder =
+             InterceptionModelBuilder.<ClassMetadata<?>,ClassMetadata>newBuilderFor(footballTeamClass, ClassMetadata.class);
 
-      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echo2", ValueBearer.class)).with(ParameterOverridingInterceptor2.class);
-      InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
-      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<?,?>>();
-      interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
+      builder.interceptAroundInvoke(FootballTeam.class.getMethod("echo2", ValueBearer.class)).with(ReflectiveClassMetadata.of(ParameterOverridingInterceptor2.class));
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> interceptionModel;
+      interceptionModel = builder.build();
+      this.interceptionModelRegistry = new HashMap<Class<?>, InterceptionModel<ClassMetadata<?>,ClassMetadata>>();
+      this.interceptionModelRegistry.put(FootballTeam.class, interceptionModel);
 
       FootballTeam proxy = createAdvisedInstance(FootballTeam.class, TEAM_NAME);
       proxy.doNothing();
@@ -412,13 +447,9 @@
 
    private <T> T createAdvisedInstance(Class<? extends T> targetClass, Object... args) throws Exception
    {
-       return createAdvisedSubclassedInstance(targetClass, args);
+      InterceptionModel<ClassMetadata<?>, ClassMetadata> classMetadataInterceptionModel =  interceptionModelRegistry.get(targetClass);
+      InterceptorProxyCreatorImpl ipc = new InterceptorProxyCreatorImpl(interceptionHandlerFactory, classMetadataInterceptionModel);
+      return ipc.createProxyFromClass(ReflectiveClassMetadata.of((Class<? extends T>) targetClass), new Class<?>[]{String.class}, args, interceptorMetadataRegistry.getInterceptorClassMetadata(ReflectiveClassMetadata.of((Class<? extends T>) targetClass), true));
    }
 
-   private <T> T createAdvisedSubclassedInstance(Class<? extends T> targetClass, Object... args)
-   {
-      InterceptorProxyCreator ipc = new InterceptorProxyCreatorImpl(interceptionHandlerFactory, ((InterceptionModel<Class<?>, ?>) interceptionModelRegistry.get(targetClass)));
-      return ipc.createProxyFromClass(targetClass, new Class<?>[]{String.class},args, interceptorMetadataRegistry.getInterceptorClassMetadata(ReflectiveClassMetadata.of(targetClass), true));
-   }
-
 }
\ No newline at end of file

Copied: projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/instance (from rev 106596, projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/handler)

Deleted: projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/instance/InterceptionHandler.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/handler/InterceptionHandler.java	2010-07-12 14:54:45 UTC (rev 106596)
+++ projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/instance/InterceptionHandler.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -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.spi.handler;
-
-import javax.interceptor.InvocationContext;
-
-import org.jboss.interceptor.spi.model.InterceptionType;
-
-/**
- * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
- */
-public interface InterceptionHandler
-{
-   public Object intercept(Object target, InterceptionType interceptionType, InvocationContext invocationContext) throws Exception;
-}
-

Deleted: projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/instance/InterceptionHandlerFactory.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/handler/InterceptionHandlerFactory.java	2010-07-12 14:54:45 UTC (rev 106596)
+++ projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/instance/InterceptionHandlerFactory.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -1,25 +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.spi.handler;
-
-/**
- * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
- */
-public interface InterceptionHandlerFactory<I> {
-
-    InterceptionHandler createFor(I clazz);
-}

Copied: projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/instance/InterceptorInstantiator.java (from rev 106596, projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/handler/InterceptionHandlerFactory.java)
===================================================================
--- projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/instance/InterceptorInstantiator.java	                        (rev 0)
+++ projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/instance/InterceptorInstantiator.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -0,0 +1,25 @@
+/*
+ * 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.spi.instance;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public interface InterceptorInstantiator<I, T> {
+
+    T createFor(I clazz);
+}

Modified: projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/ClassMetadata.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/ClassMetadata.java	2010-07-27 19:06:49 UTC (rev 107122)
+++ projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/ClassMetadata.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -26,14 +26,14 @@
  * 
  * @author Marius Bogoevici
  */
-public interface ClassMetadata extends Serializable
+public interface ClassMetadata<T> extends Serializable
 {
    Iterable<MethodMetadata> getDeclaredMethods();
    
-   Class<?> getJavaClass();
+   Class<T> getJavaClass();
    
    String getClassName();
 
-   ClassMetadata getSuperclass();
+   ClassMetadata<?> getSuperclass();
 
 }

Modified: projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/InterceptorMetadataReader.java
===================================================================
--- projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/InterceptorMetadataReader.java	2010-07-27 19:06:49 UTC (rev 107122)
+++ projects/interceptors/trunk/jboss-interceptor-api/src/main/java/org/jboss/interceptor/spi/metadata/InterceptorMetadataReader.java	2010-07-27 19:56:31 UTC (rev 107123)
@@ -25,7 +25,7 @@
  */
 public interface InterceptorMetadataReader
 {
-   InterceptorMetadata readForInterceptorClass(ClassMetadata clazz);
+   InterceptorMetadata readForInterceptorClass(ClassMetadata<?> clazz);
 
-   InterceptorMetadata readForTargetClass(ClassMetadata clazz);
+   InterceptorMetadata readForTargetClass(ClassMetadata<?> clazz);
 }



More information about the jboss-cvs-commits mailing list