You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by jc...@apache.org on 2008/02/27 18:14:48 UTC

svn commit: r631654 [2/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...

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/AbstractSubclassingProxyFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/AbstractSubclassingProxyFactory.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/AbstractSubclassingProxyFactory.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/AbstractSubclassingProxyFactory.java Wed Feb 27 09:14:32 2008
@@ -20,6 +20,7 @@
 import org.apache.commons.proxy.ProxyFactory;
 import org.apache.commons.proxy.exception.ProxyFactoryException;
 
+import java.io.Serializable;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Modifier;
 import java.util.Collection;
@@ -28,15 +29,61 @@
 
 /**
  * A useful superclass for a {@link ProxyFactory} which supports subclassing rather than merely implementing interfaces.
- * 
+ *
  * @author James Carman
  * @since 1.0
  */
 public abstract class AbstractSubclassingProxyFactory extends ProxyFactory
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Static Methods
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
+
+    /**
+     * Returns either {@link Object} if all of the <code>proxyClasses</code> are interfaces or the single non-interface
+     * class from <code>proxyClasses</code>.
+     *
+     * @param proxyClasses the proxy classes
+     * @return either {@link Object} if all of the <code>proxyClasses</code> are interfaces or the single non-interface
+     *         class from <code>proxyClasses</code>
+     * @throws ProxyFactoryException if multiple non-interface classes are contained in <code>proxyClasses</code> or any
+     *                               of the non-interface classes are final
+     */
+    public static Class getSuperclass( Class[] proxyClasses )
+    {
+        final Class[] superclasses = toNonInterfaces(proxyClasses);
+        switch( superclasses.length )
+        {
+            case 0:
+                return Object.class;
+            case 1:
+                final Class superclass = superclasses[0];
+                if( Modifier.isFinal(superclass.getModifiers()) )
+                {
+                    throw new ProxyFactoryException(
+                            "Proxy class cannot extend " + superclass.getName() + " as it is final.");
+                }
+                if( !hasSuitableDefaultConstructor(superclass) )
+                {
+                    throw new ProxyFactoryException("Proxy class cannot extend " + superclass.getName() +
+                            ", because it has no visible \"default\" constructor.");
+                }
+                return superclass;
+            default:
+                final StringBuffer errorMessage = new StringBuffer("Proxy class cannot extend ");
+                for( int i = 0; i < superclasses.length; i++ )
+                {
+                    Class c = superclasses[i];
+                    errorMessage.append(c.getName());
+                    if( i != superclasses.length - 1 )
+                    {
+                        errorMessage.append(", ");
+                    }
+                }
+                errorMessage.append("; multiple inheritance not allowed.");
+                throw new ProxyFactoryException(errorMessage.toString());
+        }
+    }
 
     private static boolean hasSuitableDefaultConstructor( Class superclass )
     {
@@ -44,8 +91,8 @@
         for( int i = 0; i < declaredConstructors.length; i++ )
         {
             Constructor constructor = declaredConstructors[i];
-            if( constructor.getParameterTypes().length == 0 && ( Modifier.isPublic( constructor.getModifiers() ) ||
-                                                                 Modifier.isProtected( constructor.getModifiers() ) ) )
+            if( constructor.getParameterTypes().length == 0 && ( Modifier.isPublic(constructor.getModifiers()) ||
+                    Modifier.isProtected(constructor.getModifiers()) ) )
             {
                 return true;
             }
@@ -54,7 +101,32 @@
     }
 
     /**
+     * Helper method for instantiating a proxy object from its proxy class.  Uses the default constructor.
+     *
+     * @param proxyClass the proxy class
+     * @return a proxy object
+     */
+    protected static Object instantiate( Class proxyClass )
+    {
+        try
+        {
+            return proxyClass.newInstance();
+        }
+        catch( InstantiationException e )
+        {
+            throw new ProxyFactoryException("Unable to instantiate proxy object from proxy class.", e);
+        }
+        catch( IllegalAccessException e )
+        {
+            throw new ProxyFactoryException("Unable to instantiate proxy object from proxy class.", e);
+        }
+    }
+
+    /**
      * Returns the <code>proxyClasses</code> transformed into an array of only the interface classes.
+     * <p/>
+     * <b>Note</b>: This class will append {@link Serializable} to the end of the list if it's
+     * not found!
      *
      * @param proxyClasses the proxy classes
      * @return the <code>proxyClasses</code> transformed into an array of only the interface classes
@@ -62,15 +134,21 @@
     protected static Class[] toInterfaces( Class[] proxyClasses )
     {
         final Collection interfaces = new LinkedList();
+        boolean serializableFound = false;
         for( int i = 0; i < proxyClasses.length; i++ )
         {
             Class proxyInterface = proxyClasses[i];
             if( proxyInterface.isInterface() )
             {
-                interfaces.add( proxyInterface );
+                interfaces.add(proxyInterface);
             }
+            serializableFound |= ( Serializable.class.equals(proxyInterface) );
         }
-        return ( Class[] ) interfaces.toArray( new Class[interfaces.size()] );
+        if( !serializableFound )
+        {
+            interfaces.add(Serializable.class);
+        }
+        return ( Class[] ) interfaces.toArray(new Class[interfaces.size()]);
     }
 
     private static Class[] toNonInterfaces( Class[] proxyClasses )
@@ -81,15 +159,15 @@
             Class proxyClass = proxyClasses[i];
             if( !proxyClass.isInterface() )
             {
-                superclasses.add( proxyClass );
+                superclasses.add(proxyClass);
             }
         }
-        return ( Class[] ) superclasses.toArray( new Class[superclasses.size()] );
+        return ( Class[] ) superclasses.toArray(new Class[superclasses.size()]);
     }
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Other Methods
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     /**
      * Returns true if a suitable superclass can be found, given the desired <code>proxyClasses</code>.
@@ -101,79 +179,12 @@
     {
         try
         {
-            getSuperclass( proxyClasses );
+            getSuperclass(proxyClasses);
             return true;
         }
         catch( ProxyFactoryException e )
         {
             return false;
-        }
-    }
-
-    /**
-     * Returns either {@link Object} if all of the <code>proxyClasses</code> are interfaces or the single non-interface
-     * class from <code>proxyClasses</code>.
-     *
-     * @param proxyClasses the proxy classes
-     * @return either {@link Object} if all of the <code>proxyClasses</code> are interfaces or the single non-interface
-     *         class from <code>proxyClasses</code>
-     * @throws ProxyFactoryException if multiple non-interface classes are contained in <code>proxyClasses</code> or any
-     *                               of the non-interface classes are final
-     */
-    public static Class getSuperclass( Class[] proxyClasses )
-    {
-        final Class[] superclasses = toNonInterfaces( proxyClasses );
-        switch( superclasses.length )
-        {
-            case 0:
-                return Object.class;
-            case 1:
-                final Class superclass = superclasses[0];
-                if( Modifier.isFinal( superclass.getModifiers() ) )
-                {
-                    throw new ProxyFactoryException(
-                            "Proxy class cannot extend " + superclass.getName() + " as it is final." );
-                }
-                if( !hasSuitableDefaultConstructor( superclass ) )
-                {
-                    throw new ProxyFactoryException( "Proxy class cannot extend " + superclass.getName() +
-                                                     ", because it has no visible \"default\" constructor." );
-                }
-                return superclass;
-            default:
-                final StringBuffer errorMessage = new StringBuffer( "Proxy class cannot extend " );
-                for( int i = 0; i < superclasses.length; i++ )
-                {
-                    Class c = superclasses[i];
-                    errorMessage.append( c.getName() );
-                    if( i != superclasses.length - 1 )
-                    {
-                        errorMessage.append( ", " );
-                    }
-                }
-                errorMessage.append( "; multiple inheritance not allowed." );
-                throw new ProxyFactoryException( errorMessage.toString() );
-        }
-    }
-
-    /**
-     * Helper method for instantiating a proxy object from its proxy class.  Uses the default constructor.
-     * @param proxyClass the proxy class
-     * @return a proxy object
-     */
-    protected static Object instantiate(Class proxyClass)
-    {
-        try
-        {
-            return proxyClass.newInstance();
-        }
-        catch (InstantiationException e)
-        {
-            throw new ProxyFactoryException("Unable to instantiate proxy object from proxy class.", e);
-        }
-        catch (IllegalAccessException e)
-        {
-            throw new ProxyFactoryException("Unable to instantiate proxy object from proxy class.", e);
         }
     }
 }

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/MethodSignature.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/MethodSignature.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/MethodSignature.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/MethodSignature.java Wed Feb 27 09:14:32 2008
@@ -23,32 +23,32 @@
 
 /**
  * A class for capturing the signature of a method (its name and parameter types).
- * 
+ *
  * @author James Carman
  * @since 1.0
  */
 public class MethodSignature
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Fields
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     private final String name;
     private final List parameterTypes;
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Constructors
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     public MethodSignature( Method method )
     {
         this.name = method.getName();
-        this.parameterTypes = Arrays.asList( method.getParameterTypes() );
+        this.parameterTypes = Arrays.asList(method.getParameterTypes());
     }
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Canonical Methods
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     public boolean equals( Object o )
     {
@@ -61,11 +61,11 @@
             return false;
         }
         final MethodSignature that = ( MethodSignature ) o;
-        if( !name.equals( that.name ) )
+        if( !name.equals(that.name) )
         {
             return false;
         }
-        if( !parameterTypes.equals( that.parameterTypes ) )
+        if( !parameterTypes.equals(that.parameterTypes) )
         {
             return false;
         }

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/ProxyClassCache.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/ProxyClassCache.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/ProxyClassCache.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/ProxyClassCache.java Wed Feb 27 09:14:32 2008
@@ -32,85 +32,85 @@
  */
 public class ProxyClassCache
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Fields
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     private final Map loaderToClassCache = new WeakHashMap();
     private final ProxyClassGenerator proxyClassGenerator;
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Constructors
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     public ProxyClassCache( ProxyClassGenerator proxyClassGenerator )
     {
         this.proxyClassGenerator = proxyClassGenerator;
     }
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Other Methods
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
+
+    private Map getClassCache( ClassLoader classLoader )
+    {
+        Map cache = ( Map ) loaderToClassCache.get(classLoader);
+        if( cache == null )
+        {
+            cache = new HashMap();
+            loaderToClassCache.put(classLoader, cache);
+        }
+        return cache;
+    }
+
+    private String toClassCacheKey( Class[] proxyClasses )
+    {
+        final StringBuffer sb = new StringBuffer();
+        for( int i = 0; i < proxyClasses.length; i++ )
+        {
+            Class proxyInterface = proxyClasses[i];
+            sb.append(proxyInterface.getName());
+            if( i != proxyClasses.length - 1 )
+            {
+                sb.append(",");
+            }
+        }
+        return sb.toString();
+    }
 
     /**
      * Returns the proxy class generated by the {@link ProxyClassGenerator} using the specified {@link ClassLoader} and
      * array of proxy classes.
-     * 
-     * @param classLoader the classloader
+     *
+     * @param classLoader  the classloader
      * @param proxyClasses the proxy classes
      * @return the proxy class generated by the {@link ProxyClassGenerator} using the specified {@link ClassLoader} and
-     * array of proxy classes
+     *         array of proxy classes
      */
     public synchronized Class getProxyClass( ClassLoader classLoader, Class[] proxyClasses )
     {
-        final Map classCache = getClassCache( classLoader );
-        final String key = toClassCacheKey( proxyClasses );
+        final Map classCache = getClassCache(classLoader);
+        final String key = toClassCacheKey(proxyClasses);
         Class proxyClass;
-        WeakReference proxyClassReference = ( WeakReference )classCache.get( key );
+        WeakReference proxyClassReference = ( WeakReference ) classCache.get(key);
         if( proxyClassReference == null )
         {
-            proxyClass = proxyClassGenerator.generateProxyClass( classLoader, proxyClasses );
-            classCache.put( key, new WeakReference( proxyClass ) );
+            proxyClass = proxyClassGenerator.generateProxyClass(classLoader, proxyClasses);
+            classCache.put(key, new WeakReference(proxyClass));
         }
         else
         {
             synchronized( proxyClassReference )
             {
-                proxyClass = ( Class )proxyClassReference.get();
+                proxyClass = ( Class ) proxyClassReference.get();
                 if( proxyClass == null )
                 {
-                    proxyClass = proxyClassGenerator.generateProxyClass( classLoader, proxyClasses );
-                    classCache.put( key, new WeakReference( proxyClass ) );
+                    proxyClass = proxyClassGenerator.generateProxyClass(classLoader, proxyClasses);
+                    classCache.put(key, new WeakReference(proxyClass));
                 }
             }
         }
         return proxyClass;
-    }
-
-    private Map getClassCache( ClassLoader classLoader )
-    {
-        Map cache = ( Map )loaderToClassCache.get( classLoader );
-        if( cache == null )
-        {
-            cache = new HashMap();
-            loaderToClassCache.put( classLoader, cache );
-        }
-        return cache;
-    }
-
-    private String toClassCacheKey( Class[] proxyClasses )
-    {
-        final StringBuffer sb = new StringBuffer();
-        for( int i = 0; i < proxyClasses.length; i++ )
-        {
-            Class proxyInterface = proxyClasses[i];
-            sb.append( proxyInterface.getName() );
-            if( i != proxyClasses.length - 1 )
-            {
-                sb.append( "," );
-            }
-        }
-        return sb.toString();
     }
 }
 

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/ProxyClassGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/ProxyClassGenerator.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/ProxyClassGenerator.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/ProxyClassGenerator.java Wed Feb 27 09:14:32 2008
@@ -19,19 +19,20 @@
 
 /**
  * A proxy class generator generates specific type of proxies (interceptor, invoker, etc.).
- * 
+ *
  * @author James Carman
  * @since 1.0
  */
 public interface ProxyClassGenerator
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Other Methods
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     /**
      * Generates a proxy class for the supplied {@link ClassLoader} and proxy classes.
-     * @param classLoader the classloader
+     *
+     * @param classLoader  the classloader
      * @param proxyClasses the proxy classes
      * @return the dynamically generated proxy class
      */

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/package.html
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/package.html?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/package.html (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/factory/util/package.html Wed Feb 27 09:14:32 2008
@@ -14,11 +14,11 @@
   ~ See the License for the specific language governing permissions and
   ~ limitations under the License.
   -->
-        
+
 <html>
 <body>
 <p>
-This package contains some classes useful for writing your own <a href="../../ProxyFactory.html">ProxyFactory</a>
+    This package contains some classes useful for writing your own <a href="../../ProxyFactory.html">ProxyFactory</a>
     implementation.
 </p>
 </body>

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/ExecutorInterceptor.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/ExecutorInterceptor.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/ExecutorInterceptor.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/ExecutorInterceptor.java Wed Feb 27 09:14:32 2008
@@ -18,8 +18,8 @@
 package org.apache.commons.proxy.interceptor;
 
 import EDU.oswego.cs.dl.util.concurrent.Executor;
-import org.apache.commons.proxy.Invocation;
 import org.apache.commons.proxy.Interceptor;
+import org.apache.commons.proxy.Invocation;
 
 /**
  * A method interceptor that uses an {@link Executor} to execute the method invocation.
@@ -28,34 +28,48 @@
  * methods will result in an {@link IllegalArgumentException}.  If the proxy interfaces include non-void methods, try
  * using a {@link FilteredInterceptor} along with a
  * {@link org.apache.commons.proxy.interceptor.filter.ReturnTypeFilter} to wrap an instance of this class.
- *
+ * <p/>
  * <p>
  * <b>Dependencies</b>:
  * <ul>
- *   <li>Concurrent API version 1.3.4 or greater</li>
+ * <li>Concurrent API version 1.3.4 or greater</li>
  * </ul>
  * </p>
+ *
  * @author James Carman
  * @since 1.0
  */
 public class ExecutorInterceptor implements Interceptor
 {
+//**********************************************************************************************************************
+// Fields
+//**********************************************************************************************************************
+
     private final Executor executor;
 
+//**********************************************************************************************************************
+// Constructors
+//**********************************************************************************************************************
+
     public ExecutorInterceptor( Executor executor )
     {
         this.executor = executor;
     }
 
+//**********************************************************************************************************************
+// Interceptor Implementation
+//**********************************************************************************************************************
+
+
     public Object intercept( final Invocation invocation ) throws Throwable
     {
-        if( Void.TYPE.equals( invocation.getMethod().getReturnType() ) )
+        if( Void.TYPE.equals(invocation.getMethod().getReturnType()) )
         {
             // Special case for finalize() method (should not be run in a different thread)...
-            if( !( invocation.getMethod().getName().equals( "finalize" ) &&
-                   invocation.getMethod().getParameterTypes().length == 0 ) )
+            if( !( invocation.getMethod().getName().equals("finalize") &&
+                    invocation.getMethod().getParameterTypes().length == 0 ) )
             {
-                executor.execute( new Runnable()
+                executor.execute(new Runnable()
                 {
                     public void run()
                     {
@@ -68,7 +82,7 @@
                             // What to do here?  I can't convey the failure back to the caller.
                         }
                     }
-                } );
+                });
                 return null;
             }
             else
@@ -78,7 +92,7 @@
         }
         else
         {
-            throw new IllegalArgumentException( "Only void methods can be executed in a different thread." );
+            throw new IllegalArgumentException("Only void methods can be executed in a different thread.");
         }
     }
 }

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/FilteredInterceptor.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/FilteredInterceptor.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/FilteredInterceptor.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/FilteredInterceptor.java Wed Feb 27 09:14:32 2008
@@ -17,8 +17,8 @@
 
 package org.apache.commons.proxy.interceptor;
 
-import org.apache.commons.proxy.Invocation;
 import org.apache.commons.proxy.Interceptor;
+import org.apache.commons.proxy.Invocation;
 
 /**
  * Decorates another <code>MethodInterceptor</code> by only calling it if the method is accepted by the supplied
@@ -29,16 +29,16 @@
  */
 public class FilteredInterceptor implements Interceptor
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Fields
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     private final Interceptor inner;
     private final MethodFilter filter;
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Constructors
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     public FilteredInterceptor( Interceptor inner, MethodFilter filter )
     {
@@ -46,15 +46,15 @@
         this.filter = filter;
     }
 
-//----------------------------------------------------------------------------------------------------------------------
-// MethodInterceptor Implementation
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
+// Interceptor Implementation
+//**********************************************************************************************************************
 
     public Object intercept( Invocation invocation ) throws Throwable
     {
-        if( filter.accepts( invocation.getMethod() ) )
+        if( filter.accepts(invocation.getMethod()) )
         {
-            return inner.intercept( invocation );
+            return inner.intercept(invocation);
         }
         else
         {

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/InterceptorChain.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/InterceptorChain.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/InterceptorChain.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/InterceptorChain.java Wed Feb 27 09:14:32 2008
@@ -17,15 +17,15 @@
 
 package org.apache.commons.proxy.interceptor;
 
+import org.apache.commons.proxy.Interceptor;
 import org.apache.commons.proxy.ObjectProvider;
 import org.apache.commons.proxy.ProxyFactory;
 import org.apache.commons.proxy.ProxyUtils;
-import org.apache.commons.proxy.Interceptor;
 
 /**
  * An <code>InterceptorChain</code> assists with creating proxies which go through a series of
  * {@link Interceptor interceptors}.
- *
+ * <p/>
  * <pre>
  *   MyServiceInterface serviceImpl = ...;
  *   ProxyFactory factory = ...;
@@ -33,7 +33,7 @@
  *   InterceptorChain chain = new InterceptorChain(interceptors);
  *   ObjectProvider provider = chain.createProxyProvider(factory, serviceImpl);
  *   MyServiceInterface serviceProxy = ( MyServiceInterface )provider.getObject();
- *   serviceProxy.someServiceMethod(...); // This will go through the interceptors! 
+ *   serviceProxy.someServiceMethod(...); // This will go through the interceptors!
  * </pre>
  *
  * @author James Carman
@@ -41,23 +41,24 @@
  */
 public class InterceptorChain
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Fields
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
+
     private final Interceptor[] interceptors;
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Constructors
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     public InterceptorChain( Interceptor[] interceptors )
     {
         this.interceptors = interceptors;
     }
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Other Methods
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     private Object createProxy( ProxyFactory proxyFactory, ClassLoader classLoader, Object terminus,
                                 Class[] proxyClasses )
@@ -66,7 +67,7 @@
         for( int i = interceptors.length - 1; i >= 0; --i )
         {
             currentTarget = proxyFactory
-                    .createInterceptorProxy( classLoader, currentTarget, interceptors[i], proxyClasses );
+                    .createInterceptorProxy(classLoader, currentTarget, interceptors[i], proxyClasses);
         }
         return currentTarget;
     }
@@ -76,15 +77,15 @@
      * chain of interceptors and ultimately arrive at the supplied terminus object.  The proxy will support all
      * interfaces implemented by the terminus object.  The thread context classloader will be used to generate the
      * proxy class.
-     * 
+     *
      * @param proxyFactory the {@link ProxyFactory} to use to create the proxy
-     * @param terminus the terminus
+     * @param terminus     the terminus
      * @return an {@link ObjectProvider} which will return a proxy that sends method invocations through this
-     * chain of interceptors and ultimately arrive at the supplied terminus object
+     *         chain of interceptors and ultimately arrive at the supplied terminus object
      */
     public ObjectProvider createProxyProvider( ProxyFactory proxyFactory, Object terminus )
     {
-        return createProxyProvider( proxyFactory, terminus, null );
+        return createProxyProvider(proxyFactory, terminus, null);
     }
 
     /**
@@ -94,15 +95,15 @@
      * proxy class.
      *
      * @param proxyFactory the {@link ProxyFactory} to use to create the proxy
-     * @param terminus the terminus
+     * @param terminus     the terminus
      * @param proxyClasses the interfaces to support
      * @return an {@link ObjectProvider} which will return a proxy that sends method invocations through this
-     * chain of interceptors and ultimately arrive at the supplied terminus object
+     *         chain of interceptors and ultimately arrive at the supplied terminus object
      */
     public ObjectProvider createProxyProvider( ProxyFactory proxyFactory, Object terminus, Class[] proxyClasses )
     {
-        return createProxyProvider( proxyFactory, Thread.currentThread().getContextClassLoader(), terminus,
-                                    proxyClasses );
+        return createProxyProvider(proxyFactory, Thread.currentThread().getContextClassLoader(), terminus,
+                proxyClasses);
     }
 
     /**
@@ -112,25 +113,25 @@
      * proxy class.
      *
      * @param proxyFactory the {@link ProxyFactory} to use to create the proxy
-     * @param classLoader the classloader to be used to generate the proxy class
-     * @param terminus the terminus
+     * @param classLoader  the classloader to be used to generate the proxy class
+     * @param terminus     the terminus
      * @param proxyClasses the interfaces to support
      * @return an {@link ObjectProvider} which will return a proxy that sends method invocations through this
-     * chain of interceptors and ultimately arrive at the supplied terminus object
+     *         chain of interceptors and ultimately arrive at the supplied terminus object
      */
     public ObjectProvider createProxyProvider( ProxyFactory proxyFactory, ClassLoader classLoader, Object terminus,
                                                Class[] proxyClasses )
     {
         if( proxyClasses == null || proxyClasses.length == 0 )
         {
-            proxyClasses = ProxyUtils.getAllInterfaces( terminus.getClass() );
+            proxyClasses = ProxyUtils.getAllInterfaces(terminus.getClass());
         }
-        return new ProxyObjectProvider( proxyFactory, classLoader, terminus, proxyClasses );
+        return new ProxyObjectProvider(proxyFactory, classLoader, terminus, proxyClasses);
     }
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Inner Classes
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     private class ProxyObjectProvider implements ObjectProvider
     {
@@ -150,7 +151,7 @@
 
         public Object getObject()
         {
-            return createProxy( proxyFactory, classLoader, terminus, proxyClasses );
+            return createProxy(proxyFactory, classLoader, terminus, proxyClasses);
         }
     }
 }

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/LoggingInterceptor.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/LoggingInterceptor.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/LoggingInterceptor.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/LoggingInterceptor.java Wed Feb 27 09:14:32 2008
@@ -18,68 +18,69 @@
 package org.apache.commons.proxy.interceptor;
 
 import org.apache.commons.logging.Log;
-import org.apache.commons.proxy.ProxyUtils;
 import org.apache.commons.proxy.Interceptor;
 import org.apache.commons.proxy.Invocation;
+import org.apache.commons.proxy.ProxyUtils;
 
 /**
  * An interceptor which logs each method invocation.
  * <b>Note</b>: The implementation of this class was borrowed from
  * HiveMind's logging interceptor.
- *
+ * <p/>
  * <p>
  * <b>Dependencies</b>:
  * <ul>
- *   <li>Apache Commons Logging version 1.0.4 or greater</li>
+ * <li>Apache Commons Logging version 1.0.4 or greater</li>
  * </ul>
  * </p>
+ *
  * @author James Carman
  * @since 1.0
  */
 public class LoggingInterceptor implements Interceptor
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Fields
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     private static final int BUFFER_SIZE = 100;
     private Log log;
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Constructors
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     public LoggingInterceptor( Log log )
     {
         this.log = log;
     }
 
-//----------------------------------------------------------------------------------------------------------------------
-// MethodInterceptor Implementation
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
+// Interceptor Implementation
+//**********************************************************************************************************************
 
     public Object intercept( Invocation invocation ) throws Throwable
     {
         if( log.isDebugEnabled() )
         {
             final String methodName = invocation.getMethod().getName();
-            entry( methodName, invocation.getArguments() );
+            entry(methodName, invocation.getArguments());
             try
             {
                 Object result = invocation.proceed();
-                if( Void.TYPE.equals( invocation.getMethod().getReturnType() ) )
+                if( Void.TYPE.equals(invocation.getMethod().getReturnType()) )
                 {
-                    voidExit( methodName );
+                    voidExit(methodName);
                 }
                 else
                 {
-                    exit( methodName, result );
+                    exit(methodName, result);
                 }
                 return result;
             }
             catch( Throwable t )
             {
-                exception( methodName, t );
+                exception(methodName, t);
                 throw t;
             }
         }
@@ -89,35 +90,15 @@
         }
     }
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Other Methods
-//----------------------------------------------------------------------------------------------------------------------
-
-    private void entry( String methodName, Object[] args )
-    {
-        StringBuffer buffer = new StringBuffer( BUFFER_SIZE );
-        buffer.append( "BEGIN " );
-        buffer.append( methodName );
-        buffer.append( "(" );
-        int count = args.length;
-        for( int i = 0; i < count; i++ )
-        {
-            Object arg = args[i];
-            if( i > 0 )
-            {
-                buffer.append( ", " );
-            }
-            convert( buffer, arg );
-        }
-        buffer.append( ")" );
-        log.debug( buffer.toString() );
-    }
+//**********************************************************************************************************************
 
     private void convert( StringBuffer buffer, Object input )
     {
         if( input == null )
         {
-            buffer.append( "<null>" );
+            buffer.append("<null>");
             return;
         }
 
@@ -126,56 +107,76 @@
         // that's a lot of work for a rare case.
         if( !( input instanceof Object[] ) )
         {
-            buffer.append( input.toString() );
+            buffer.append(input.toString());
             return;
         }
-        buffer.append( "(" );
-        buffer.append( ProxyUtils.getJavaClassName( input.getClass() ) );
-        buffer.append( "){" );
+        buffer.append("(");
+        buffer.append(ProxyUtils.getJavaClassName(input.getClass()));
+        buffer.append("){");
         Object[] array = ( Object[] ) input;
         int count = array.length;
         for( int i = 0; i < count; i++ )
         {
             if( i > 0 )
             {
-                buffer.append( ", " );
+                buffer.append(", ");
             }
 
             // We use convert() again, because it could be a multi-dimensional array
             // (god help us) where each element must be converted.
-            convert( buffer, array[i] );
+            convert(buffer, array[i]);
+        }
+        buffer.append("}");
+    }
+
+    private void entry( String methodName, Object[] args )
+    {
+        StringBuffer buffer = new StringBuffer(BUFFER_SIZE);
+        buffer.append("BEGIN ");
+        buffer.append(methodName);
+        buffer.append("(");
+        int count = args.length;
+        for( int i = 0; i < count; i++ )
+        {
+            Object arg = args[i];
+            if( i > 0 )
+            {
+                buffer.append(", ");
+            }
+            convert(buffer, arg);
         }
-        buffer.append( "}" );
+        buffer.append(")");
+        log.debug(buffer.toString());
     }
 
     private void exception( String methodName, Throwable t )
     {
-        StringBuffer buffer = new StringBuffer( BUFFER_SIZE );
-        buffer.append( "EXCEPTION " );
-        buffer.append( methodName );
-        buffer.append( "() -- " );
-        buffer.append( t.getClass().getName() );
-        log.debug( buffer.toString(), t );
+        StringBuffer buffer = new StringBuffer(BUFFER_SIZE);
+        buffer.append("EXCEPTION ");
+        buffer.append(methodName);
+        buffer.append("() -- ");
+        buffer.append(t.getClass().getName());
+        log.debug(buffer.toString(), t);
     }
 
     private void exit( String methodName, Object result )
     {
-        StringBuffer buffer = new StringBuffer( BUFFER_SIZE );
-        buffer.append( "END " );
-        buffer.append( methodName );
-        buffer.append( "() [" );
-        convert( buffer, result );
-        buffer.append( "]" );
-        log.debug( buffer.toString() );
+        StringBuffer buffer = new StringBuffer(BUFFER_SIZE);
+        buffer.append("END ");
+        buffer.append(methodName);
+        buffer.append("() [");
+        convert(buffer, result);
+        buffer.append("]");
+        log.debug(buffer.toString());
     }
 
     private void voidExit( String methodName )
     {
-        StringBuffer buffer = new StringBuffer( BUFFER_SIZE );
-        buffer.append( "END " );
-        buffer.append( methodName );
-        buffer.append( "()" );
-        log.debug( buffer.toString() );
+        StringBuffer buffer = new StringBuffer(BUFFER_SIZE);
+        buffer.append("END ");
+        buffer.append(methodName);
+        buffer.append("()");
+        log.debug(buffer.toString());
     }
 }
 

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/MethodFilter.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/MethodFilter.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/MethodFilter.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/MethodFilter.java Wed Feb 27 09:14:32 2008
@@ -27,12 +27,13 @@
  */
 public interface MethodFilter
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Other Methods
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     /**
      * Returns whether or not this filter accepts this method.
+     *
      * @param method the method
      * @return whether or not this filter accepts this method
      */

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/MethodInterceptorAdapter.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/MethodInterceptorAdapter.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/MethodInterceptorAdapter.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/MethodInterceptorAdapter.java Wed Feb 27 09:14:32 2008
@@ -28,29 +28,47 @@
 /**
  * An adapter class to adapt AOP Alliance's {@link MethodInterceptor} interface to Commons Proxy's
  * {@link Interceptor} interface.
- *
+ * <p/>
  * <p>
  * <b>Dependencies</b>:
  * <ul>
- *   <li>AOP Alliance API version 1.0 or greater</li>
+ * <li>AOP Alliance API version 1.0 or greater</li>
  * </ul>
  * </p>
+ *
  * @author James Carman
  * @since 1.0
  */
 public class MethodInterceptorAdapter implements Interceptor
 {
+//**********************************************************************************************************************
+// Fields
+//**********************************************************************************************************************
+
     private final MethodInterceptor methodInterceptor;
 
+//**********************************************************************************************************************
+// Constructors
+//**********************************************************************************************************************
+
     public MethodInterceptorAdapter( MethodInterceptor methodInterceptor )
     {
         this.methodInterceptor = methodInterceptor;
     }
 
+//**********************************************************************************************************************
+// Interceptor Implementation
+//**********************************************************************************************************************
+
+
     public Object intercept( Invocation invocation ) throws Throwable
     {
-        return methodInterceptor.invoke( new MethodInvocationAdapter( invocation ) );
+        return methodInterceptor.invoke(new MethodInvocationAdapter(invocation));
     }
+
+//**********************************************************************************************************************
+// Inner Classes
+//**********************************************************************************************************************
 
     private static class MethodInvocationAdapter implements MethodInvocation
     {

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/SerializingInterceptor.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/SerializingInterceptor.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/SerializingInterceptor.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/SerializingInterceptor.java Wed Feb 27 09:14:32 2008
@@ -25,26 +25,36 @@
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.io.Serializable;
 
 /**
  * An interceptor which makes a serialized copy of all parameters and return values.  This
  * is useful when testing remote services to ensure that all parameter/return types
  * are in fact serializable/deserializable.
+ *
  * @since 1.0
  */
-public class SerializingInterceptor implements Interceptor
+public class SerializingInterceptor implements Interceptor, Serializable
 {
-    public Object intercept(Invocation invocation) throws Throwable
+//**********************************************************************************************************************
+// Interceptor Implementation
+//**********************************************************************************************************************
+
+    public Object intercept( Invocation invocation ) throws Throwable
     {
         Object[] arguments = invocation.getArguments();
-        for (int i = 0; i < arguments.length; i++)
+        for( int i = 0; i < arguments.length; i++ )
         {
             arguments[i] = serializedCopy(arguments[i]);
         }
         return serializedCopy(invocation.proceed());
     }
 
-    private Object serializedCopy(Object original)
+//**********************************************************************************************************************
+// Other Methods
+//**********************************************************************************************************************
+
+    private Object serializedCopy( Object original )
     {
         try
         {
@@ -60,15 +70,15 @@
             bin.close();
             return copy;
         }
-        catch (IOException e)
+        catch( IOException e )
         {
-            throw new RuntimeException( "Unable to make serialized copy of " +
-                    original.getClass().getName() + " object.", e );
+            throw new RuntimeException("Unable to make serialized copy of " +
+                    original.getClass().getName() + " object.", e);
         }
-        catch (ClassNotFoundException e)
+        catch( ClassNotFoundException e )
         {
-            throw new RuntimeException( "Unable to make serialized copy of " +
-                    original.getClass().getName() + " object.", e );
+            throw new RuntimeException("Unable to make serialized copy of " +
+                    original.getClass().getName() + " object.", e);
         }
     }
 }

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/filter/PatternFilter.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/filter/PatternFilter.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/filter/PatternFilter.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/filter/PatternFilter.java Wed Feb 27 09:14:32 2008
@@ -30,16 +30,16 @@
  */
 public class PatternFilter implements MethodFilter
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Fields
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     public static String GETTER_SETTER_PATTERN = "get\\w+|set\\w+";
     private final String pattern;
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Static Methods
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     /**
      * Returns a {@link MethodFilter} which accepts only "getters" and "setters."
@@ -48,25 +48,25 @@
      */
     public static MethodFilter getterSetterFilter()
     {
-        return new PatternFilter( GETTER_SETTER_PATTERN );
+        return new PatternFilter(GETTER_SETTER_PATTERN);
     }
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Constructors
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     public PatternFilter( String pattern )
     {
         this.pattern = pattern;
     }
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // MethodFilter Implementation
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     public boolean accepts( Method method )
     {
-        return method.getName().matches( pattern );
+        return method.getName().matches(pattern);
     }
 }
 

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/filter/ReturnTypeFilter.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/filter/ReturnTypeFilter.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/filter/ReturnTypeFilter.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/filter/ReturnTypeFilter.java Wed Feb 27 09:14:32 2008
@@ -27,25 +27,39 @@
 
 /**
  * Filters methods based on their return type.
+ *
  * @author James Carman
  * @since 1.0
  */
 public class ReturnTypeFilter implements MethodFilter
 {
+//**********************************************************************************************************************
+// Fields
+//**********************************************************************************************************************
+
     private final Set validReturnTypes = new HashSet();
 
+//**********************************************************************************************************************
+// Constructors
+//**********************************************************************************************************************
+
     public ReturnTypeFilter( Class[] validReturnTypes )
     {
-        this( Arrays.asList( validReturnTypes ) );
+        this(Arrays.asList(validReturnTypes));
     }
 
     public ReturnTypeFilter( Collection validReturnTypes )
     {
-        this.validReturnTypes.addAll( validReturnTypes );
+        this.validReturnTypes.addAll(validReturnTypes);
     }
 
+//**********************************************************************************************************************
+// MethodFilter Implementation
+//**********************************************************************************************************************
+
+
     public boolean accepts( Method method )
     {
-        return validReturnTypes.contains( method.getReturnType() );
+        return validReturnTypes.contains(method.getReturnType());
     }
 }

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/filter/SimpleFilter.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/filter/SimpleFilter.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/filter/SimpleFilter.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/filter/SimpleFilter.java Wed Feb 27 09:14:32 2008
@@ -32,15 +32,15 @@
  */
 public class SimpleFilter implements MethodFilter
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Fields
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     private final Set methodNames;
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Constructors
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     /**
      * Creates a simple filter that accepts no methods.
@@ -52,20 +52,21 @@
 
     /**
      * Creates a simple filter that accepts methods matching the supplied names.
+     *
      * @param methodNames the names
      */
     public SimpleFilter( String[] methodNames )
     {
-        this.methodNames = new HashSet( Arrays.asList( methodNames ) );
+        this.methodNames = new HashSet(Arrays.asList(methodNames));
     }
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // MethodFilter Implementation
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     public boolean accepts( Method method )
     {
-        return methodNames.contains( method.getName() );
+        return methodNames.contains(method.getName());
     }
 }
 

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/filter/package.html
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/filter/package.html?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/filter/package.html (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/filter/package.html Wed Feb 27 09:14:32 2008
@@ -18,7 +18,7 @@
 <html>
 <body>
 <p>
-This package contains some useful <a href="../MethodFilter.html">MethodFilter</a> implementations.
+    This package contains some useful <a href="../MethodFilter.html">MethodFilter</a> implementations.
 </p>
 </body>
 </html>

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/package.html
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/package.html?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/package.html (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/interceptor/package.html Wed Feb 27 09:14:32 2008
@@ -18,7 +18,7 @@
 <html>
 <body>
 <p>
-This package contains some useful <a href="../Interceptor.html">Interceptor</a> implementations.
+    This package contains some useful <a href="../Interceptor.html">Interceptor</a> implementations.
 </p>
 </body>
 </html>

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/DuckTypingInvoker.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/DuckTypingInvoker.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/DuckTypingInvoker.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/DuckTypingInvoker.java Wed Feb 27 09:14:32 2008
@@ -52,24 +52,24 @@
  */
 public class DuckTypingInvoker implements Invoker
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Fields
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     private final ObjectProvider targetProvider;
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Constructors
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     public DuckTypingInvoker( final ObjectProvider targetProvider )
     {
         this.targetProvider = targetProvider;
     }
 
-//----------------------------------------------------------------------------------------------------------------------
-// Interface Invoker
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
+// Invoker Implementation
+//**********************************************************************************************************************
 
     public Object invoke( final Object proxy, final Method method, final Object[] arguments ) throws Throwable
     {
@@ -77,18 +77,18 @@
         final Class targetClass = target.getClass();
         try
         {
-            final Method targetMethod = targetClass.getMethod( method.getName(), method.getParameterTypes() );
-            if ( method.getReturnType().isAssignableFrom( targetMethod.getReturnType() ) )
+            final Method targetMethod = targetClass.getMethod(method.getName(), method.getParameterTypes());
+            if( method.getReturnType().isAssignableFrom(targetMethod.getReturnType()) )
             {
-                return targetMethod.invoke( target, arguments );
+                return targetMethod.invoke(target, arguments);
             }
             throw new UnsupportedOperationException(
-                    "Target type " + targetClass.getName() + " method has incompatible return type." );
+                    "Target type " + targetClass.getName() + " method has incompatible return type.");
         }
-        catch ( NoSuchMethodException e )
+        catch( NoSuchMethodException e )
         {
             throw new UnsupportedOperationException(
-                    "Target type " + targetClass.getName() + " does not have a method matching " + method + "." );
+                    "Target type " + targetClass.getName() + " does not have a method matching " + method + ".");
         }
     }
 }

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/InvocationHandlerAdapter.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/InvocationHandlerAdapter.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/InvocationHandlerAdapter.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/InvocationHandlerAdapter.java Wed Feb 27 09:14:32 2008
@@ -19,8 +19,8 @@
 
 import org.apache.commons.proxy.Invoker;
 
-import java.lang.reflect.Method;
 import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
 
 /**
  * An adapter class to adapt the JDK's {@link InvocationHandler} interface to Commons Proxy's
@@ -31,15 +31,28 @@
  */
 public class InvocationHandlerAdapter implements Invoker
 {
+//**********************************************************************************************************************
+// Fields
+//**********************************************************************************************************************
+
     private final InvocationHandler invocationHandler;
 
+//**********************************************************************************************************************
+// Constructors
+//**********************************************************************************************************************
+
     public InvocationHandlerAdapter( InvocationHandler invocationHandler )
     {
         this.invocationHandler = invocationHandler;
     }
 
+//**********************************************************************************************************************
+// Invoker Implementation
+//**********************************************************************************************************************
+
+
     public Object invoke( Object proxy, Method method, Object[] arguments ) throws Throwable
     {
-        return invocationHandler.invoke( proxy, method, arguments );
+        return invocationHandler.invoke(proxy, method, arguments);
     }
 }

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/NullInvoker.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/NullInvoker.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/NullInvoker.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/NullInvoker.java Wed Feb 27 09:14:32 2008
@@ -19,6 +19,7 @@
 
 import org.apache.commons.proxy.Invoker;
 
+import java.io.Serializable;
 import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.Map;
@@ -30,30 +31,40 @@
  * @author James Carman
  * @since 1.0
  */
-public class NullInvoker implements Invoker
+public class NullInvoker implements Invoker, Serializable
 {
+//**********************************************************************************************************************
+// Fields
+//**********************************************************************************************************************
+
     private static Map primitiveValueMap = new HashMap();
+
+//**********************************************************************************************************************
+// Static Methods
+//**********************************************************************************************************************
+
     static
     {
-        primitiveValueMap.put( Integer.TYPE, new Integer( 0 ) );
-        primitiveValueMap.put( Long.TYPE, new Long( 0 ) );
-        primitiveValueMap.put( Short.TYPE, new Short( ( short )0 ) );
-        primitiveValueMap.put( Byte.TYPE, new Byte( ( byte )0 ) );
-        primitiveValueMap.put( Float.TYPE, new Float( 0.0f ) );
-        primitiveValueMap.put( Double.TYPE, new Double( 0.0 ) );
-        primitiveValueMap.put( Character.TYPE, new Character( ( char )0 ) );
-        primitiveValueMap.put( Boolean.TYPE, Boolean.FALSE );
+        primitiveValueMap.put(Integer.TYPE, new Integer(0));
+        primitiveValueMap.put(Long.TYPE, new Long(0));
+        primitiveValueMap.put(Short.TYPE, new Short(( short ) 0));
+        primitiveValueMap.put(Byte.TYPE, new Byte(( byte ) 0));
+        primitiveValueMap.put(Float.TYPE, new Float(0.0f));
+        primitiveValueMap.put(Double.TYPE, new Double(0.0));
+        primitiveValueMap.put(Character.TYPE, new Character(( char ) 0));
+        primitiveValueMap.put(Boolean.TYPE, Boolean.FALSE);
     }
-//----------------------------------------------------------------------------------------------------------------------
-// InvocationHandler Implementation
-//----------------------------------------------------------------------------------------------------------------------
+
+//**********************************************************************************************************************
+// Invoker Implementation
+//**********************************************************************************************************************
 
     public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable
     {
         final Class returnType = method.getReturnType();
         if( returnType.isPrimitive() )
         {
-            return primitiveValueMap.get( returnType );
+            return primitiveValueMap.get(returnType);
         }
         else
         {

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/XmlRpcInvoker.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/XmlRpcInvoker.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/XmlRpcInvoker.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/XmlRpcInvoker.java Wed Feb 27 09:14:32 2008
@@ -27,45 +27,62 @@
 
 /**
  * Uses <a href="http://ws.apache.org/xmlrpc/">Apache XML-RPC</a> to invoke methods on an XML-RPC service.
- *
+ * <p/>
  * <p>
  * <b>Dependencies</b>:
  * <ul>
- *   <li>Apache XML-RPC version 2.0 or greater</li>
+ * <li>Apache XML-RPC version 2.0 or greater</li>
  * </ul>
  * </p>
+ *
  * @author James Carman
  * @since 1.0
  */
 public class XmlRpcInvoker implements Invoker
 {
+//**********************************************************************************************************************
+// Fields
+//**********************************************************************************************************************
+
     private final XmlRpcHandler handler;
     private final String handlerName;
 
+//**********************************************************************************************************************
+// Constructors
+//**********************************************************************************************************************
+
     public XmlRpcInvoker( XmlRpcHandler handler, String handlerName )
     {
         this.handler = handler;
         this.handlerName = handlerName;
     }
 
+//**********************************************************************************************************************
+// Invoker Implementation
+//**********************************************************************************************************************
+
+
     public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable
     {
-        final Object returnValue = handler.execute( handlerName + "." + method.getName(), toArgumentVector( args ) );
+        final Object returnValue = handler.execute(handlerName + "." + method.getName(), toArgumentVector(args));
         if( returnValue instanceof XmlRpcException )
         {
-            throw new InvokerException( "Unable to execute XML-RPC call.", ( XmlRpcException )returnValue );
-
+            throw new InvokerException("Unable to execute XML-RPC call.", ( XmlRpcException ) returnValue);
         }
         return returnValue;
     }
 
+//**********************************************************************************************************************
+// Other Methods
+//**********************************************************************************************************************
+
     private Vector toArgumentVector( Object[] args )
     {
         final Vector v = new Vector();
         for( int i = 0; i < args.length; i++ )
         {
             Object arg = args[i];
-            v.addElement( arg );
+            v.addElement(arg);
         }
         return v;
     }

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/package.html
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/package.html?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/package.html (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/invoker/package.html Wed Feb 27 09:14:32 2008
@@ -18,7 +18,7 @@
 <html>
 <body>
 <p>
-This package contains some useful <a href="../Invoker.html">Invoker</a> implementations.
+    This package contains some useful <a href="../Invoker.html">Invoker</a> implementations.
 </p>
 </body>
 </html>

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

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/provider/BeanProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/provider/BeanProvider.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/provider/BeanProvider.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/provider/BeanProvider.java Wed Feb 27 09:14:32 2008
@@ -20,23 +20,25 @@
 import org.apache.commons.proxy.ObjectProvider;
 import org.apache.commons.proxy.exception.ObjectProviderException;
 
+import java.io.Serializable;
+
 /**
  * Uses <code>Class.newInstance()</code> to instantiate an object.
  *
  * @author James Carman
  * @since 1.0
  */
-public class BeanProvider implements ObjectProvider
+public class BeanProvider implements ObjectProvider, Serializable
 {
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Fields
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     private Class beanClass;
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Constructors
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     public BeanProvider()
     {
@@ -44,6 +46,7 @@
 
     /**
      * Constructs a provider which instantiates objects of the specified bean class.
+     *
      * @param beanClass the bean class
      */
     public BeanProvider( Class beanClass )
@@ -51,9 +54,9 @@
         this.beanClass = beanClass;
     }
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // ObjectProvider Implementation
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     public Object getObject()
     {
@@ -61,24 +64,24 @@
         {
             if( beanClass == null )
             {
-                throw new ObjectProviderException( "No bean class provided." );
+                throw new ObjectProviderException("No bean class provided.");
             }
             return beanClass.newInstance();
         }
         catch( InstantiationException e )
         {
-            throw new ObjectProviderException( "Class " + beanClass.getName() + " is not concrete.", e );
+            throw new ObjectProviderException("Class " + beanClass.getName() + " is not concrete.", e);
         }
         catch( IllegalAccessException e )
         {
-            throw new ObjectProviderException( "Constructor for class " + beanClass.getName() + " is not accessible.",
-                                               e );
+            throw new ObjectProviderException("Constructor for class " + beanClass.getName() + " is not accessible.",
+                    e);
         }
     }
 
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 // Getter/Setter Methods
-//----------------------------------------------------------------------------------------------------------------------
+//**********************************************************************************************************************
 
     public void setBeanClass( Class beanClass )
     {

Modified: commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/provider/CloningProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/provider/CloningProvider.java?rev=631654&r1=631653&r2=631654&view=diff
==============================================================================
--- commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/provider/CloningProvider.java (original)
+++ commons/proper/proxy/trunk/src/main/java/org/apache/commons/proxy/provider/CloningProvider.java Wed Feb 27 09:14:32 2008
@@ -21,6 +21,7 @@
 import org.apache.commons.proxy.ProxyUtils;
 import org.apache.commons.proxy.exception.ObjectProviderException;
 
+import java.io.Serializable;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
@@ -30,14 +31,23 @@
  * @author James Carman
  * @since 1.0
  */
-public class CloningProvider implements ObjectProvider
+public class CloningProvider implements ObjectProvider, Serializable
 {
+//**********************************************************************************************************************
+// Fields
+//**********************************************************************************************************************
+
     private final Cloneable cloneable;
     private Method cloneMethod;
 
+//**********************************************************************************************************************
+// Constructors
+//**********************************************************************************************************************
+
     /**
      * Constructs a provider which returns clone copies of the specified {@link Cloneable}
      * object.
+     *
      * @param cloneable the object to clone
      */
     public CloningProvider( Cloneable cloneable )
@@ -45,39 +55,47 @@
         this.cloneable = cloneable;
     }
 
-    private synchronized Method getCloneMethod()
-    {
-        if( cloneMethod == null )
-        {
-            try
-            {
-                cloneMethod = cloneable.getClass().getMethod( "clone", ProxyUtils.EMPTY_ARGUMENT_TYPES );
-            }
-            catch( NoSuchMethodException e )
-            {
-                throw new ObjectProviderException(
-                        "Class " + cloneable.getClass().getName() + " does not have a public clone() method." );
-            }
-        }
-        return cloneMethod;
-    }
+//**********************************************************************************************************************
+// ObjectProvider Implementation
+//**********************************************************************************************************************
+
 
     public Object getObject()
     {
         try
         {
-            return getCloneMethod().invoke( cloneable, ProxyUtils.EMPTY_ARGUMENTS );
+            return getCloneMethod().invoke(cloneable, ProxyUtils.EMPTY_ARGUMENTS);
         }
         catch( IllegalAccessException e )
         {
             throw new ObjectProviderException(
-                    "Class " + cloneable.getClass().getName() + " does not have a public clone() method.", e );
+                    "Class " + cloneable.getClass().getName() + " does not have a public clone() method.", e);
         }
         catch( InvocationTargetException e )
         {
             throw new ObjectProviderException(
-                    "Attempt to clone object of type " + cloneable.getClass().getName() + " threw an exception.", e );
+                    "Attempt to clone object of type " + cloneable.getClass().getName() + " threw an exception.", e);
         }
     }
 
+//**********************************************************************************************************************
+// Getter/Setter Methods
+//**********************************************************************************************************************
+
+    private synchronized Method getCloneMethod()
+    {
+        if( cloneMethod == null )
+        {
+            try
+            {
+                cloneMethod = cloneable.getClass().getMethod("clone", ProxyUtils.EMPTY_ARGUMENT_TYPES);
+            }
+            catch( NoSuchMethodException e )
+            {
+                throw new ObjectProviderException(
+                        "Class " + cloneable.getClass().getName() + " does not have a public clone() method.");
+            }
+        }
+        return cloneMethod;
+    }
 }