Author: mbenson Date: Tue Jul 20 20:44:26 2010 New Revision: 965999 URL: http://svn.apache.org/viewvc?rev=965999&view=rev Log: switch to least number of interface methods that will accomplish all of: varargs/typesafe results/optional classloader
Modified: commons/proper/proxy/branches/version-2.0-work/core/src/main/java/org/apache/commons/proxy2/ProxyFactory.java commons/proper/proxy/branches/version-2.0-work/core/src/main/java/org/apache/commons/proxy2/impl/AbstractProxyFactory.java Modified: commons/proper/proxy/branches/version-2.0-work/core/src/main/java/org/apache/commons/proxy2/ProxyFactory.java URL: http://svn.apache.org/viewvc/commons/proper/proxy/branches/version-2.0-work/core/src/main/java/org/apache/commons/proxy2/ProxyFactory.java?rev=965999&r1=965998&r2=965999&view=diff ============================================================================== --- commons/proper/proxy/branches/version-2.0-work/core/src/main/java/org/apache/commons/proxy2/ProxyFactory.java (original) +++ commons/proper/proxy/branches/version-2.0-work/core/src/main/java/org/apache/commons/proxy2/ProxyFactory.java Tue Jul 20 20:44:26 2010 @@ -28,77 +28,6 @@ public interface ProxyFactory //********************************************************************************************************************** /** - * Creates a proxy2 which delegates to the object provided by <code>delegateProvider</code>. - * - * @param classLoader the class loader to use when generating the proxy2 - * @param delegateProvider the delegate provider - * @param proxyClass the class/interface that the proxy2 should implement - * @return a proxy2 which delegates to the object provided by the target <code>delegateProvider> - */ - public <T> T createDelegatorProxy( ClassLoader classLoader, ObjectProvider<T> delegateProvider, - Class<T> proxyClass ); - - /** - * Creates a proxy2 which passes through a {...@link Interceptor interceptor} before eventually reaching the - * <code>target</code> object. The proxy2 will be generated using the current thread's "context class loader." - * - * @param target the target object - * @param interceptor the method interceptor - * @param proxyClass the class/interface that the proxy2 should implement - * @return a proxy2 which passes through a {...@link Interceptor interceptor} before eventually reaching the - * <code>target</code> object. - */ - public <T> T createInterceptorProxy( Object target, Interceptor interceptor, - Class<T> proxyClass ); - - /** - * Creates a proxy2 which passes through a {...@link Interceptor interceptor} before eventually reaching the - * <code>target</code> object. - * - * @param classLoader the class loader to use when generating the proxy2 - * @param target the target object - * @param interceptor the method interceptor - * @param proxyClass the class/interface that the proxy2 should implement. - * @return a proxy2 which passes through a {...@link Interceptor interceptor} before eventually reaching the - * <code>target</code> object. - */ - public <T> T createInterceptorProxy( ClassLoader classLoader, - Object target, - Interceptor interceptor, - Class<T> proxyClass ); - - /** - * Creates a proxy2 which uses the provided {...@link Invoker} to handle all method invocations. The proxy2 will be - * generated using the current thread's "context class loader." - * - * @param invoker the invoker - * @param proxyClass the class/interface that the proxy2 should implement - * @return a proxy2 which uses the provided {...@link Invoker} to handle all method invocations - */ - public <T> T createInvokerProxy( Invoker invoker, Class<T> proxyClass ); - - /** - * Creates a proxy2 which uses the provided {...@link Invoker} to handle all method invocations. - * - * @param classLoader the class loader to use when generating the proxy2 - * @param invoker the invoker - * @param proxyClass the class/interface that the proxy2 should implement - * @return a proxy2 which uses the provided {...@link Invoker} to handle all method invocations - */ - public <T> T createInvokerProxy( ClassLoader classLoader, Invoker invoker, - Class<T> proxyClass ); - - /** - * Creates a proxy2 which delegates to the object provided by <code>delegateProvider</code>. The proxy2 will be - * generated using the current thread's "context class loader." - * - * @param delegateProvider the delegate provider - * @param proxyClass the class/interface that the proxy2 should implement - * @return a proxy2 which delegates to the object provided by the target object provider - */ - public <T> T createDelegatorProxy( ObjectProvider<T> delegateProvider, Class<T> proxyClass ); - - /** * Learn whether this {...@link ProxyFactory} is capable of creating a proxy2 for the specified set of classes. * * @param proxyClasses the proxy2 classes @@ -114,7 +43,7 @@ public interface ProxyFactory * @param proxyClasses the interfaces that the proxy2 should implement * @return a proxy2 which delegates to the object provided by the target object provider */ - public Object createDelegatorProxy( ObjectProvider<?> delegateProvider, Class<?>... proxyClasses ); + public <T> T createDelegatorProxy( ObjectProvider<?> delegateProvider, Class<?>... proxyClasses ); /** * Creates a proxy2 which delegates to the object provided by <code>delegateProvider</code>. @@ -124,7 +53,7 @@ public interface ProxyFactory * @param proxyClasses the interfaces that the proxy2 should implement * @return a proxy2 which delegates to the object provided by the target <code>delegateProvider> */ - public Object createDelegatorProxy( ClassLoader classLoader, ObjectProvider<?> delegateProvider, + public <T> T createDelegatorProxy( ClassLoader classLoader, ObjectProvider<?> delegateProvider, Class<?>... proxyClasses ); /** @@ -137,7 +66,7 @@ public interface ProxyFactory * @return a proxy2 which passes through a {...@link Interceptor interceptor} before eventually reaching the * <code>target</code> object. */ - public Object createInterceptorProxy( Object target, Interceptor interceptor, + public <T> T createInterceptorProxy( Object target, Interceptor interceptor, Class<?>... proxyClasses ); /** @@ -151,7 +80,7 @@ public interface ProxyFactory * @return a proxy2 which passes through a {...@link Interceptor interceptor} before eventually reaching the * <code>target</code> object. */ - public Object createInterceptorProxy( ClassLoader classLoader, Object target, Interceptor interceptor, + public <T> T createInterceptorProxy( ClassLoader classLoader, Object target, Interceptor interceptor, Class<?>... proxyClasses ); /** @@ -162,7 +91,7 @@ public interface ProxyFactory * @param proxyClasses the interfaces that the proxy2 should implement * @return a proxy2 which uses the provided {...@link Invoker} to handle all method invocations */ - public Object createInvokerProxy( Invoker invoker, Class<?>... proxyClasses ); + public <T> T createInvokerProxy( Invoker invoker, Class<?>... proxyClasses ); /** * Creates a proxy2 which uses the provided {...@link Invoker} to handle all method invocations. @@ -172,6 +101,6 @@ public interface ProxyFactory * @param proxyClasses the interfaces that the proxy2 should implement * @return a proxy2 which uses the provided {...@link Invoker} to handle all method invocations */ - public Object createInvokerProxy( ClassLoader classLoader, Invoker invoker, + public <T> T createInvokerProxy( ClassLoader classLoader, Invoker invoker, Class<?>... proxyClasses ); } Modified: commons/proper/proxy/branches/version-2.0-work/core/src/main/java/org/apache/commons/proxy2/impl/AbstractProxyFactory.java URL: http://svn.apache.org/viewvc/commons/proper/proxy/branches/version-2.0-work/core/src/main/java/org/apache/commons/proxy2/impl/AbstractProxyFactory.java?rev=965999&r1=965998&r2=965999&view=diff ============================================================================== --- commons/proper/proxy/branches/version-2.0-work/core/src/main/java/org/apache/commons/proxy2/impl/AbstractProxyFactory.java (original) +++ commons/proper/proxy/branches/version-2.0-work/core/src/main/java/org/apache/commons/proxy2/impl/AbstractProxyFactory.java Tue Jul 20 20:44:26 2010 @@ -55,41 +55,12 @@ public abstract class AbstractProxyFacto * @param proxyClasses the interfaces that the proxy2 should implement * @return a proxy2 which delegates to the object provided by the target object provider */ - public Object createDelegatorProxy( ObjectProvider<?> delegateProvider, Class<?>... proxyClasses ) + public <T> T createDelegatorProxy( ObjectProvider<?> delegateProvider, Class<?>... proxyClasses ) { return createDelegatorProxy(Thread.currentThread().getContextClassLoader(), delegateProvider, proxyClasses); } /** - * Creates a proxy2 which delegates to the object provided by <code>delegateProvider</code>. The proxy2 will be - * generated using the current thread's "context class loader." - * - * @param delegateProvider the delegate provider - * @param proxyClass the class/interface that the proxy2 should implement - * @return a proxy2 which delegates to the object provided by the target object provider - */ - @SuppressWarnings("unchecked") - public <T> T createDelegatorProxy( ObjectProvider<T> delegateProvider, Class<T> proxyClass ) - { - return (T)createDelegatorProxy(delegateProvider, new Class[] {proxyClass}); - } - - /** - * Creates a proxy2 which delegates to the object provided by <code>delegateProvider</code>. - * - * @param classLoader the class loader to use when generating the proxy2 - * @param delegateProvider the delegate provider - * @param proxyClass the class/interface that the proxy2 should implement - * @return a proxy2 which delegates to the object provided by the target <code>delegateProvider> - */ - @SuppressWarnings( "unchecked" ) - public <T> T createDelegatorProxy( ClassLoader classLoader, ObjectProvider<T> delegateProvider, - Class<T> proxyClass ) - { - return ( T ) createDelegatorProxy(classLoader, delegateProvider, new Class[] {proxyClass}); - } - - /** * Creates a proxy2 which passes through a {...@link Interceptor interceptor} before eventually reaching the * <code>target</code> object. The proxy2 will be generated using the current thread's "context class loader." * @@ -99,7 +70,7 @@ public abstract class AbstractProxyFacto * @return a proxy2 which passes through a {...@link Interceptor interceptor} before eventually reaching the * <code>target</code> object. */ - public Object createInterceptorProxy( Object target, Interceptor interceptor, + public <T> T createInterceptorProxy( Object target, Interceptor interceptor, Class<?>... proxyClasses ) { return createInterceptorProxy(Thread.currentThread().getContextClassLoader(), target, interceptor, @@ -107,43 +78,6 @@ public abstract class AbstractProxyFacto } /** - * Creates a proxy2 which passes through a {...@link Interceptor interceptor} before eventually reaching the - * <code>target</code> object. The proxy2 will be generated using the current thread's "context class loader." - * - * @param target the target object - * @param interceptor the method interceptor - * @param proxyClass the class/interface that the proxy2 should implement - * @return a proxy2 which passes through a {...@link Interceptor interceptor} before eventually reaching the - * <code>target</code> object. - */ - @SuppressWarnings( "unchecked" ) - public <T> T createInterceptorProxy( Object target, Interceptor interceptor, - Class<T> proxyClass ) - { - return ( T ) createInterceptorProxy(target, interceptor, new Class[] {proxyClass}); - } - - /** - * Creates a proxy2 which passes through a {...@link Interceptor interceptor} before eventually reaching the - * <code>target</code> object. - * - * @param classLoader the class loader to use when generating the proxy2 - * @param target the target object - * @param interceptor the method interceptor - * @param proxyClass the class/interface that the proxy2 should implement. - * @return a proxy2 which passes through a {...@link Interceptor interceptor} before eventually reaching the - * <code>target</code> object. - */ - @SuppressWarnings( "unchecked" ) - public <T> T createInterceptorProxy( ClassLoader classLoader, - Object target, - Interceptor interceptor, - Class<T> proxyClass ) - { - return ( T ) createInterceptorProxy(classLoader, target, interceptor, new Class[] {proxyClass}); - } - - /** * Creates a proxy2 which uses the provided {...@link Invoker} to handle all method invocations. The proxy2 will be * generated using the current thread's "context class loader." * @@ -151,39 +85,10 @@ public abstract class AbstractProxyFacto * @param proxyClasses the interfaces that the proxy2 should implement * @return a proxy2 which uses the provided {...@link Invoker} to handle all method invocations */ - public Object createInvokerProxy( Invoker invoker, Class<?>... proxyClasses ) + public <T> T createInvokerProxy( Invoker invoker, Class<?>... proxyClasses ) { return createInvokerProxy(Thread.currentThread().getContextClassLoader(), invoker, proxyClasses); } - /** - * Creates a proxy2 which uses the provided {...@link Invoker} to handle all method invocations. The proxy2 will be - * generated using the current thread's "context class loader." - * - * @param invoker the invoker - * @param proxyClass the class/interface that the proxy2 should implement - * @return a proxy2 which uses the provided {...@link Invoker} to handle all method invocations - */ - @SuppressWarnings( "unchecked" ) - public <T> T createInvokerProxy( Invoker invoker, Class<T> proxyClass ) - { - return ( T ) createInvokerProxy(invoker, new Class[] {proxyClass}); - } - - /** - * Creates a proxy2 which uses the provided {...@link Invoker} to handle all method invocations. - * - * @param classLoader the class loader to use when generating the proxy2 - * @param invoker the invoker - * @param proxyClass the class/interface that the proxy2 should implement - * @return a proxy2 which uses the provided {...@link Invoker} to handle all method invocations - */ - @SuppressWarnings( "unchecked" ) - public <T> T createInvokerProxy( ClassLoader classLoader, Invoker invoker, - Class<T> proxyClass ) - { - return ( T ) createInvokerProxy(classLoader, invoker, new Class[] {proxyClass}); - } - }