commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jcar...@apache.org
Subject svn commit: r631654 [1/4] - in /commons/proper/proxy/trunk: ./ src/main/java/org/apache/commons/proxy/ src/main/java/org/apache/commons/proxy/exception/ src/main/java/org/apache/commons/proxy/factory/cglib/ src/main/java/org/apache/commons/proxy/factor...
Date Wed, 27 Feb 2008 17:14:48 GMT
Author: jcarman
Date: Wed Feb 27 09:14:32 2008
New Revision: 631654

URL: http://svn.apache.org/viewvc?rev=631654&view=rev
Log:
PROXY-8: Improve Proxy Serialization
Code Formatting

Added:
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/util/AbstractTestCase.java
Modified:
    commons/proper/proxy/trunk/pom.xml
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/Interceptor.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/Invocation.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/Invoker.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/ObjectProvider.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/ProxyFactory.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/ProxyUtils.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/exception/InvokerException.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/exception/ObjectProviderException.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/exception/ProxyFactoryException.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/exception/package.html
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/cglib/CglibProxyFactory.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/cglib/package.html
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistInvocation.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistProxyFactory.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistUtils.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/javassist/package.html
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/AbstractProxyClassGenerator.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/AbstractSubclassingProxyFactory.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/MethodSignature.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/ProxyClassCache.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/ProxyClassGenerator.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/package.html
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/ExecutorInterceptor.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/FilteredInterceptor.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/InterceptorChain.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/LoggingInterceptor.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/MethodFilter.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/MethodInterceptorAdapter.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/SerializingInterceptor.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/filter/PatternFilter.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/filter/ReturnTypeFilter.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/filter/SimpleFilter.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/filter/package.html
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/package.html
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/DuckTypingInvoker.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/InvocationHandlerAdapter.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/NullInvoker.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/XmlRpcInvoker.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/package.html
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/package.html
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/provider/BeanProvider.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/provider/CloningProvider.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/provider/ConstantProvider.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/provider/NullProvider.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/provider/ProviderDecorator.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/provider/SingletonProvider.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/provider/package.html
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/provider/remoting/BurlapProvider.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/provider/remoting/HessianProvider.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/provider/remoting/JaxRpcProvider.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/provider/remoting/RmiProvider.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/provider/remoting/SessionBeanProvider.java
    commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/provider/remoting/package.html
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/TestProxyFactory.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/TestProxyUtils.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/exception/AbstractExceptionClassTestCase.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/exception/TestDelegateProviderException.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/exception/TestInvocationHandlerException.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/exception/TestProxyFactoryException.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/factory/AbstractProxyFactoryTestCase.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/factory/AbstractSubclassingProxyFactoryTestCase.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/factory/cglib/TestCglibProxyFactory.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/factory/javassist/TestJavassistProxyFactory.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/factory/util/TestMethodSignature.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/interceptor/TestExecutorInterceptor.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/interceptor/TestFilteredInterceptor.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/interceptor/TestInterceptorChain.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/interceptor/TestLoggingInterceptor.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/interceptor/TestMethodInterceptorAdapter.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/interceptor/TestSerializingInterceptor.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/interceptor/filter/TestPatternFilter.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/interceptor/filter/TestReturnTypeFilter.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/interceptor/filter/TestSimpleFilter.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/invoker/TestDuckTypingInvoker.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/invoker/TestInvocationHandlerAdapter.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/invoker/TestNullInvoker.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/invoker/TestXmlRpcInvoker.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/provider/CountingProvider.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/provider/TestBeanProvider.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/provider/TestCloningProvider.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/provider/TestConstantProvider.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/provider/TestNullProvider.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/provider/remoting/TestBurlapProvider.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/provider/remoting/TestHessianProvider.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/util/AbstractEcho.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/util/DuplicateEcho.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/util/Echo.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/util/EchoImpl.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/util/QuoteService.java
    commons/proper/proxy/trunk/src/test/java/org/apache/commons/proxy/util/SuffixInterceptor.java

Modified: commons/proper/proxy/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/pom.xml?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/pom.xml (original)
+++ commons/proper/proxy/trunk/pom.xml Wed Feb 27 09:14:32 2008
@@ -213,6 +213,12 @@
             <version>1.3</version>
             <optional>true</optional>
         </dependency>
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>2.3</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <reporting>

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/Interceptor.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/Interceptor.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/Interceptor.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/Interceptor.java Wed Feb 27 09:14:32 2008
@@ -19,11 +19,15 @@
 
 /**
  * "Intercepts" a method invocation.
- * 
+ *
  * @author James Carman
  * @since 1.0
  */
 public interface Interceptor
 {
+//**********************************************************************************************************************
+// Other Methods
+//**********************************************************************************************************************
+
     public Object intercept( Invocation invocation ) throws Throwable;
 }

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/Invocation.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/Invocation.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/Invocation.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/Invocation.java Wed Feb 27 09:14:32 2008
@@ -21,34 +21,41 @@
 
 /**
  * Represents a method invocation.
- * 
+ *
  * @author James Carman
  * @since 1.0
  */
 public interface Invocation
 {
-    /**
-     * Returns the method being called.
-     * @return the method being called
-     */
-    public Method getMethod();
+//**********************************************************************************************************************
+// Other Methods
+//**********************************************************************************************************************
 
     /**
      * Returns the arguments being passed to this method invocation.  Changes in the elements of this array will be
      * propagated to the recipient of this invocation.
-     * 
+     *
      * @return the arguments being passed to this method invocation
      */
     public Object[] getArguments();
 
     /**
+     * Returns the method being called.
+     *
+     * @return the method being called
+     */
+    public Method getMethod();
+
+    /**
      * Returns the proxy object on which this invocation was invoked.
+     *
      * @return the proxy object on which this invocation was invoked
      */
     public Object getProxy();
 
     /**
      * Called in order to let the invocation proceed.
+     *
      * @return the return value of the invocation
      * @throws Throwable any exception or error that was thrown as a result of this invocation
      */

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/Invoker.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/Invoker.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/Invoker.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/Invoker.java Wed Feb 27 09:14:32 2008
@@ -17,21 +17,27 @@
 
 package org.apache.commons.proxy;
 
+import java.io.Serializable;
 import java.lang.reflect.Method;
 
 /**
  * An invoker is responsible for handling a method invocation.
- * 
+ *
  * @author James Carman
  * @since 1.0
  */
-public interface Invoker
+public interface Invoker extends Serializable
 {
+//**********************************************************************************************************************
+// Other Methods
+//**********************************************************************************************************************
+
     /**
      * "Invokes" the method.  Implementation should throw a {@link org.apache.commons.proxy.exception.InvokerException}
      * if problems arise while trying to invoke the method.
-     * @param proxy the proxy object
-     * @param method the method being invoked
+     *
+     * @param proxy     the proxy object
+     * @param method    the method being invoked
      * @param arguments the arguments
      * @return the return value
      * @throws Throwable thrown by the implementation

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/ObjectProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/ObjectProvider.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/ObjectProvider.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/ObjectProvider.java Wed Feb 27 09:14:32 2008
@@ -25,9 +25,9 @@
  */
 public interface ObjectProvider
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Other Methods
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     /**
      * Returns an object.  Implementing classes should throw a

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/ProxyFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/ProxyFactory.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/ProxyFactory.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/ProxyFactory.java Wed Feb 27 09:14:32 2008
@@ -17,6 +17,7 @@
 
 package org.apache.commons.proxy;
 
+import java.io.Serializable;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -24,31 +25,32 @@
 
 /**
  * A <code>ProxyFactory</code> can be used to create three different &quot;flavors&quot; of proxy objects.
- *
+ * <p/>
  * <ul>
- *   <li>Delegator - the proxy will delegate to an object provided by an {@link ObjectProvider}</li>
- *   <li>Interceptor - the proxy will pass each method invocation through an {@link Interceptor}</li>
- *   <li>Invoker - the proxy will allow an {@link Invoker} to handle all method invocations</li>
+ * <li>Delegator - the proxy will delegate to an object provided by an {@link ObjectProvider}</li>
+ * <li>Interceptor - the proxy will pass each method invocation through an {@link Interceptor}</li>
+ * <li>Invoker - the proxy will allow an {@link Invoker} to handle all method invocations</li>
  * </ul>
- *
+ * <p/>
  * <p>
  * Originally, the ProxyFactory class was an interface.  However, to allow for future changes to the
  * class without breaking binary or semantic compatibility, it has been changed to a concrete class.
- *
+ * <p/>
  * </p>
  * <p>
  * <b>Note</b>: This class uses Java reflection.  For more efficient proxies, try using either
  * {@link org.apache.commons.proxy.factory.cglib.CglibProxyFactory CglibProxyFactory} or
  * {@link org.apache.commons.proxy.factory.javassist.JavassistProxyFactory JavassistProxyFactory} instead.
  * </p>
+ *
  * @author James Carman
  * @since 1.0
  */
 public class ProxyFactory
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Other Methods
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     /**
      * Returns true if all <code>proxyClasses</code> are interfaces.
@@ -79,7 +81,7 @@
      */
     public Object createDelegatorProxy( ObjectProvider delegateProvider, Class[] proxyClasses )
     {
-        return createDelegatorProxy( Thread.currentThread().getContextClassLoader(), delegateProvider, proxyClasses );
+        return createDelegatorProxy(Thread.currentThread().getContextClassLoader(), delegateProvider, proxyClasses);
     }
 
     /**
@@ -93,8 +95,8 @@
     public Object createDelegatorProxy( ClassLoader classLoader, ObjectProvider delegateProvider,
                                         Class[] proxyClasses )
     {
-        return Proxy.newProxyInstance( classLoader, proxyClasses,
-                                       new DelegatorInvocationHandler( delegateProvider ) );
+        return Proxy.newProxyInstance(classLoader, proxyClasses,
+                new DelegatorInvocationHandler(delegateProvider));
     }
 
     /**
@@ -110,8 +112,8 @@
     public Object createInterceptorProxy( Object target, Interceptor interceptor,
                                           Class[] proxyClasses )
     {
-        return createInterceptorProxy( Thread.currentThread().getContextClassLoader(), target, interceptor,
-                                       proxyClasses );
+        return createInterceptorProxy(Thread.currentThread().getContextClassLoader(), target, interceptor,
+                proxyClasses);
     }
 
     /**
@@ -129,7 +131,7 @@
                                           Class[] proxyClasses )
     {
         return Proxy
-                .newProxyInstance( classLoader, proxyClasses, new InterceptorInvocationHandler( target, interceptor ) );
+                .newProxyInstance(classLoader, proxyClasses, new InterceptorInvocationHandler(target, interceptor));
     }
 
     /**
@@ -142,8 +144,8 @@
      */
     public Object createInvokerProxy( Invoker invoker, Class[] proxyClasses )
     {
-        return createInvokerProxy( Thread.currentThread().getContextClassLoader(), invoker,
-                                   proxyClasses );
+        return createInvokerProxy(Thread.currentThread().getContextClassLoader(), invoker,
+                proxyClasses);
     }
 
     /**
@@ -157,16 +159,17 @@
     public Object createInvokerProxy( ClassLoader classLoader, Invoker invoker,
                                       Class[] proxyClasses )
     {
-        return Proxy.newProxyInstance( classLoader, proxyClasses, new InvokerInvocationHandler( invoker ) );
+        return Proxy.newProxyInstance(classLoader, proxyClasses, new InvokerInvocationHandler(invoker));
     }
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Inner Classes
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
-    private static class DelegatorInvocationHandler implements InvocationHandler
+    private static class DelegatorInvocationHandler implements InvocationHandler, Serializable
     {
         private final ObjectProvider delegateProvider;
+
         protected DelegatorInvocationHandler( ObjectProvider delegateProvider )
         {
             this.delegateProvider = delegateProvider;
@@ -176,7 +179,7 @@
         {
             try
             {
-                return method.invoke( delegateProvider.getObject(), args );
+                return method.invoke(delegateProvider.getObject(), args);
             }
             catch( InvocationTargetException e )
             {
@@ -185,10 +188,11 @@
         }
     }
 
-    private static class InterceptorInvocationHandler implements InvocationHandler
+    private static class InterceptorInvocationHandler implements InvocationHandler, Serializable
     {
         private final Object target;
         private final Interceptor methodInterceptor;
+
         public InterceptorInvocationHandler( Object target, Interceptor methodInterceptor )
         {
             this.target = target;
@@ -197,16 +201,32 @@
 
         public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable
         {
-            final ReflectionInvocation invocation = new ReflectionInvocation( target, method, args );
-            return methodInterceptor.intercept( invocation );
+            final ReflectionInvocation invocation = new ReflectionInvocation(target, method, args);
+            return methodInterceptor.intercept(invocation);
+        }
+    }
+
+    private static class InvokerInvocationHandler implements InvocationHandler, Serializable
+    {
+        private final Invoker invoker;
+
+        public InvokerInvocationHandler( Invoker invoker )
+        {
+            this.invoker = invoker;
+        }
+
+        public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable
+        {
+            return invoker.invoke(proxy, method, args);
         }
     }
 
-    private static class ReflectionInvocation implements Invocation
+    private static class ReflectionInvocation implements Invocation, Serializable
     {
         private final Method method;
         private final Object[] arguments;
         private final Object target;
+
         public ReflectionInvocation( Object target, Method method, Object[] arguments )
         {
             this.method = method;
@@ -233,26 +253,12 @@
         {
             try
             {
-                return method.invoke( target, arguments );
+                return method.invoke(target, arguments);
             }
             catch( InvocationTargetException e )
             {
                 throw e.getTargetException();
             }
-        }
-    }
-
-    private static class InvokerInvocationHandler implements InvocationHandler
-    {
-        private final Invoker invoker;
-        public InvokerInvocationHandler( Invoker invoker )
-        {
-            this.invoker = invoker;
-        }
-
-        public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable
-        {
-            return invoker.invoke( proxy, method, args );
         }
     }
 }

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/ProxyUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/ProxyUtils.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/ProxyUtils.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/ProxyUtils.java Wed Feb 27 09:14:32 2008
@@ -19,42 +19,43 @@
 
 import org.apache.commons.proxy.invoker.NullInvoker;
 
+import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.HashMap;
 
 /**
  * Provides some helpful proxy utility methods.
- * 
+ *
  * @author James Carman
  * @since 1.0
  */
 public class ProxyUtils
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Fields
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     public static final Object[] EMPTY_ARGUMENTS = new Object[0];
     public static final Class[] EMPTY_ARGUMENT_TYPES = new Class[0];
     private static final Map wrapperClassMap = new HashMap();
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Static Methods
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     static
     {
-        wrapperClassMap.put( Integer.TYPE, Integer.class );
-        wrapperClassMap.put( Character.TYPE, Character.class );
-        wrapperClassMap.put( Boolean.TYPE, Boolean.class );
-        wrapperClassMap.put( Short.TYPE, Short.class );
-        wrapperClassMap.put( Long.TYPE, Long.class );
-        wrapperClassMap.put( Float.TYPE, Float.class );
-        wrapperClassMap.put( Double.TYPE, Double.class );
-        wrapperClassMap.put( Byte.TYPE, Byte.class );
+        wrapperClassMap.put(Integer.TYPE, Integer.class);
+        wrapperClassMap.put(Character.TYPE, Character.class);
+        wrapperClassMap.put(Boolean.TYPE, Boolean.class);
+        wrapperClassMap.put(Short.TYPE, Short.class);
+        wrapperClassMap.put(Long.TYPE, Long.class);
+        wrapperClassMap.put(Float.TYPE, Float.class);
+        wrapperClassMap.put(Double.TYPE, Double.class);
+        wrapperClassMap.put(Byte.TYPE, Byte.class);
     }
+
     /**
      * Creates a "null object" which implements the <code>proxyClasses</code>.
      *
@@ -64,7 +65,7 @@
      */
     public static Object createNullObject( ProxyFactory proxyFactory, Class[] proxyClasses )
     {
-        return proxyFactory.createInvokerProxy( new NullInvoker(), proxyClasses );
+        return proxyFactory.createInvokerProxy(new NullInvoker(), proxyClasses);
     }
 
     /**
@@ -77,7 +78,7 @@
      */
     public static Object createNullObject( ProxyFactory proxyFactory, ClassLoader classLoader, Class[] proxyClasses )
     {
-        return proxyFactory.createInvokerProxy( classLoader, new NullInvoker(), proxyClasses );
+        return proxyFactory.createInvokerProxy(classLoader, new NullInvoker(), proxyClasses);
     }
 
     /**
@@ -97,8 +98,8 @@
      */
     public static Class[] getAllInterfaces( Class cls )
     {
-        final List interfaces = getAllInterfacesImpl( cls, new LinkedList() );
-        return interfaces == null ? null : ( Class[] ) interfaces.toArray( new Class[interfaces.size()] );
+        final List interfaces = getAllInterfacesImpl(cls, new LinkedList());
+        return interfaces == null ? null : ( Class[] ) interfaces.toArray(new Class[interfaces.size()]);
     }
 
     private static List getAllInterfacesImpl( Class cls, List list )
@@ -112,11 +113,11 @@
             Class[] interfaces = cls.getInterfaces();
             for( int i = 0; i < interfaces.length; i++ )
             {
-                if( !list.contains( interfaces[i] ) )
+                if( !list.contains(interfaces[i]) )
                 {
-                    list.add( interfaces[i] );
+                    list.add(interfaces[i]);
                 }
-                getAllInterfacesImpl( interfaces[i], list );
+                getAllInterfacesImpl(interfaces[i], list);
             }
             cls = cls.getSuperclass();
         }
@@ -136,19 +137,20 @@
     {
         if( clazz.isArray() )
         {
-            return getJavaClassName( clazz.getComponentType() ) + "[]";
+            return getJavaClassName(clazz.getComponentType()) + "[]";
         }
         return clazz.getName();
     }
 
     /**
      * Returns the wrapper class for the given primitive type.
+     *
      * @param primitiveType the primitive type
      * @return the wrapper class
      */
     public static Class getWrapperClass( Class primitiveType )
     {
-        return ( Class )wrapperClassMap.get( primitiveType );
+        return ( Class ) wrapperClassMap.get(primitiveType);
     }
 }
 

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/exception/InvokerException.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/exception/InvokerException.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/exception/InvokerException.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/exception/InvokerException.java Wed Feb 27 09:14:32 2008
@@ -25,22 +25,26 @@
  */
 public class InvokerException extends RuntimeException
 {
+//**********************************************************************************************************************
+// Constructors
+//**********************************************************************************************************************
+
     public InvokerException()
     {
     }
 
     public InvokerException( String message )
     {
-        super( message );
+        super(message);
     }
 
     public InvokerException( Throwable cause )
     {
-        super( cause );
+        super(cause);
     }
 
     public InvokerException( String message, Throwable cause )
     {
-        super( message, cause );
+        super(message, cause);
     }
 }

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/exception/ObjectProviderException.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/exception/ObjectProviderException.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/exception/ObjectProviderException.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/exception/ObjectProviderException.java Wed Feb 27 09:14:32 2008
@@ -26,9 +26,9 @@
  */
 public class ObjectProviderException extends RuntimeException
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Constructors
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     public ObjectProviderException()
     {
@@ -36,17 +36,17 @@
 
     public ObjectProviderException( String message )
     {
-        super( message );
+        super(message);
     }
 
     public ObjectProviderException( Throwable cause )
     {
-        super( cause );
+        super(cause);
     }
 
     public ObjectProviderException( String message, Throwable cause )
     {
-        super( message, cause );
+        super(message, cause);
     }
 }
 

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/exception/ProxyFactoryException.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/exception/ProxyFactoryException.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/exception/ProxyFactoryException.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/exception/ProxyFactoryException.java Wed Feb 27 09:14:32 2008
@@ -26,9 +26,9 @@
  */
 public class ProxyFactoryException extends RuntimeException
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Constructors
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     public ProxyFactoryException()
     {
@@ -36,17 +36,17 @@
 
     public ProxyFactoryException( String message )
     {
-        super( message );
+        super(message);
     }
 
     public ProxyFactoryException( Throwable cause )
     {
-        super( cause );
+        super(cause);
     }
 
     public ProxyFactoryException( String message, Throwable cause )
     {
-        super( message, cause );
+        super(message, cause);
     }
 }
 

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/exception/package.html
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/exception/package.html?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/exception/package.html (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/exception/package.html Wed Feb 27 09:14:32 2008
@@ -17,7 +17,7 @@
 <html>
 <body>
 <p>
-This package contains the exception classes used by the primary API.
+    This package contains the exception classes used by the primary API.
 </p>
 </body>
 </html>

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/cglib/CglibProxyFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/cglib/CglibProxyFactory.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/cglib/CglibProxyFactory.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/cglib/CglibProxyFactory.java Wed Feb 27 09:14:32 2008
@@ -22,13 +22,13 @@
 import net.sf.cglib.proxy.Dispatcher;
 import net.sf.cglib.proxy.Enhancer;
 import net.sf.cglib.proxy.MethodProxy;
-import net.sf.cglib.proxy.NoOp;
 import org.apache.commons.proxy.Interceptor;
 import org.apache.commons.proxy.Invocation;
 import org.apache.commons.proxy.Invoker;
 import org.apache.commons.proxy.ObjectProvider;
 import org.apache.commons.proxy.factory.util.AbstractSubclassingProxyFactory;
 
+import java.io.Serializable;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 
@@ -44,97 +44,98 @@
  */
 public class CglibProxyFactory extends AbstractSubclassingProxyFactory
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Fields
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     private static CallbackFilter callbackFilter = new PublicCallbackFilter();
 
-//----------------------------------------------------------------------------------------------------------------------
-// ProxyFactory Implementation
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
+// Other Methods
+//**********************************************************************************************************************
 
     public Object createDelegatorProxy( ClassLoader classLoader, ObjectProvider targetProvider,
                                         Class[] proxyClasses )
     {
         final Enhancer enhancer = new Enhancer();
-        enhancer.setClassLoader( classLoader );
-        enhancer.setInterfaces( toInterfaces( proxyClasses ) );
-        enhancer.setSuperclass( getSuperclass( proxyClasses ) );
-        enhancer.setCallbackFilter( callbackFilter );
-        enhancer.setCallbacks( new Callback[]{ new ObjectProviderDispatcher( targetProvider ), NoOp.INSTANCE } );
-        return enhancer.create();
+        enhancer.setClassLoader(classLoader);
+        enhancer.setInterfaces(toInterfaces(proxyClasses));
+        enhancer.setSuperclass(getSuperclass(proxyClasses));
+        enhancer.setCallbackFilter(callbackFilter);
+        final ProxyObjectDispatcher proxyObjectDispatcher = new ProxyObjectDispatcher();
+        enhancer.setCallbacks(new Callback[] {new ObjectProviderDispatcher(targetProvider), proxyObjectDispatcher});
+        final Object proxy = enhancer.create();
+        proxyObjectDispatcher.setProxyObject(proxy);
+        return proxy;
     }
 
     public Object createInterceptorProxy( ClassLoader classLoader, Object target, Interceptor interceptor,
                                           Class[] proxyClasses )
     {
         final Enhancer enhancer = new Enhancer();
-        enhancer.setClassLoader( classLoader );
-        enhancer.setInterfaces( toInterfaces( proxyClasses ) );
-        enhancer.setSuperclass( getSuperclass( proxyClasses ) );
-        enhancer.setCallbackFilter( callbackFilter );
-        enhancer.setCallbacks( new Callback[]{ new InterceptorBridge( target, interceptor ), NoOp.INSTANCE } );
-        return enhancer.create();
+        enhancer.setClassLoader(classLoader);
+        enhancer.setInterfaces(toInterfaces(proxyClasses));
+        enhancer.setSuperclass(getSuperclass(proxyClasses));
+        enhancer.setCallbackFilter(callbackFilter);
+        final ProxyObjectDispatcher proxyObjectDispatcher = new ProxyObjectDispatcher();
+        enhancer.setCallbacks(new Callback[] {new InterceptorBridge(target, interceptor), proxyObjectDispatcher});
+        final Object proxy = enhancer.create();
+        proxyObjectDispatcher.setProxyObject(proxy);
+        return proxy;
     }
 
     public Object createInvokerProxy( ClassLoader classLoader, Invoker invoker,
                                       Class[] proxyClasses )
     {
         final Enhancer enhancer = new Enhancer();
-        enhancer.setClassLoader( classLoader );
-        enhancer.setInterfaces( toInterfaces( proxyClasses ) );
-        enhancer.setSuperclass( getSuperclass( proxyClasses ) );
-        enhancer.setCallbackFilter( callbackFilter );
-        enhancer.setCallbacks( new Callback[]{ new InvokerBridge( invoker ), NoOp.INSTANCE } );
-        return enhancer.create();
+        enhancer.setClassLoader(classLoader);
+        enhancer.setInterfaces(toInterfaces(proxyClasses));
+        enhancer.setSuperclass(getSuperclass(proxyClasses));
+        enhancer.setCallbackFilter(callbackFilter);
+        final ProxyObjectDispatcher proxyObjectDispatcher = new ProxyObjectDispatcher();
+        enhancer.setCallbacks(new Callback[] {new InvokerBridge(invoker), proxyObjectDispatcher });
+        final Object proxy = enhancer.create();
+        proxyObjectDispatcher.setProxyObject(proxy);
+        return proxy;
     }
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Inner Classes
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
-    private static class PublicCallbackFilter implements CallbackFilter
+    private static class InterceptorBridge implements net.sf.cglib.proxy.MethodInterceptor, Serializable
     {
-        public int accept( Method method )
-        {
-            return Modifier.isPublic( method.getModifiers() ) ? 0 : 1;
-        }
-    }
-
-    private class InvokerBridge implements net.sf.cglib.proxy.InvocationHandler
-    {
-        private final Invoker original;
+        private final Interceptor inner;
+        private final Object target;
 
-        public InvokerBridge( Invoker original )
+        public InterceptorBridge( Object target, Interceptor inner )
         {
-            this.original = original;
+            this.inner = inner;
+            this.target = target;
         }
 
-        public Object invoke( Object object, Method method, Object[] objects ) throws Throwable
+        public Object intercept( Object object, Method method, Object[] args, MethodProxy methodProxy ) throws Throwable
         {
-            return original.invoke( object, method, objects );
+            return inner.intercept(new MethodProxyInvocation(target, method, args, methodProxy));
         }
     }
 
-    private class InterceptorBridge implements net.sf.cglib.proxy.MethodInterceptor
+    private static class InvokerBridge implements net.sf.cglib.proxy.InvocationHandler, Serializable
     {
-        private final Interceptor inner;
-        private final Object target;
+        private final Invoker original;
 
-        public InterceptorBridge( Object target, Interceptor inner )
+        public InvokerBridge( Invoker original )
         {
-            this.inner = inner;
-            this.target = target;
+            this.original = original;
         }
 
-        public Object intercept( Object object, Method method, Object[] args, MethodProxy methodProxy ) throws Throwable
+        public Object invoke( Object object, Method method, Object[] objects ) throws Throwable
         {
-            return inner.intercept( new MethodProxyInvocation( target, method, args, methodProxy ) );
+            return original.invoke(object, method, objects);
         }
     }
 
-    private class MethodProxyInvocation implements Invocation
+    private static class MethodProxyInvocation implements Invocation, Serializable
     {
         private final MethodProxy methodProxy;
         private final Method method;
@@ -161,7 +162,7 @@
 
         public Object proceed() throws Throwable
         {
-            return methodProxy.invoke( target, args );
+            return methodProxy.invoke(target, args);
         }
 
         public Object getProxy()
@@ -170,7 +171,7 @@
         }
     }
 
-    private class ObjectProviderDispatcher implements Dispatcher
+    private static class ObjectProviderDispatcher implements Dispatcher, Serializable
     {
         private final ObjectProvider delegateProvider;
 
@@ -182,6 +183,29 @@
         public Object loadObject()
         {
             return delegateProvider.getObject();
+        }
+    }
+
+    private static class ProxyObjectDispatcher implements Dispatcher, Serializable
+    {
+        private Object proxyObject;
+
+        public void setProxyObject( Object thisObject )
+        {
+            this.proxyObject = thisObject;
+        }
+
+        public Object loadObject() throws Exception
+        {
+            return proxyObject;
+        }
+    }
+
+    private static class PublicCallbackFilter implements CallbackFilter
+    {
+        public int accept( Method method )
+        {
+            return Modifier.isPublic(method.getModifiers()) ? 0 : 1;
         }
     }
 }

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/cglib/package.html
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/cglib/package.html?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/cglib/package.html (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/cglib/package.html Wed Feb 27 09:14:32 2008
@@ -17,7 +17,7 @@
 <html>
 <body>
 <p>
-This package contains the <a href="http://cglib.sourceforge.net/">CGLIB</a>-based
+    This package contains the <a href="http://cglib.sourceforge.net/">CGLIB</a>-based
     <a href="../../ProxyFactory.html">ProxyFactory</a> implementation.
 </p>
 </body>

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistInvocation.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistInvocation.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistInvocation.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistInvocation.java Wed Feb 27 09:14:32 2008
@@ -34,34 +34,35 @@
  * A <a href="http://www.jboss.org/products/javassist">Javassist</a>-based {@link Invocation} implementation.  This
  * class actually serves as the superclass for all <a href="http://www.jboss.org/products/javassist">Javassist</a>-based
  * method invocations.  Subclasses are dynamically created to deal with specific interface methods (they're hard-wired).
- * 
+ *
  * @author James Carman
  * @since 1.0
  */
 public abstract class JavassistInvocation implements Invocation
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Fields
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
+
     private static WeakHashMap loaderToClassCache = new WeakHashMap();
     protected final Method method;
     protected final Object target;
     protected final Object[] arguments;
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Static Methods
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     private static String createCastExpression( Class type, String objectToCast )
     {
         if( !type.isPrimitive() )
         {
-            return "( " + ProxyUtils.getJavaClassName( type ) + " )" + objectToCast;
+            return "( " + ProxyUtils.getJavaClassName(type) + " )" + objectToCast;
         }
         else
         {
-            return "( ( " + ProxyUtils.getWrapperClass( type ).getName() + " )" + objectToCast + " )." +
-                   type.getName() + "Value()";
+            return "( ( " + ProxyUtils.getWrapperClass(type).getName() + " )" + objectToCast + " )." +
+                    type.getName() + "Value()";
         }
     }
 
@@ -70,73 +71,73 @@
     {
         Class invocationClass;
         final CtClass ctClass = JavassistUtils.createClass(
-                getSimpleName( interfaceMethod.getDeclaringClass() ) + "_" + interfaceMethod.getName() +
-                "_invocation",
-                JavassistInvocation.class );
+                getSimpleName(interfaceMethod.getDeclaringClass()) + "_" + interfaceMethod.getName() +
+                        "_invocation",
+                JavassistInvocation.class);
         final CtConstructor constructor = new CtConstructor(
-                JavassistUtils.resolve( new Class[]{ Method.class, Object.class, Object[].class } ),
-                ctClass );
-        constructor.setBody( "{\n\tsuper($$);\n}" );
-        ctClass.addConstructor( constructor );
-        final CtMethod proceedMethod = new CtMethod( JavassistUtils.resolve( Object.class ), "proceed",
-                                                     JavassistUtils.resolve( new Class[0] ), ctClass );
+                JavassistUtils.resolve(new Class[] {Method.class, Object.class, Object[].class}),
+                ctClass);
+        constructor.setBody("{\n\tsuper($$);\n}");
+        ctClass.addConstructor(constructor);
+        final CtMethod proceedMethod = new CtMethod(JavassistUtils.resolve(Object.class), "proceed",
+                JavassistUtils.resolve(new Class[0]), ctClass);
         final Class[] argumentTypes = interfaceMethod.getParameterTypes();
-        final StringBuffer proceedBody = new StringBuffer( "{\n" );
-        if( !Void.TYPE.equals( interfaceMethod.getReturnType() ) )
+        final StringBuffer proceedBody = new StringBuffer("{\n");
+        if( !Void.TYPE.equals(interfaceMethod.getReturnType()) )
         {
-            proceedBody.append( "\treturn " );
+            proceedBody.append("\treturn ");
             if( interfaceMethod.getReturnType().isPrimitive() )
             {
-                proceedBody.append( "new " );
-                proceedBody.append( ProxyUtils.getWrapperClass( interfaceMethod.getReturnType() ).getName() );
-                proceedBody.append( "( " );
+                proceedBody.append("new ");
+                proceedBody.append(ProxyUtils.getWrapperClass(interfaceMethod.getReturnType()).getName());
+                proceedBody.append("( ");
             }
         }
         else
         {
-            proceedBody.append( "\t" );
+            proceedBody.append("\t");
         }
-        proceedBody.append( "( (" );
-        proceedBody.append( ProxyUtils.getJavaClassName( interfaceMethod.getDeclaringClass() ) );
-        proceedBody.append( " )target )." );
-        proceedBody.append( interfaceMethod.getName() );
-        proceedBody.append( "(" );
+        proceedBody.append("( (");
+        proceedBody.append(ProxyUtils.getJavaClassName(interfaceMethod.getDeclaringClass()));
+        proceedBody.append(" )target ).");
+        proceedBody.append(interfaceMethod.getName());
+        proceedBody.append("(");
         for( int i = 0; i < argumentTypes.length; ++i )
         {
             final Class argumentType = argumentTypes[i];
-            proceedBody.append( createCastExpression( argumentType, "arguments[" + i + "]" ) );
+            proceedBody.append(createCastExpression(argumentType, "arguments[" + i + "]"));
             if( i != argumentTypes.length - 1 )
             {
-                proceedBody.append( ", " );
+                proceedBody.append(", ");
             }
         }
-        if( !Void.TYPE.equals( interfaceMethod.getReturnType() ) && interfaceMethod.getReturnType().isPrimitive() )
+        if( !Void.TYPE.equals(interfaceMethod.getReturnType()) && interfaceMethod.getReturnType().isPrimitive() )
         {
-            proceedBody.append( ") );\n" );
+            proceedBody.append(") );\n");
         }
         else
         {
-            proceedBody.append( ");\n" );
+            proceedBody.append(");\n");
         }
-        if( Void.TYPE.equals( interfaceMethod.getReturnType() ) )
+        if( Void.TYPE.equals(interfaceMethod.getReturnType()) )
         {
-            proceedBody.append( "\treturn null;\n" );
+            proceedBody.append("\treturn null;\n");
         }
-        proceedBody.append( "}" );
+        proceedBody.append("}");
         final String body = proceedBody.toString();
-        proceedMethod.setBody( body );
-        ctClass.addMethod( proceedMethod );
-        invocationClass = ctClass.toClass( classLoader );
+        proceedMethod.setBody(body);
+        ctClass.addMethod(proceedMethod);
+        invocationClass = ctClass.toClass(classLoader);
         return invocationClass;
     }
 
     private static Map getClassCache( ClassLoader classLoader )
     {
-        Map cache = ( Map ) loaderToClassCache.get( classLoader );
+        Map cache = ( Map ) loaderToClassCache.get(classLoader);
         if( cache == null )
         {
             cache = new HashMap();
-            loaderToClassCache.put( classLoader, cache );
+            loaderToClassCache.put(classLoader, cache);
         }
         return cache;
     }
@@ -144,23 +145,23 @@
     /**
      * Returns a method invocation class specifically coded to invoke the supplied interface method.
      *
-     * @param classLoader the classloader to use
+     * @param classLoader     the classloader to use
      * @param interfaceMethod the interface method
      * @return a method invocation class specifically coded to invoke the supplied interface method
      * @throws CannotCompileException if a compilation error occurs
      */
     synchronized static Class getMethodInvocationClass( ClassLoader classLoader,
-                                                               Method interfaceMethod )
+                                                        Method interfaceMethod )
             throws CannotCompileException
     {
-        final Map classCache = getClassCache( classLoader );
-        final String key = toClassCacheKey( interfaceMethod );
-        final WeakReference invocationClassRef = ( WeakReference ) classCache.get( key );
+        final Map classCache = getClassCache(classLoader);
+        final String key = toClassCacheKey(interfaceMethod);
+        final WeakReference invocationClassRef = ( WeakReference ) classCache.get(key);
         Class invocationClass;
         if( invocationClassRef == null )
         {
-            invocationClass = createInvocationClass( classLoader, interfaceMethod );
-            classCache.put( key, new WeakReference( invocationClass ) );
+            invocationClass = createInvocationClass(classLoader, interfaceMethod);
+            classCache.put(key, new WeakReference(invocationClass));
         }
         else
         {
@@ -169,8 +170,8 @@
                 invocationClass = ( Class ) invocationClassRef.get();
                 if( invocationClass == null )
                 {
-                    invocationClass = createInvocationClass( classLoader, interfaceMethod );
-                    classCache.put( key, new WeakReference( invocationClass ) );
+                    invocationClass = createInvocationClass(classLoader, interfaceMethod);
+                    classCache.put(key, new WeakReference(invocationClass));
                 }
             }
         }
@@ -180,18 +181,18 @@
     private static String getSimpleName( Class c )
     {
         final String name = c.getName();
-        final int ndx = name.lastIndexOf( '.' );
-        return ndx == -1 ? name : name.substring( ndx + 1 );
+        final int ndx = name.lastIndexOf('.');
+        return ndx == -1 ? name : name.substring(ndx + 1);
     }
 
     private static String toClassCacheKey( Method method )
     {
-        return String.valueOf( method );
+        return String.valueOf(method);
     }
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Constructors
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     public JavassistInvocation( Method method, Object target, Object[] arguments )
     {
@@ -200,9 +201,9 @@
         this.arguments = arguments;
     }
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Invocation Implementation
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     public Object[] getArguments()
     {

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistProxyFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistProxyFactory.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistProxyFactory.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistProxyFactory.java Wed Feb 27 09:14:32 2008
@@ -42,32 +42,49 @@
  */
 public class JavassistProxyFactory extends AbstractSubclassingProxyFactory
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Fields
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
+
+    private static final String GET_METHOD_METHOD_NAME = "_javassistGetMethod";
+
     private static final ProxyClassCache delegatingProxyClassCache = new ProxyClassCache(
-            new DelegatingProxyClassGenerator() );
+            new DelegatingProxyClassGenerator());
     private static final ProxyClassCache interceptorProxyClassCache = new ProxyClassCache(
-            new InterceptorProxyClassGenerator() );
+            new InterceptorProxyClassGenerator());
     private static final ProxyClassCache invocationHandlerProxyClassCache = new ProxyClassCache(
-            new InvokerProxyClassGenerator() );
+            new InvokerProxyClassGenerator());
+
+//**********************************************************************************************************************
+// Static Methods
+//**********************************************************************************************************************
+
+    private static void addGetMethodMethod( CtClass proxyClass ) throws CannotCompileException
+    {
+        final CtMethod method = new CtMethod(JavassistUtils.resolve(Method.class), GET_METHOD_METHOD_NAME,
+                JavassistUtils.resolve(new Class[] {String.class, String.class, Class[].class}), proxyClass);
+        final String body = "try { return Class.forName($1).getMethod($2, $3); } catch( Exception e ) " +
+                "{ throw new RuntimeException(\"Unable to look up method.\", e); }";
+        method.setBody(body);
+        proxyClass.addMethod(method);
+    }
 
-//----------------------------------------------------------------------------------------------------------------------
-// ProxyFactory Implementation
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
+// Other Methods
+//**********************************************************************************************************************
 
     public Object createDelegatorProxy( ClassLoader classLoader, ObjectProvider targetProvider,
                                         Class[] proxyClasses )
     {
         try
         {
-            final Class clazz = delegatingProxyClassCache.getProxyClass( classLoader, proxyClasses );
-            return clazz.getConstructor( new Class[]{ ObjectProvider.class } )
-                    .newInstance( new Object[]{ targetProvider } );
+            final Class clazz = delegatingProxyClassCache.getProxyClass(classLoader, proxyClasses);
+            return clazz.getConstructor(new Class[] {ObjectProvider.class})
+                    .newInstance(new Object[] {targetProvider});
         }
         catch( Exception e )
         {
-            throw new ProxyFactoryException( "Unable to instantiate proxy from generated proxy class.", e );
+            throw new ProxyFactoryException("Unable to instantiate proxy from generated proxy class.", e);
         }
     }
 
@@ -76,14 +93,14 @@
     {
         try
         {
-            final Class clazz = interceptorProxyClassCache.getProxyClass( classLoader, proxyClasses );
-            final Method[] methods = AbstractProxyClassGenerator.getImplementationMethods( proxyClasses );
-            return clazz.getConstructor( new Class[]{ Method[].class, Object.class, Interceptor.class } )
-                    .newInstance( new Object[]{ methods, target, interceptor } );
+            final Class clazz = interceptorProxyClassCache.getProxyClass(classLoader, proxyClasses);
+            final Method[] methods = AbstractProxyClassGenerator.getImplementationMethods(proxyClasses);
+            return clazz.getConstructor(new Class[] {Method[].class, Object.class, Interceptor.class})
+                    .newInstance(new Object[] {methods, target, interceptor});
         }
         catch( Exception e )
         {
-            throw new ProxyFactoryException( "Unable to instantiate proxy class instance.", e );
+            throw new ProxyFactoryException("Unable to instantiate proxy class instance.", e);
         }
     }
 
@@ -92,55 +109,54 @@
     {
         try
         {
-            final Class clazz = invocationHandlerProxyClassCache.getProxyClass( classLoader, proxyClasses );
-            final Method[] methods = AbstractProxyClassGenerator.getImplementationMethods( proxyClasses );
-            return clazz.getConstructor( new Class[]{ Method[].class, Invoker.class } )
-                    .newInstance( new Object[]{ methods, invoker } );
+            final Class clazz = invocationHandlerProxyClassCache.getProxyClass(classLoader, proxyClasses);
+            final Method[] methods = AbstractProxyClassGenerator.getImplementationMethods(proxyClasses);
+            return clazz.getConstructor(new Class[] {Method[].class, Invoker.class})
+                    .newInstance(new Object[] {methods, invoker});
         }
         catch( Exception e )
         {
-            throw new ProxyFactoryException( "Unable to instantiate proxy from generated proxy class.", e );
+            throw new ProxyFactoryException("Unable to instantiate proxy from generated proxy class.", e);
         }
     }
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Inner Classes
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
-    private static class InvokerProxyClassGenerator extends AbstractProxyClassGenerator
+    private static class DelegatingProxyClassGenerator extends AbstractProxyClassGenerator
     {
         public Class generateProxyClass( ClassLoader classLoader, Class[] proxyClasses )
         {
             try
             {
-                final CtClass proxyClass = JavassistUtils.createClass( getSuperclass( proxyClasses ) );
-                final Method[] methods = getImplementationMethods( proxyClasses );
-                JavassistUtils.addInterfaces( proxyClass, toInterfaces( proxyClasses ) );
-                JavassistUtils.addField( Method[].class, "methods", proxyClass );
-                JavassistUtils.addField( Invoker.class, "invoker", proxyClass );
+                final CtClass proxyClass = JavassistUtils.createClass(getSuperclass(proxyClasses));
+                JavassistUtils.addField(ObjectProvider.class, "provider", proxyClass);
                 final CtConstructor proxyConstructor = new CtConstructor(
-                        JavassistUtils.resolve(
-                                new Class[]{ Method[].class, Invoker.class } ),
-                        proxyClass );
-                proxyConstructor
-                        .setBody( "{\n\tthis.methods = $1;\n\tthis.invoker = $2; }" );
-                proxyClass.addConstructor( proxyConstructor );
+                        JavassistUtils.resolve(new Class[] {ObjectProvider.class}),
+                        proxyClass);
+                proxyConstructor.setBody("{ this.provider = $1; }");
+                proxyClass.addConstructor(proxyConstructor);
+                JavassistUtils.addInterfaces(proxyClass, toInterfaces(proxyClasses));
+                final Method[] methods = getImplementationMethods(proxyClasses);
                 for( int i = 0; i < methods.length; ++i )
                 {
-                    final CtMethod method = new CtMethod( JavassistUtils.resolve( methods[i].getReturnType() ),
-                                                          methods[i].getName(),
-                                                          JavassistUtils.resolve( methods[i].getParameterTypes() ),
-                                                          proxyClass );
-                    final String body = "{\n\t return ( $r ) invoker.invoke( this, methods[" + i +
-                                        "], $args );\n }";
-                    method.setBody( body );
-                    proxyClass.addMethod( method );
+                    final Method method = methods[i];
+                    final CtMethod ctMethod = new CtMethod(JavassistUtils.resolve(method.getReturnType()),
+                            method.getName(),
+                            JavassistUtils.resolve(method.getParameterTypes()),
+                            proxyClass);
+                    final String body = "{ return ( $r ) ( ( " + method.getDeclaringClass().getName() +
+                            " )provider.getObject() )." +
+                            method.getName() + "($$); }";
+                    ctMethod.setBody(body);
+                    proxyClass.addMethod(ctMethod);
                 }
-                return proxyClass.toClass( classLoader );
+                return proxyClass.toClass(classLoader);
             }
             catch( CannotCompileException e )
             {
-                throw new ProxyFactoryException( "Could not compile class.", e );
+                throw new ProxyFactoryException("Could not compile class.", e);
             }
         }
     }
@@ -151,77 +167,78 @@
         {
             try
             {
-                final CtClass proxyClass = JavassistUtils.createClass( getSuperclass( proxyClasses ) );
-                final Method[] methods = getImplementationMethods( proxyClasses );
-                JavassistUtils.addInterfaces( proxyClass, toInterfaces( proxyClasses ) );
-                JavassistUtils.addField( Method[].class, "methods", proxyClass );
-                JavassistUtils.addField( Object.class, "target", proxyClass );
-                JavassistUtils.addField( Interceptor.class, "interceptor", proxyClass );
+                final CtClass proxyClass = JavassistUtils.createClass(getSuperclass(proxyClasses));
+                final Method[] methods = getImplementationMethods(proxyClasses);
+                JavassistUtils.addInterfaces(proxyClass, toInterfaces(proxyClasses));
+                JavassistUtils.addField(Object.class, "target", proxyClass);
+                JavassistUtils.addField(Interceptor.class, "interceptor", proxyClass);
+                addGetMethodMethod(proxyClass);
                 final CtConstructor proxyConstructor = new CtConstructor(
                         JavassistUtils.resolve(
-                                new Class[]{ Method[].class, Object.class, Interceptor.class } ),
-                        proxyClass );
+                                new Class[] {Method[].class, Object.class, Interceptor.class}),
+                        proxyClass);
                 proxyConstructor
                         .setBody(
-                                "{\n\tthis.methods = $1;\n\tthis.target = $2;\n\tthis.interceptor = $3; }" );
-                proxyClass.addConstructor( proxyConstructor );
+                                "{\n\tthis.target = $2;\n\tthis.interceptor = $3; }");
+                proxyClass.addConstructor(proxyConstructor);
                 for( int i = 0; i < methods.length; ++i )
                 {
-                    final CtMethod method = new CtMethod( JavassistUtils.resolve( methods[i].getReturnType() ),
-                                                          methods[i].getName(),
-                                                          JavassistUtils.resolve( methods[i].getParameterTypes() ),
-                                                          proxyClass );
+                    final CtMethod method = new CtMethod(JavassistUtils.resolve(methods[i].getReturnType()),
+                            methods[i].getName(),
+                            JavassistUtils.resolve(methods[i].getParameterTypes()),
+                            proxyClass);
                     final Class invocationClass = JavassistInvocation
-                            .getMethodInvocationClass( classLoader, methods[i] );
-                    final String body = "{\n\t return ( $r ) interceptor.intercept( new " + invocationClass.getName() +
-                                        "( methods[" + i + "], target, $args ) );\n }";
-                    method.setBody( body );
-                    proxyClass.addMethod( method );
+                            .getMethodInvocationClass(classLoader, methods[i]);
 
+                    final String body = "{\n\t return ( $r ) interceptor.intercept( new " + invocationClass.getName() +
+                            "( " + GET_METHOD_METHOD_NAME + "(\"" + methods[i].getDeclaringClass().getName() +
+                            "\", \"" + methods[i].getName() + "\", $sig), target, $args ) );\n }";
+                    method.setBody(body);
+                    proxyClass.addMethod(method);
                 }
-                return proxyClass.toClass( classLoader );
+                return proxyClass.toClass(classLoader);
             }
             catch( CannotCompileException e )
             {
-                throw new ProxyFactoryException( "Could not compile class.", e );
+                throw new ProxyFactoryException("Could not compile class.", e);
             }
         }
     }
 
-    private static class DelegatingProxyClassGenerator extends AbstractProxyClassGenerator
+    private static class InvokerProxyClassGenerator extends AbstractProxyClassGenerator
     {
         public Class generateProxyClass( ClassLoader classLoader, Class[] proxyClasses )
         {
             try
             {
-                final CtClass proxyClass = JavassistUtils.createClass( getSuperclass( proxyClasses ) );
-                JavassistUtils.addField( ObjectProvider.class, "provider", proxyClass );
+                final CtClass proxyClass = JavassistUtils.createClass(getSuperclass(proxyClasses));
+                final Method[] methods = getImplementationMethods(proxyClasses);
+                JavassistUtils.addInterfaces(proxyClass, toInterfaces(proxyClasses));
+                JavassistUtils.addField(Method[].class, "methods", proxyClass);
+                JavassistUtils.addField(Invoker.class, "invoker", proxyClass);
                 final CtConstructor proxyConstructor = new CtConstructor(
-                        JavassistUtils.resolve( new Class[]{ ObjectProvider.class } ),
-                        proxyClass );
-                proxyConstructor.setBody( "{ this.provider = $1; }" );
-                proxyClass.addConstructor( proxyConstructor );
-                JavassistUtils.addInterfaces( proxyClass, toInterfaces( proxyClasses ) );
-                final Method[] methods = getImplementationMethods( proxyClasses );
+                        JavassistUtils.resolve(
+                                new Class[] {Method[].class, Invoker.class}),
+                        proxyClass);
+                proxyConstructor
+                        .setBody("{\n\tthis.methods = $1;\n\tthis.invoker = $2; }");
+                proxyClass.addConstructor(proxyConstructor);
                 for( int i = 0; i < methods.length; ++i )
                 {
-                    final Method method = methods[i];
-                    final CtMethod ctMethod = new CtMethod( JavassistUtils.resolve( method.getReturnType() ),
-                                                            method.getName(),
-                                                            JavassistUtils.resolve( method.getParameterTypes() ),
-                                                            proxyClass );
-                    final String body = "{ return ( $r ) ( ( " + method.getDeclaringClass().getName() +
-                                        " )provider.getObject() )." +
-                                        method.getName() + "($$); }";
-                    ctMethod.setBody( body );
-                    proxyClass.addMethod( ctMethod );
-
+                    final CtMethod method = new CtMethod(JavassistUtils.resolve(methods[i].getReturnType()),
+                            methods[i].getName(),
+                            JavassistUtils.resolve(methods[i].getParameterTypes()),
+                            proxyClass);
+                    final String body = "{\n\t return ( $r ) invoker.invoke( this, methods[" + i +
+                            "], $args );\n }";
+                    method.setBody(body);
+                    proxyClass.addMethod(method);
                 }
-                return proxyClass.toClass( classLoader );
+                return proxyClass.toClass(classLoader);
             }
             catch( CannotCompileException e )
             {
-                throw new ProxyFactoryException( "Could not compile class.", e );
+                throw new ProxyFactoryException("Could not compile class.", e);
             }
         }
     }

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistUtils.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistUtils.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistUtils.java Wed Feb 27 09:14:32 2008
@@ -31,75 +31,49 @@
 
 /**
  * Some utility methods for dealing with Javassist.  This class is not part of the public API!
- * 
+ *
  * @author James Carman
  * @since 1.0
  */
 class JavassistUtils
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Fields
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
+
     public static final String DEFAULT_BASE_NAME = "JavassistUtilsGenerated";
     private static int classNumber = 0;
     private static final ClassPool classPool = new ClassPool();
 
+    private static final Set classLoaders = new HashSet();
+
+//**********************************************************************************************************************
+// Static Methods
+//**********************************************************************************************************************
+
     static
     {
-        classPool.appendClassPath( new LoaderClassPath( ClassLoader.getSystemClassLoader() ) );
+        classPool.appendClassPath(new LoaderClassPath(ClassLoader.getSystemClassLoader()));
     }
 
-    private static final Set classLoaders = new HashSet();
-//----------------------------------------------------------------------------------------------------------------------
-// Static Methods
-//----------------------------------------------------------------------------------------------------------------------
-
     /**
      * Adds a field to a class.
-     * 
-     * @param fieldType the field's type
-     * @param fieldName the field name
-     * @param enclosingClass the class receiving the new field 
+     *
+     * @param fieldType      the field's type
+     * @param fieldName      the field name
+     * @param enclosingClass the class receiving the new field
      * @throws CannotCompileException if a compilation problem occurs
      */
     public static void addField( Class fieldType, String fieldName, CtClass enclosingClass )
             throws CannotCompileException
     {
-        enclosingClass.addField( new CtField( resolve( fieldType ), fieldName, enclosingClass ) );
-    }
-
-    /**
-     * Finds the {@link CtClass} corresponding to the Java {@link Class} passed in.
-     * 
-     * @param clazz the Java {@link Class}
-     * @return the {@link CtClass}
-     */
-    public static CtClass resolve( Class clazz )
-    {
-        synchronized( classLoaders )
-        {
-            try
-            {
-                final ClassLoader loader = clazz.getClassLoader();
-                if( loader != null && !classLoaders.contains( loader ) )
-                {
-                    classLoaders.add( loader );
-                    classPool.appendClassPath( new LoaderClassPath( loader ) );
-                }
-                return classPool.get( ProxyUtils.getJavaClassName( clazz ) );
-            }
-            catch( NotFoundException e )
-            {
-                throw new ObjectProviderException(
-                        "Unable to find class " + clazz.getName() + " in default Javassist class pool.", e );
-            }
-        }
+        enclosingClass.addField(new CtField(resolve(fieldType), fieldName, enclosingClass));
     }
 
     /**
      * Adds interfaces to a {@link CtClass}
-     * 
-     * @param ctClass the {@link CtClass}
+     *
+     * @param ctClass      the {@link CtClass}
      * @param proxyClasses the interfaces
      */
     public static void addInterfaces( CtClass ctClass, Class[] proxyClasses )
@@ -107,36 +81,64 @@
         for( int i = 0; i < proxyClasses.length; i++ )
         {
             Class proxyInterface = proxyClasses[i];
-            ctClass.addInterface( resolve( proxyInterface ) );
+            ctClass.addInterface(resolve(proxyInterface));
         }
     }
 
     /**
      * Creates a new {@link CtClass} derived from the Java {@link Class} using the default base name.
-     * 
+     *
      * @param superclass the superclass
      * @return the new derived {@link CtClass}
      */
     public static CtClass createClass( Class superclass )
     {
-        return createClass( DEFAULT_BASE_NAME, superclass );
+        return createClass(DEFAULT_BASE_NAME, superclass);
     }
 
     /**
      * Creates a new {@link CtClass} derived from the Java {@link Class} using the supplied base name.
-     * 
-     * @param baseName the base name
+     *
+     * @param baseName   the base name
      * @param superclass the superclass
      * @return the new derived {@link CtClass}
      */
     public synchronized static CtClass createClass( String baseName, Class superclass )
     {
-        return classPool.makeClass( baseName + "_" + classNumber++, resolve( superclass ) );
+        return classPool.makeClass(baseName + "_" + classNumber++, resolve(superclass));
+    }
+
+    /**
+     * Finds the {@link CtClass} corresponding to the Java {@link Class} passed in.
+     *
+     * @param clazz the Java {@link Class}
+     * @return the {@link CtClass}
+     */
+    public static CtClass resolve( Class clazz )
+    {
+        synchronized( classLoaders )
+        {
+            try
+            {
+                final ClassLoader loader = clazz.getClassLoader();
+                if( loader != null && !classLoaders.contains(loader) )
+                {
+                    classLoaders.add(loader);
+                    classPool.appendClassPath(new LoaderClassPath(loader));
+                }
+                return classPool.get(ProxyUtils.getJavaClassName(clazz));
+            }
+            catch( NotFoundException e )
+            {
+                throw new ObjectProviderException(
+                        "Unable to find class " + clazz.getName() + " in default Javassist class pool.", e);
+            }
+        }
     }
 
     /**
      * Resolves an array of Java {@link Class}es to an array of their corresponding {@link CtClass}es.
-     * 
+     *
      * @param classes the Java {@link Class}es
      * @return the corresponding {@link CtClass}es
      */
@@ -145,7 +147,7 @@
         final CtClass[] ctClasses = new CtClass[classes.length];
         for( int i = 0; i < ctClasses.length; ++i )
         {
-            ctClasses[i] = resolve( classes[i] );
+            ctClasses[i] = resolve(classes[i]);
         }
         return ctClasses;
     }

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/javassist/package.html
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/javassist/package.html?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/javassist/package.html (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/javassist/package.html Wed Feb 27 09:14:32 2008
@@ -18,7 +18,7 @@
 <html>
 <body>
 <p>
-This package contains the <a href="http://www.jboss.org/products/javassist">Javassist</a>-based
+    This package contains the <a href="http://www.jboss.org/products/javassist">Javassist</a>-based
     <a href="../../ProxyFactory.html">ProxyFactory</a> implementation.
 </p>
 </body>

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/AbstractProxyClassGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/AbstractProxyClassGenerator.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/AbstractProxyClassGenerator.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/AbstractProxyClassGenerator.java Wed Feb 27 09:14:32 2008
@@ -34,9 +34,9 @@
  */
 public abstract class AbstractProxyClassGenerator implements ProxyClassGenerator
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Static Methods
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     /**
      * Returns all methods that a proxy class must implement from the proxy interfaces.  This method makes sure there
@@ -56,14 +56,14 @@
             final Method[] methods = proxyInterface.getMethods();
             for( int j = 0; j < methods.length; j++ )
             {
-                final MethodSignature signature = new MethodSignature( methods[j] );
-                if( Modifier.isFinal( methods[j].getModifiers() ) )
+                final MethodSignature signature = new MethodSignature(methods[j]);
+                if( Modifier.isFinal(methods[j].getModifiers()) )
                 {
-                    finalizedSignatures.add( signature );
+                    finalizedSignatures.add(signature);
                 }
-                else if( !signatureMethodMap.containsKey( signature ) )
+                else if( !signatureMethodMap.containsKey(signature) )
                 {
-                    signatureMethodMap.put( signature, methods[j] );
+                    signatureMethodMap.put(signature, methods[j]);
                 }
             }
         }
@@ -71,9 +71,9 @@
         for( Iterator i = finalizedSignatures.iterator(); i.hasNext(); )
         {
             MethodSignature signature = ( MethodSignature ) i.next();
-            resultingMethods.remove( signatureMethodMap.get( signature ) );
+            resultingMethods.remove(signatureMethodMap.get(signature));
         }
-        return ( Method[] ) resultingMethods.toArray( new Method[resultingMethods.size()] );
+        return ( Method[] ) resultingMethods.toArray(new Method[resultingMethods.size()]);
     }
 }
 



Mime
View raw message