Copied: jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/invoker/NullInvoker.java (from r321183, jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/handler/NullInvocationHandler.java) URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/invoker/NullInvoker.java?p2=jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/invoker/NullInvoker.java&p1=jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/handler/NullInvocationHandler.java&r1=321183&r2=325897&rev=325897&view=diff ============================================================================== --- jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/handler/NullInvocationHandler.java (original) +++ jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/invoker/NullInvoker.java Mon Oct 17 07:11:52 2005 @@ -14,21 +14,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.commons.proxy.handler; +package org.apache.commons.proxy.invoker; + +import org.apache.commons.proxy.Invoker; -import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; /** - * An [EMAIL PROTECTED] InvocationHandler} implementation which merely returns null for all method invocations. This class is + * An [EMAIL PROTECTED] Invoker} implementation which merely returns null for all method invocations. This class is * useful for scenarios where the "null object" design pattern is needed. * * @author James Carman * @version 1.0 */ -public class NullInvocationHandler implements InvocationHandler +public class NullInvoker implements Invoker { private static Map primitiveValueMap = new HashMap(); static
Propchange: jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/invoker/NullInvoker.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/invoker/NullInvoker.java ------------------------------------------------------------------------------ svn:keywords = Id Copied: jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/invoker/XmlRpcInvoker.java (from r321183, jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/handler/XmlRpcInvocationHandler.java) URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/invoker/XmlRpcInvoker.java?p2=jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/invoker/XmlRpcInvoker.java&p1=jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/handler/XmlRpcInvocationHandler.java&r1=321183&r2=325897&rev=325897&view=diff ============================================================================== --- jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/handler/XmlRpcInvocationHandler.java (original) +++ jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/invoker/XmlRpcInvoker.java Mon Oct 17 07:11:52 2005 @@ -14,13 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.commons.proxy.handler; +package org.apache.commons.proxy.invoker; -import org.apache.xmlrpc.XmlRpcHandler; -import org.apache.xmlrpc.XmlRpcException; +import org.apache.commons.proxy.Invoker; import org.apache.commons.proxy.exception.InvocationHandlerException; +import org.apache.xmlrpc.XmlRpcException; +import org.apache.xmlrpc.XmlRpcHandler; -import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.util.Vector; @@ -28,12 +28,12 @@ * @author James Carman * @version 1.0 */ -public class XmlRpcInvocationHandler implements InvocationHandler +public class XmlRpcInvoker implements Invoker { private final XmlRpcHandler handler; private final String handlerName; - public XmlRpcInvocationHandler( XmlRpcHandler handler, String handlerName ) + public XmlRpcInvoker( XmlRpcHandler handler, String handlerName ) { this.handler = handler; this.handlerName = handlerName; Propchange: jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/invoker/XmlRpcInvoker.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/invoker/XmlRpcInvoker.java ------------------------------------------------------------------------------ svn:keywords = Id 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=325897&r1=325896&r2=325897&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 Mon Oct 17 07:11:52 2005 @@ -15,8 +15,9 @@ */ package org.apache.commons.proxy.factory; -import org.aopalliance.intercept.MethodInterceptor; -import org.aopalliance.intercept.MethodInvocation; +import org.apache.commons.proxy.Invocation; +import org.apache.commons.proxy.Interceptor; +import org.apache.commons.proxy.Invoker; import org.apache.commons.proxy.ObjectProvider; import org.apache.commons.proxy.ProxyFactory; import org.apache.commons.proxy.provider.ProviderUtils; @@ -24,11 +25,9 @@ import org.apache.commons.proxy.util.DuplicateEcho; import org.apache.commons.proxy.util.Echo; import org.apache.commons.proxy.util.EchoImpl; -import org.apache.commons.proxy.util.SuffixMethodInterceptor; +import org.apache.commons.proxy.util.SuffixInterceptor; import java.io.IOException; -import java.lang.reflect.AccessibleObject; -import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.util.Arrays; import java.util.LinkedList; @@ -64,8 +63,8 @@ public void testInvocationHandlerProxy() throws Exception { - final InvocationHandlerTester tester = new InvocationHandlerTester(); - final Echo echo = ( Echo )factory.createInvocationHandlerProxy( tester, ECHO_ONLY ); + final InvokerTester tester = new InvokerTester(); + final Echo echo = ( Echo )factory.createInvokerProxy( tester, ECHO_ONLY ); echo.echoBack( "hello" ); assertEquals( Echo.class.getMethod( "echoBack", new Class[] { String.class } ), tester.method ); assertSame( echo, tester.proxy ); @@ -100,7 +99,7 @@ public void testCreateInterceptorProxy() { final Echo target = ( Echo ) factory.createDelegatorProxy( createSingletonEcho(), ECHO_ONLY ); - final Echo proxy = ( Echo ) factory.createInterceptorProxy( target, new SuffixMethodInterceptor( " suffix" ), ECHO_ONLY ); + final Echo proxy = ( Echo ) factory.createInterceptorProxy( target, new SuffixInterceptor( " suffix" ), ECHO_ONLY ); proxy.echo(); assertEquals( "message suffix", proxy.echoBack( "message" ) ); } @@ -112,15 +111,14 @@ public void testMethodInvocationImplementation() throws Exception { - final MethodInvocationTester tester = new MethodInvocationTester(); + final InterceptorTester tester = new InterceptorTester(); final EchoImpl target = new EchoImpl(); final Echo proxy = ( Echo ) factory.createInterceptorProxy( target, tester, ECHO_ONLY ); proxy.echo(); 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 ); + assertEquals( target, tester.proxy ); proxy.echoBack( "Hello" ); assertNotNull( tester.arguments ); assertEquals( 1, tester.arguments.length ); @@ -136,7 +134,7 @@ public void testMethodInvocationDuplicateMethods() throws Exception { - final MethodInvocationTester tester = new MethodInvocationTester(); + final InterceptorTester tester = new InterceptorTester(); final EchoImpl target = new EchoImpl(); final Echo proxy = ( Echo ) factory.createInterceptorProxy( target, tester, new Class[] { Echo.class, DuplicateEcho.class } ); proxy.echoBack( "hello" ); @@ -146,7 +144,7 @@ public void testMethodInvocationClassCaching() throws Exception { - final MethodInvocationTester tester = new MethodInvocationTester(); + final InterceptorTester tester = new InterceptorTester(); final EchoImpl target = new EchoImpl(); final Echo proxy1 = ( Echo ) factory.createInterceptorProxy( target, tester, ECHO_ONLY ); final Echo proxy2 = ( Echo ) factory.createInterceptorProxy( target, tester, new Class[] { Echo.class, DuplicateEcho.class } ); @@ -239,24 +237,24 @@ { } - private static class ChangeArgumentInterceptor implements MethodInterceptor + private static class ChangeArgumentInterceptor implements Interceptor { - public Object invoke( MethodInvocation methodInvocation ) throws Throwable + public Object intercept( Invocation methodInvocation ) throws Throwable { methodInvocation.getArguments()[0] = "something different"; return methodInvocation.proceed(); } } - protected static class NoOpMethodInterceptor implements MethodInterceptor + protected static class NoOpMethodInterceptor implements Interceptor { - public Object invoke( MethodInvocation methodInvocation ) throws Throwable + public Object intercept( Invocation methodInvocation ) throws Throwable { return methodInvocation.proceed(); } } - private static class InvocationHandlerTester implements InvocationHandler + private static class InvokerTester implements Invoker { private Object method; private Object[] args; @@ -271,20 +269,18 @@ } } - private static class MethodInvocationTester implements MethodInterceptor + private static class InterceptorTester implements Interceptor { private Object[] arguments; private Method method; - private Object target; - private AccessibleObject staticPart; + private Object proxy; private Class invocationClass; - public Object invoke( MethodInvocation methodInvocation ) throws Throwable + public Object intercept( Invocation methodInvocation ) throws Throwable { this.arguments = methodInvocation.getArguments(); this.method = methodInvocation.getMethod(); - this.target = methodInvocation.getThis(); - this.staticPart = methodInvocation.getStaticPart(); + this.proxy = methodInvocation.getProxy(); this.invocationClass = methodInvocation.getClass(); return methodInvocation.proceed(); } Modified: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/factory/AbstractSubclassingProxyFactoryTestCase.java URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/factory/AbstractSubclassingProxyFactoryTestCase.java?rev=325897&r1=325896&r2=325897&view=diff ============================================================================== --- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/factory/AbstractSubclassingProxyFactoryTestCase.java (original) +++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/factory/AbstractSubclassingProxyFactoryTestCase.java Mon Oct 17 07:11:52 2005 @@ -18,7 +18,7 @@ import org.apache.commons.proxy.ProxyFactory; import org.apache.commons.proxy.exception.ProxyFactoryException; -import org.apache.commons.proxy.handler.NullInvocationHandler; +import org.apache.commons.proxy.invoker.NullInvoker; import org.apache.commons.proxy.provider.ConstantProvider; import org.apache.commons.proxy.util.AbstractEcho; import org.apache.commons.proxy.util.Echo; @@ -71,7 +71,7 @@ public void testInvocationHandlerWithSuperclass() { final Echo echo = ( Echo ) factory - .createInvocationHandlerProxy( new NullInvocationHandler(), new Class[] { Echo.class, EchoImpl.class } ); + .createInvokerProxy( new NullInvoker(), new Class[] { Echo.class, EchoImpl.class } ); assertTrue( echo instanceof EchoImpl ); } @@ -84,7 +84,7 @@ proxy = ( Echo )factory.createInterceptorProxy( new EchoImpl(), new NoOpMethodInterceptor(), proxyClasses ); assertEquals( "final", proxy.echoBack("echo") ); - proxy = ( Echo )factory.createInvocationHandlerProxy( new NullInvocationHandler(), proxyClasses ); + proxy = ( Echo )factory.createInvokerProxy( new NullInvoker(), proxyClasses ); assertEquals( "final", proxy.echoBack("echo") ); } @@ -118,7 +118,7 @@ { try { - factory.createInvocationHandlerProxy( new NullInvocationHandler(), + factory.createInvokerProxy( new NullInvoker(), new Class[] { EchoImpl.class, String.class } ); fail(); } Copied: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestExecutorInterceptor.java (from r321183, jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestExecutorMethodInterceptor.java) URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestExecutorInterceptor.java?p2=jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestExecutorInterceptor.java&p1=jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestExecutorMethodInterceptor.java&r1=321183&r2=325897&rev=325897&view=diff ============================================================================== --- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestExecutorMethodInterceptor.java (original) +++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestExecutorInterceptor.java Mon Oct 17 07:11:52 2005 @@ -23,14 +23,14 @@ import EDU.oswego.cs.dl.util.concurrent.Executor; import EDU.oswego.cs.dl.util.concurrent.CountDown; -public class TestExecutorMethodInterceptor extends TestCase +public class TestExecutorInterceptor extends TestCase { public void testVoidMethod() throws Exception { final ExecutedEcho impl = new ExecutedEcho(); final OneShotExecutor executor = new OneShotExecutor(); final Echo proxy = ( Echo ) new CglibProxyFactory() - .createInterceptorProxy( impl, new ExecutorMethodInterceptor( executor ), new Class[] { Echo.class } ); + .createInterceptorProxy( impl, new ExecutorInterceptor( executor ), new Class[] { Echo.class } ); proxy.echo(); executor.getLatch().acquire(); assertEquals( executor.getThread(), impl.getExecutionThread() ); @@ -41,7 +41,7 @@ final ExecutedEcho impl = new ExecutedEcho(); final OneShotExecutor executor = new OneShotExecutor(); final Echo proxy = ( Echo ) new CglibProxyFactory() - .createInterceptorProxy( impl, new ExecutorMethodInterceptor( executor ), new Class[] { Echo.class } ); + .createInterceptorProxy( impl, new ExecutorInterceptor( executor ), new Class[] { Echo.class } ); try { proxy.echoBack( "hello" ); Propchange: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestExecutorInterceptor.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestExecutorInterceptor.java ------------------------------------------------------------------------------ svn:keywords = Id Copied: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestFilteredInterceptor.java (from r321183, jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestFilteredMethodInterceptor.java) URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestFilteredInterceptor.java?p2=jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestFilteredInterceptor.java&p1=jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestFilteredMethodInterceptor.java&r1=321183&r2=325897&rev=325897&view=diff ============================================================================== --- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestFilteredMethodInterceptor.java (original) +++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestFilteredInterceptor.java Mon Oct 17 07:11:52 2005 @@ -17,27 +17,27 @@ import org.apache.commons.proxy.util.Echo; import org.apache.commons.proxy.util.EchoImpl; -import org.apache.commons.proxy.util.SuffixMethodInterceptor; +import org.apache.commons.proxy.util.SuffixInterceptor; import org.apache.commons.proxy.factory.cglib.CglibProxyFactory; -import org.apache.commons.proxy.interceptor.filter.SimpleMethodFilter; -import org.aopalliance.intercept.MethodInterceptor; +import org.apache.commons.proxy.interceptor.filter.SimpleFilter; +import org.apache.commons.proxy.Interceptor; import junit.framework.TestCase; /** * @author James Carman * @version 1.0 */ -public class TestFilteredMethodInterceptor extends TestCase +public class TestFilteredInterceptor extends TestCase { public void testFilterAccepts() { - Echo echo = ( Echo ) new MethodInterceptorChain( new MethodInterceptor[] { new FilteredMethodInterceptor( new SuffixMethodInterceptor( "a" ), new SimpleMethodFilter( new String[] { "echoBack" } ) ) } ).createProxyProvider( new CglibProxyFactory(), new EchoImpl() ).getObject(); + Echo echo = ( Echo ) new InterceptorChain( new Interceptor[] { new FilteredInterceptor( new SuffixInterceptor( "a" ), new SimpleFilter( new String[] { "echoBack" } ) ) } ).createProxyProvider( new CglibProxyFactory(), new EchoImpl() ).getObject(); assertEquals( "messagea", echo.echoBack( "message" ) ); } public void testFilterDenies() { - Echo echo = ( Echo ) new MethodInterceptorChain( new MethodInterceptor[] { new FilteredMethodInterceptor( new SuffixMethodInterceptor( "a" ), new SimpleMethodFilter() ) } ).createProxyProvider( new CglibProxyFactory(), new EchoImpl() ).getObject(); + Echo echo = ( Echo ) new InterceptorChain( new Interceptor[] { new FilteredInterceptor( new SuffixInterceptor( "a" ), new SimpleFilter() ) } ).createProxyProvider( new CglibProxyFactory(), new EchoImpl() ).getObject(); assertEquals( "message", echo.echoBack( "message" ) ); } } Propchange: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestFilteredInterceptor.java ------------------------------------------------------------------------------ svn:eol-style = native Copied: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestInterceptorChain.java (from r321183, jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestMethodInterceptorChain.java) URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestInterceptorChain.java?p2=jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestInterceptorChain.java&p1=jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestMethodInterceptorChain.java&r1=321183&r2=325897&rev=325897&view=diff ============================================================================== --- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestMethodInterceptorChain.java (original) +++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestInterceptorChain.java Mon Oct 17 07:11:52 2005 @@ -16,27 +16,27 @@ package org.apache.commons.proxy.interceptor; import junit.framework.TestCase; +import org.apache.commons.proxy.Interceptor; import org.apache.commons.proxy.factory.cglib.CglibProxyFactory; import org.apache.commons.proxy.util.Echo; -import org.apache.commons.proxy.util.SuffixMethodInterceptor; import org.apache.commons.proxy.util.EchoImpl; -import org.aopalliance.intercept.MethodInterceptor; +import org.apache.commons.proxy.util.SuffixInterceptor; /** * @author James Carman * @version 1.0 */ -public class TestMethodInterceptorChain extends TestCase +public class TestInterceptorChain extends TestCase { public void testWithSingleInterceptor() { - Echo echo = ( Echo ) new MethodInterceptorChain( new MethodInterceptor[] { new SuffixMethodInterceptor( "a" ) } ).createProxyProvider( new CglibProxyFactory(), new EchoImpl(), new Class[] { Echo.class } ).getObject(); + Echo echo = ( Echo ) new InterceptorChain( new Interceptor[] { new SuffixInterceptor( "a" ) } ).createProxyProvider( new CglibProxyFactory(), new EchoImpl(), new Class[] { Echo.class } ).getObject(); assertEquals( "messagea", echo.echoBack( "message" ) ); } public void testWithMultipleInterceptors() { - Echo echo = ( Echo ) new MethodInterceptorChain( new MethodInterceptor[] { new SuffixMethodInterceptor( "a" ), new SuffixMethodInterceptor( "b" ) } ).createProxyProvider( new CglibProxyFactory(), new EchoImpl(), new Class[] { Echo.class } ).getObject(); + Echo echo = ( Echo ) new InterceptorChain( new Interceptor[] { new SuffixInterceptor( "a" ), new SuffixInterceptor( "b" ) } ).createProxyProvider( new CglibProxyFactory(), new EchoImpl(), new Class[] { Echo.class } ).getObject(); assertEquals( "messageba", echo.echoBack( "message" ) ); } } Propchange: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestInterceptorChain.java ------------------------------------------------------------------------------ svn:eol-style = native Copied: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestLoggingInterceptor.java (from r321183, jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestLoggingMethodInterceptor.java) URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestLoggingInterceptor.java?p2=jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestLoggingInterceptor.java&p1=jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestLoggingMethodInterceptor.java&r1=321183&r2=325897&rev=325897&view=diff ============================================================================== --- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestLoggingMethodInterceptor.java (original) +++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestLoggingInterceptor.java Mon Oct 17 07:11:52 2005 @@ -25,7 +25,7 @@ import java.io.IOException; -public class TestLoggingMethodInterceptor extends MockObjectTestCase +public class TestLoggingInterceptor extends MockObjectTestCase { private Mock logMock; private Echo echo; @@ -34,7 +34,7 @@ { logMock = mock( Log.class ); echo = ( Echo ) new CglibProxyFactory() - .createInterceptorProxy( new EchoImpl(), new LoggingMethodInterceptor( ( Log ) logMock.proxy() ), + .createInterceptorProxy( new EchoImpl(), new LoggingInterceptor( ( Log ) logMock.proxy() ), new Class[]{ Echo.class } ); } @@ -42,7 +42,7 @@ { logMock = mock( Log.class ); echo = ( Echo ) new CglibProxyFactory() - .createInterceptorProxy( new EchoImpl(), new LoggingMethodInterceptor( ( Log ) logMock.proxy() ), + .createInterceptorProxy( new EchoImpl(), new LoggingInterceptor( ( Log ) logMock.proxy() ), new Class[]{ Echo.class } ); logMock.expects( once() ).method( "isDebugEnabled" ).will( returnValue( false ) ); echo.echoBack( "Hello" ); Propchange: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestLoggingInterceptor.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestLoggingInterceptor.java ------------------------------------------------------------------------------ svn:keywords = Id Copied: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/filter/TestPatternFilter.java (from r321183, jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/filter/TestPatternMethodFilter.java) URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/filter/TestPatternFilter.java?p2=jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/filter/TestPatternFilter.java&p1=jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/filter/TestPatternMethodFilter.java&r1=321183&r2=325897&rev=325897&view=diff ============================================================================== --- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/filter/TestPatternMethodFilter.java (original) +++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/filter/TestPatternFilter.java Mon Oct 17 07:11:52 2005 @@ -19,21 +19,24 @@ import java.util.Date; +import org.apache.commons.proxy.interceptor.MethodFilter; + /** * @author James Carman * @version 1.0 */ -public class TestPatternMethodFilter extends TestCase +public class TestPatternFilter extends TestCase { public void testAccepts() throws Exception { - final PatternMethodFilter filter = new PatternMethodFilter( "set\\w+|get\\w+" ); + final MethodFilter filter = PatternFilter.getterSetterFilter(); assertTrue( filter.accepts( Date.class.getMethod( "getSeconds", new Class[] {} ) ) ); assertTrue( filter.accepts( Date.class.getMethod( "getMinutes", new Class[] {} ) ) ); assertTrue( filter.accepts( Date.class.getMethod( "setSeconds", new Class[] { Integer.TYPE } ) ) ); assertTrue( filter.accepts( Date.class.getMethod( "setMinutes", new Class[] { Integer.TYPE } ) ) ); assertFalse( filter.accepts( Date.class.getMethod( "toString", new Class[] {} ) ) ); assertFalse( filter.accepts( Date.class.getMethod( "hashCode", new Class[] {} ) ) ); - } + + } Propchange: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/filter/TestPatternFilter.java ------------------------------------------------------------------------------ svn:eol-style = native Copied: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/filter/TestSimpleFilter.java (from r321183, jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/filter/TestSimpleMethodFilter.java) URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/filter/TestSimpleFilter.java?p2=jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/filter/TestSimpleFilter.java&p1=jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/filter/TestSimpleMethodFilter.java&r1=321183&r2=325897&rev=325897&view=diff ============================================================================== --- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/filter/TestSimpleMethodFilter.java (original) +++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/filter/TestSimpleFilter.java Mon Oct 17 07:11:52 2005 @@ -23,11 +23,11 @@ * @author James Carman * @version 1.0 */ -public class TestSimpleMethodFilter extends TestCase +public class TestSimpleFilter extends TestCase { public void testAccepts() throws Exception { - final SimpleMethodFilter filter = new SimpleMethodFilter( new String[] { "echoBack" } ); + final SimpleFilter filter = new SimpleFilter( new String[] { "echoBack" } ); assertTrue( filter.accepts( Echo.class.getMethod( "echoBack", new Class[] { String.class } ) ) ); assertFalse( filter.accepts( EchoImpl.class.getMethod( "hashCode", new Class[] {} ) ) ); } Propchange: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/filter/TestSimpleFilter.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/invoker/TestNullInvoker.java URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/invoker/TestNullInvoker.java?rev=325897&view=auto ============================================================================== --- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/invoker/TestNullInvoker.java (added) +++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/invoker/TestNullInvoker.java Mon Oct 17 07:11:52 2005 @@ -0,0 +1,50 @@ +/* $Id$ + * + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.proxy.invoker; +import junit.framework.TestCase; +import org.apache.commons.proxy.ProxyUtils; +import org.apache.commons.proxy.factory.cglib.CglibProxyFactory; + +public class TestNullInvoker extends TestCase +{ + public void testReturnValues() + { + final Tester tester = ( Tester )ProxyUtils.createNullObject( new CglibProxyFactory(), new Class[] { Tester.class } ); + assertEquals( 0, tester.intMethod() ); + assertEquals( 0L, tester.longMethod() ); + assertEquals( ( short )0, tester.shortMethod() ); + assertEquals( ( byte )0, tester.byteMethod() ); + assertEquals( ( char )0, tester.charMethod() ); + assertEquals( 0.0f, tester.floatMethod(), 0.0f ); + assertEquals( 0.0, tester.doubleMethod(), 0.0f ); + assertFalse( tester.booleanMethod() ); + assertNull( tester.stringMethod() ); + } + + public static interface Tester + { + public int intMethod(); + public long longMethod(); + public short shortMethod(); + public byte byteMethod(); + public char charMethod(); + public double doubleMethod(); + public float floatMethod(); + public String stringMethod(); + public boolean booleanMethod(); + } +} \ No newline at end of file Propchange: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/invoker/TestNullInvoker.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/invoker/TestNullInvoker.java ------------------------------------------------------------------------------ svn:keywords = Id Added: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/invoker/TestXmlRpcInvoker.java URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/invoker/TestXmlRpcInvoker.java?rev=325897&view=auto ============================================================================== --- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/invoker/TestXmlRpcInvoker.java (added) +++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/invoker/TestXmlRpcInvoker.java Mon Oct 17 07:11:52 2005 @@ -0,0 +1,103 @@ +/* $Id$ + * + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.proxy.invoker; + +import junit.extensions.TestSetup; +import junit.framework.Protectable; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestResult; +import junit.framework.TestSuite; +import org.apache.commons.proxy.exception.InvocationHandlerException; +import org.apache.commons.proxy.factory.cglib.CglibProxyFactory; +import org.apache.commons.proxy.util.Echo; +import org.apache.commons.proxy.util.EchoImpl; +import org.apache.xmlrpc.WebServer; +import org.apache.xmlrpc.XmlRpcClient; +import org.apache.xmlrpc.XmlRpcClientLite; + +/** + * @author James Carman + */ +public class TestXmlRpcInvoker extends TestCase +{ + private static WebServer server; + private static XmlRpcClient client; + + public static Test suite() + { + return new TestSetup( new TestSuite( TestXmlRpcInvoker.class ) ) + { + public void run( final TestResult testResult ) + { + Protectable p = new Protectable() + { + public void protect() throws Throwable + { + try + { + setUp(); + basicRun( testResult ); + } + finally + { + tearDown(); + } + } + }; + testResult.runProtected( this, p ); + } + + protected void setUp() throws Exception + { + server = new WebServer( 9999 ); + server.addHandler( "echo", new EchoImpl() ); + server.start(); + client = new XmlRpcClientLite( "http://localhost:9999/RPC2" ); + } + + protected void tearDown() throws Exception + { + server.shutdown(); + } + }; + } + + public void testInvalidHandlerName() + { + final XmlRpcInvoker handler = new XmlRpcInvoker( client, "invalid" ); + final Echo echo = ( Echo ) new CglibProxyFactory() + .createInvokerProxy( handler, new Class[]{ Echo.class } ); + try + { + echo.echoBack( "Hello" ); + fail(); + } + catch( InvocationHandlerException e ) + { + } + } + + public void testValidInvocation() throws Exception + { + final XmlRpcInvoker handler = new XmlRpcInvoker( client, "echo" ); + final Echo echo = ( Echo ) new CglibProxyFactory() + .createInvokerProxy( handler, new Class[]{ Echo.class } ); + assertEquals( "Hello", echo.echoBack( "Hello" ) ); + + } +} \ No newline at end of file Propchange: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/invoker/TestXmlRpcInvoker.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/invoker/TestXmlRpcInvoker.java ------------------------------------------------------------------------------ svn:keywords = Id Copied: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/SuffixInterceptor.java (from r321183, jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/SuffixMethodInterceptor.java) URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/SuffixInterceptor.java?p2=jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/SuffixInterceptor.java&p1=jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/SuffixMethodInterceptor.java&r1=321183&r2=325897&rev=325897&view=diff ============================================================================== --- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/SuffixMethodInterceptor.java (original) +++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/SuffixInterceptor.java Mon Oct 17 07:11:52 2005 @@ -15,24 +15,24 @@ */ package org.apache.commons.proxy.util; -import org.aopalliance.intercept.MethodInterceptor; -import org.aopalliance.intercept.MethodInvocation; +import org.apache.commons.proxy.Invocation; +import org.apache.commons.proxy.Interceptor; /** * @author James Carman * @version 1.0 */ -public class SuffixMethodInterceptor implements MethodInterceptor +public class SuffixInterceptor implements Interceptor { private final String suffix; - public SuffixMethodInterceptor( String suffix ) + public SuffixInterceptor( String suffix ) { this.suffix = suffix; } - public Object invoke( MethodInvocation methodInvocation ) throws Throwable + public Object intercept( Invocation methodInvocation ) throws Throwable { - return methodInvocation.proceed() + suffix; + return methodInvocation.proceed() + suffix; } } Propchange: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/SuffixInterceptor.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: jakarta/commons/sandbox/proxy/trunk/xdocs/index.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/xdocs/index.xml?rev=325897&r1=325896&r2=325897&view=diff ============================================================================== --- jakarta/commons/sandbox/proxy/trunk/xdocs/index.xml (original) +++ jakarta/commons/sandbox/proxy/trunk/xdocs/index.xml Mon Oct 17 07:11:52 2005 @@ -36,8 +36,8 @@ <li><b>Performance Monitoring</b> - the proxy can log each method invocation to a performance monitor allowing system administrators to see what parts of the system are potentially bogged down.</li> </ul> - <em>Commons Proxy</em> supports dynamic proxy generation using proxy factories, object providers, invocation handlers, and - method interceptors. + <em>Commons Proxy</em> supports dynamic proxy generation using proxy factories, object providers, invokers, and + interceptors. </p> <section name="Proxy Factories"> <p> @@ -51,10 +51,10 @@ <ul> <li><b>Delegator Proxies</b> - a proxy that merely delegates each method invocation to an object provided by an <a href="apidocs/org/apache/commons/proxy/ObjectProvider.html">object provider</a>.</li> - <li><b>Interceptor Proxies</b> - a proxy that allows a <a href="http://aopalliance.sourceforge.net/doc/org/aopalliance/intercept/MethodInterceptor.html">method interceptor</a> to intercept each - method invocation.</li> - <li><b>Invocation Handler Proxies</b> - a proxy that uses an - <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/InvocationHandler.html">invocation handler</a> to handle all method + <li><b>Interceptor Proxies</b> - a proxy that allows an <a href="apidocs/org/apache/commons/proxy/Interceptor.html">Interceptor</a> to intercept each + method invocation as it makes its way to the target of the invocation.</li> + <li><b>Invoker Proxies</b> - a proxy that uses an + <a href="apidocs/org/apache/commons/proxy/Invoker.html">invoker</a> to handle all method invocations.</li> </ul> @@ -95,23 +95,25 @@ </p> </section> - <section name="Invocation Handlers"> + <section name="Invokers"> <p> - An <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/reflect/InvocationHandler.html">invocation handler</a> handles all - method invocations using a single method. <em>Commons Proxy</em> provides a couple invocation handler implementations: + An <a href="apidocs/org/apache/commons/proxy/Invoker.html">invoker</a> handles all + method invocations using a single method. <em>Commons Proxy</em> provides a few invoker implementations: <table border="0"> - <tr><td><b>Null</b></td><td>Always returns a null (useful for the "Null Object" pattern)</td></tr> - <tr><td><b>Apache XML-RPC</b></td><td>Uses <a href="http://ws.apache.org/xmlrpc/">Apache XML-RPC</a> to fulfill the method invocation</td></tr> - </table> + <tr><td><b>Null</b></td><td>Always returns a null (useful for the "Null Object" pattern)</td></tr> + <tr><td><b>Apache XML-RPC</b></td><td>Uses <a href="http://ws.apache.org/xmlrpc/">Apache XML-RPC</a> to fulfill the method invocation</td></tr> + <tr><td><b>Invocation Handler Adapter</b></td><td>Adapts the JDK <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/reflect/InvocationHandler.html">InvocationHandler</a> interface + to the <em>Commons Proxy</em> <a href="apidocs/org/apache/commons/proxy/Invoker.html">Invoker</a> interface.</td></tr> + </table> </p> </section> - <section name="Method Interceptors"> + <section name="Interceptors"> <p> - <cm>Commons Proxy</cm> uses the <a href="http://aopalliance.sourceforge.net">AOP Alliance</a> API - for method interceptor support. Method interceptors provide <em>rudimentary</em> aspect-oriented + <cm>Commons Proxy</cm> allows you to "intercept" a method invocation using <a href="apidocs/org/apache/commons/proxy/Interceptor.html">Interceptors</a>. + Interceptors provide <em>rudimentary</em> aspect-oriented programming support, allowing you to alter the results/effects of a method invocation without actually - changing the implementation of the method itself. <em>Commons Proxy</em> provides a few method interceptor + changing the implementation of the method itself. <em>Commons Proxy</em> provides a few interceptor implementations including: <table border="0"> <tr><td><b>Executor</b></td><td>Uses an @@ -120,6 +122,9 @@ <a href="http://jakarta.apache.org/commons/logging/">Jakarta Commons Logging</a> API</td></tr> <tr><td><b>Filtered</b></td><td>Optionally intercepts a method invocation based on a <a href="apidocs/org/apache/commons/proxy/interceptor/MethodFilter.html">method filter</a></td></tr> + <tr><td><b>Method Interceptor Adapter</b></td><td>Adapts the AOP Alliance <a href="http://aopalliance.sourceforge.net/doc/org/aopalliance/intercept/MethodInterceptor.html">MethodInterceptor</a> interface to the + <em>Commons Proxy</em> <a href="apidocs/org/apache/commons/proxy/Interceptor.html">Interceptor</a> interface.</td></tr> + </table> </p> </section> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]