You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by jc...@apache.org on 2005/10/13 17:57:34 UTC
svn commit: r320786 - in /jakarta/commons/sandbox/proxy/trunk/src:
java/org/apache/commons/proxy/ java/org/apache/commons/proxy/factory/cglib/
java/org/apache/commons/proxy/factory/javassist/
java/org/apache/commons/proxy/factory/reflect/ test/org/apac...
Author: jcarman
Date: Thu Oct 13 08:57:23 2005
New Revision: 320786
URL: http://svn.apache.org/viewcvs?rev=320786&view=rev
Log:
AOP Alliance API clarification (http://sourceforge.net/mailarchive/forum.php?thread_id=8065814&forum_id=33808). Arguments should not be null, but an empty Object[].
Modified:
jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/ProxyUtils.java
jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/factory/cglib/CglibProxyFactory.java
jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/factory/javassist/JavassistMethodInvocation.java
jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/factory/reflect/ReflectionMethodInvocation.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/ProxyUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/ProxyUtils.java?rev=320786&r1=320785&r2=320786&view=diff
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/ProxyUtils.java (original)
+++ jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/ProxyUtils.java Thu Oct 13 08:57:23 2005
@@ -28,6 +28,9 @@
*/
public class ProxyUtils
{
+ public static final Object[] EMPTY_ARGUMENTS = new Object[0];
+ public static final Class[] EMPTY_ARGUMENT_TYPES = new Class[0];
+
/**
* Creates a "null object" which implements the <code>proxyClasses</code>.
* @param proxyFactory the proxy factory to be used to create the proxy object
Modified: jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/factory/cglib/CglibProxyFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/factory/cglib/CglibProxyFactory.java?rev=320786&r1=320785&r2=320786&view=diff
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/factory/cglib/CglibProxyFactory.java (original)
+++ jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/factory/cglib/CglibProxyFactory.java Thu Oct 13 08:57:23 2005
@@ -22,6 +22,7 @@
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.proxy.ObjectProvider;
+import org.apache.commons.proxy.ProxyUtils;
import org.apache.commons.proxy.factory.util.AbstractSubclassingProxyFactory;
import java.lang.reflect.AccessibleObject;
@@ -122,7 +123,7 @@
this.target = target;
this.method = method;
this.methodProxy = methodProxy;
- this.args = args == null || args.length == 0 ? null : args;
+ this.args = args == null ? ProxyUtils.EMPTY_ARGUMENTS : args;
}
public Method getMethod()
Modified: jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/factory/javassist/JavassistMethodInvocation.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/factory/javassist/JavassistMethodInvocation.java?rev=320786&r1=320785&r2=320786&view=diff
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/factory/javassist/JavassistMethodInvocation.java (original)
+++ jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/factory/javassist/JavassistMethodInvocation.java Thu Oct 13 08:57:23 2005
@@ -21,6 +21,7 @@
import javassist.CtConstructor;
import javassist.CtMethod;
import org.aopalliance.intercept.MethodInvocation;
+import org.apache.commons.proxy.ProxyUtils;
import java.lang.ref.WeakReference;
import java.lang.reflect.AccessibleObject;
@@ -111,7 +112,7 @@
constructor.setBody( "{\n\tsuper($$);\n}" );
ctClass.addConstructor( constructor );
final CtMethod proceedMethod = new CtMethod( JavassistUtils.resolve( Object.class ), "proceed",
- JavassistUtils.resolve( new Class[0] ), ctClass );
+ JavassistUtils.resolve( ProxyUtils.EMPTY_ARGUMENT_TYPES ), ctClass );
final Class[] argumentTypes = interfaceMethod.getParameterTypes();
final StringBuffer proceedBody = new StringBuffer( "{\n" );
if( !Void.TYPE.equals( interfaceMethod.getReturnType() ) )
@@ -159,7 +160,7 @@
{
this.method = method;
this.target = target;
- this.arguments = ( arguments == null || arguments.length == 0 ? null : arguments );
+ this.arguments = ( arguments == null ? ProxyUtils.EMPTY_ARGUMENTS : arguments );
}
//----------------------------------------------------------------------------------------------------------------------
Modified: jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/factory/reflect/ReflectionMethodInvocation.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/factory/reflect/ReflectionMethodInvocation.java?rev=320786&r1=320785&r2=320786&view=diff
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/factory/reflect/ReflectionMethodInvocation.java (original)
+++ jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/factory/reflect/ReflectionMethodInvocation.java Thu Oct 13 08:57:23 2005
@@ -17,6 +17,7 @@
package org.apache.commons.proxy.factory.reflect;
import org.aopalliance.intercept.MethodInvocation;
+import org.apache.commons.proxy.ProxyUtils;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.InvocationTargetException;
@@ -45,7 +46,7 @@
public ReflectionMethodInvocation( Object target, Method method, Object[] arguments )
{
this.method = method;
- this.arguments = arguments;
+ this.arguments = ( arguments == null ? ProxyUtils.EMPTY_ARGUMENTS : arguments );
this.target = target;
}
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=320786&r1=320785&r2=320786&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 Oct 13 08:57:23 2005
@@ -116,7 +116,8 @@
final EchoImpl target = new EchoImpl();
final Echo proxy = ( Echo ) factory.createInterceptorProxy( target, tester, ECHO_ONLY );
proxy.echo();
- assertNull( tester.arguments );
+ assertNotNull( tester.arguments );
+ assertEquals( 0, tester.arguments.length );
assertEquals( Echo.class.getMethod( "echo", new Class[] {} ), tester.method );
assertEquals( target, tester.target );
assertEquals( Echo.class.getMethod( "echo", new Class[] {} ), tester.staticPart );
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org