[jboss-cvs] JBossAS SVN: r94326 - projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Oct 5 00:15:04 EDT 2009


Author: marius.bogoevici
Date: 2009-10-05 00:15:04 -0400 (Mon, 05 Oct 2009)
New Revision: 94326

Modified:
   projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreatorImpl.java
Log:
Allow for proxification of classes with multi-argument constructors.

Modified: projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreatorImpl.java
===================================================================
--- projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreatorImpl.java	2009-10-05 01:52:38 UTC (rev 94325)
+++ projects/interceptors/trunk/src/main/java/org/jboss/interceptor/proxy/InterceptorProxyCreatorImpl.java	2009-10-05 04:15:04 UTC (rev 94326)
@@ -19,6 +19,7 @@
 
 import javassist.util.proxy.MethodHandler;
 import javassist.util.proxy.ProxyFactory;
+import javassist.util.proxy.ProxyObject;
 import org.jboss.interceptor.model.InterceptionType;
 import org.jboss.interceptor.model.InterceptorClassMetadata;
 import org.jboss.interceptor.registry.InterceptorRegistry;
@@ -28,8 +29,11 @@
 
 import javax.interceptor.AroundInvoke;
 import java.lang.reflect.Method;
+import java.lang.reflect.Constructor;
 import java.util.*;
 
+import sun.reflect.ReflectionFactory;
+
 /**
  * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
  */
@@ -57,11 +61,19 @@
 
       proxyFactory.setInterfaces(new Class<?>[]{LifecycleMixin.class});
 
-      proxyFactory.setHandler(new InstanceProxifyingMethodHandler(target, proxyClass, interceptorRegistry));
+      InstanceProxifyingMethodHandler instanceProxifyingMethodHandler = new InstanceProxifyingMethodHandler(target, proxyClass, interceptorRegistry);
+      proxyFactory.setHandler(instanceProxifyingMethodHandler);
 
       try
       {
-         return (T) proxyFactory.create(constructorTypes, constructorArguments);
+         //return (T) proxyFactory.create(constructorTypes, constructorArguments);
+
+         Class<T> clazz = proxyFactory.createClass();
+         ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory();
+         Constructor<T> c = reflectionFactory.newConstructorForSerialization(clazz, Object.class.getDeclaredConstructor());
+         T proxyObject = c.newInstance();
+         ((ProxyObject)proxyObject).setHandler(instanceProxifyingMethodHandler);
+         return proxyObject;
       } catch (Exception e)
       {
          throw new InterceptorException(e);




More information about the jboss-cvs-commits mailing list