commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jcar...@apache.org
Subject svn commit: r265714 - in /jakarta/commons/sandbox/proxy/trunk/src: java/org/apache/commons/proxy/factory/util/AbstractProxyClassGenerator.java test/org/apache/commons/proxy/factory/AbstractProxyFactoryTestCase.java
Date Thu, 01 Sep 2005 13:16:06 GMT
Author: jcarman
Date: Thu Sep  1 06:16:01 2005
New Revision: 265714

URL: http://svn.apache.org/viewcvs?rev=265714&view=rev
Log:
Fixed bug where interface hierarchies weren't supported.  It was calling getDeclaredMethods()
rather than getMethods().

Modified:
    jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/factory/util/AbstractProxyClassGenerator.java
    jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/factory/AbstractProxyFactoryTestCase.java

Modified: jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/factory/util/AbstractProxyClassGenerator.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/factory/util/AbstractProxyClassGenerator.java?rev=265714&r1=265713&r2=265714&view=diff
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/factory/util/AbstractProxyClassGenerator.java
(original)
+++ jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/factory/util/AbstractProxyClassGenerator.java
Thu Sep  1 06:16:01 2005
@@ -23,11 +23,21 @@
 import java.util.Set;
 
 /**
+ * A useful superclass for {@link ProxyClassGenerator} implementations.
+ *
  * @author James Carman
  * @version 1.0
  */
 public abstract class AbstractProxyClassGenerator implements ProxyClassGenerator
 {
+    /**
+     * Returns all methods that a proxy class must implement from the
+     * proxy interfaces.  This method makes sure there are no method signature clashes.
+     * For methods with the same signature (name and parameter types), the one encountered
+     * first will be returned in the result.
+     * @param proxyInterfaces the interfaces the proxy class must implement
+     * @return all methods that the proxy class must implement
+     */
     public static Method[] getImplementationMethods( Class... proxyInterfaces )
     {
         final Set<MethodSignature> signatures = new HashSet<MethodSignature>();
@@ -35,7 +45,7 @@
         for( int i = 0; i < proxyInterfaces.length; i++ )
         {
             Class proxyInterface = proxyInterfaces[i];
-            final Method[] methods = proxyInterface.getDeclaredMethods();
+            final Method[] methods = proxyInterface.getMethods();
             for( int j = 0; j < methods.length; j++ )
             {
                 final MethodSignature signature = new MethodSignature( methods[j] );

Modified: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/factory/AbstractProxyFactoryTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/factory/AbstractProxyFactoryTestCase.java?rev=265714&r1=265713&r2=265714&view=diff
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/factory/AbstractProxyFactoryTestCase.java
(original)
+++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/factory/AbstractProxyFactoryTestCase.java
Thu Sep  1 06:16:01 2005
@@ -19,7 +19,6 @@
 import org.aopalliance.intercept.MethodInvocation;
 import org.apache.commons.proxy.ProxyFactory;
 import static org.apache.commons.proxy.provider.ProviderUtils.*;
-import org.apache.commons.proxy.provider.ConstantProvider;
 import org.apache.commons.proxy.util.AbstractTestCase;
 import org.apache.commons.proxy.util.Echo;
 import org.apache.commons.proxy.util.EchoImpl;
@@ -32,6 +31,8 @@
 import java.util.Arrays;
 import java.util.List;
 import java.util.LinkedList;
+import java.util.SortedSet;
+import java.util.TreeSet;
 
 /**
  * @author James Carman
@@ -46,11 +47,17 @@
         this.factory = factory;
     }
 
+    public void testInterfaceHierarchies()
+    {
+        final SortedSet<String> set = ( SortedSet<String> ) factory.createDelegatingProxy(
constantProvider( new TreeSet<String>() ), SortedSet.class );
+        set.add( "Hello" );
+    }
+
     public void testDelegatingProxyInterfaceOrder()
     {
         final Echo echo = ( Echo ) factory.createDelegatingProxy( singletonProvider( beanProvider(
EchoImpl.class ) ), Echo.class, DuplicateEcho.class );
-        final List expected = new LinkedList( Arrays.asList( Echo.class, DuplicateEcho.class
) );
-        final List actual = new LinkedList( Arrays.asList( echo.getClass().getInterfaces()
) );
+        final List<Class> expected = new LinkedList<Class>( Arrays.asList( Echo.class,
DuplicateEcho.class ) );
+        final List<Class> actual = new LinkedList<Class>( Arrays.asList( echo.getClass().getInterfaces()
) );
         actual.retainAll( expected );  // Doesn't alter order!
         assertEquals( expected, actual );
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message