commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jcar...@apache.org
Subject svn commit: r345665 - in /jakarta/commons/sandbox/proxy/trunk/src: java/org/apache/commons/proxy/ test/org/apache/commons/proxy/ test/org/apache/commons/proxy/interceptor/ test/org/apache/commons/proxy/invoker/ test/org/apache/commons/proxy/provider/
Date Sat, 19 Nov 2005 18:38:02 GMT
Author: jcarman
Date: Sat Nov 19 10:37:57 2005
New Revision: 345665

URL: http://svn.apache.org/viewcvs?rev=345665&view=rev
Log:
Removed ProxyUtils.getProxyFactory() method.

Modified:
    jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/ProxyUtils.java
    jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/TestProxyUtils.java
    jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestMethodInterceptorAdapter.java
    jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/invoker/TestInvocationHandlerAdapter.java
    jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/provider/TestJaxRpcProvider.java
    jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/provider/TestPooledProvider.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=345665&r1=345664&r2=345665&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
Sat Nov 19 10:37:57 2005
@@ -16,7 +16,6 @@
  */
 package org.apache.commons.proxy;
 
-import org.apache.commons.proxy.exception.ProxyFactoryException;
 import org.apache.commons.proxy.invoker.NullInvoker;
 
 import java.util.LinkedList;
@@ -125,81 +124,6 @@
             return getJavaClassName( clazz.getComponentType() ) + "[]";
         }
         return clazz.getName();
-    }
-
-    /**
-     * Returns an appropriate {@link ProxyFactory} implementation for the current environment.
The implementation class
-     * search order is as follows: <ul> <li>Try to use the type indicated by
the system property
-     * "commons-proxy.factory"</li> <li>Try to use
-     * {@link org.apache.commons.proxy.factory.javassist.JavassistProxyFactory}</li>
-     * <li>Try to use {@link org.apache.commons.proxy.factory.cglib.CglibProxyFactory}</li>
<li>Default to {@link
-     * org.apache.commons.proxy.factory.reflect.ReflectionProxyFactory} (should always be
available)</li> </ul>
-     *
-     * @param classLoader the class loader to use to instantiate the proxy factory
-     * @return an appropriate {@link ProxyFactory} implementation for the current environment
-     */
-    public static ProxyFactory getProxyFactory( ClassLoader classLoader )
-    {
-        final String[] classNames = new String[]{ System.getProperty( PROXY_FACTORY_PROPERTY
),
-                "org.apache.commons.proxy.factory.javassist.JavassistProxyFactory",
-                "org.apache.commons.proxy.factory.cglib.CglibProxyFactory",
-                "org.apache.commons.proxy.factory.reflect.ReflectionProxyFactory" };
-        for( int i = 0; i < classNames.length; i++ )
-        {
-            final String className = classNames[i];
-            final ProxyFactory factory = instantiateProxyFactory( className, classLoader
);
-            if( factory != null )
-            {
-                return factory;
-            }
-        }
-        throw new ProxyFactoryException( "Unable to find a suitable proxy factory implementation
class." );
-    }
-
-    /**
-     * Returns an appropriate {@link ProxyFactory} implementation for the current environment.
The implementation class
-     * search order is as follows: <ul> <li>Try to the type indicated by the
system property
-     * "commons-proxy.factory"</li> <li>Try to use
-     * {@link org.apache.commons.proxy.factory.javassist.JavassistProxyFactory}</li>
-     * <li>Try to use {@link org.apache.commons.proxy.factory.cglib.CglibProxyFactory}</li>
<li>Default to {@link
-     * org.apache.commons.proxy.factory.reflect.ReflectionProxyFactory} (should always be
available)</li> </ul>
-     * <p/>
-     * <b>Note</b>: This implementation uses the current thread's context class
loader!
-     *
-     * @return an appropriate {@link ProxyFactory} implementation for the current environment
-     */
-    public static ProxyFactory getProxyFactory()
-    {
-        return getProxyFactory( Thread.currentThread().getContextClassLoader() );
-    }
-
-    private static ProxyFactory instantiateProxyFactory( String className, ClassLoader classLoader
)
-    {
-        try
-        {
-            if( className == null )
-            {
-                return null;
-            }
-            Class proxyFactoryClass = classLoader.loadClass( className );
-            if( !ProxyFactory.class.isAssignableFrom( proxyFactoryClass ) )
-            {
-                return null;
-            }
-            return ( ProxyFactory ) proxyFactoryClass.newInstance();
-        }
-        catch( IllegalAccessException e )
-        {
-            return null;
-        }
-        catch( InstantiationException e )
-        {
-            return null;
-        }
-        catch( ClassNotFoundException e )
-        {
-            return null;
-        }
     }
 }
 

Modified: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/TestProxyUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/TestProxyUtils.java?rev=345665&r1=345664&r2=345665&view=diff
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/TestProxyUtils.java
(original)
+++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/TestProxyUtils.java
Sat Nov 19 10:37:57 2005
@@ -17,11 +17,7 @@
 package org.apache.commons.proxy;
 
 import junit.framework.TestCase;
-import org.apache.commons.proxy.exception.ProxyFactoryException;
-import org.apache.commons.proxy.factory.cglib.CglibProxyFactory;
 import org.apache.commons.proxy.factory.javassist.JavassistProxyFactory;
-import org.apache.commons.proxy.factory.reflect.ReflectionProxyFactory;
-import org.apache.commons.proxy.factory.util.AbstractProxyFactory;
 import org.apache.commons.proxy.util.DuplicateEcho;
 import org.apache.commons.proxy.util.Echo;
 import org.apache.commons.proxy.util.EchoImpl;
@@ -83,73 +79,5 @@
         assertEquals( "byte", ProxyUtils.getJavaClassName( Byte.TYPE ) );
         assertEquals( "char", ProxyUtils.getJavaClassName( Character.TYPE ) );
         assertEquals( "boolean", ProxyUtils.getJavaClassName( Boolean.TYPE ) );
-    }
-
-
-
-    public void testGetProxyFactory() throws Exception
-    {
-        assertTrue( ProxyUtils.getProxyFactory() instanceof JavassistProxyFactory );
-        System.setProperty( ProxyUtils.PROXY_FACTORY_PROPERTY, "java.lang.String" );
-        assertTrue( ProxyUtils.getProxyFactory() instanceof JavassistProxyFactory );
-        System.setProperty( ProxyUtils.PROXY_FACTORY_PROPERTY, CglibProxyFactory.class.getName()
);
-        assertTrue( ProxyUtils.getProxyFactory() instanceof CglibProxyFactory );
-        System.setProperty( ProxyUtils.PROXY_FACTORY_PROPERTY, ReflectionProxyFactory.class.getName()
);
-        assertTrue( ProxyUtils.getProxyFactory() instanceof ReflectionProxyFactory );
-        System.setProperty( ProxyUtils.PROXY_FACTORY_PROPERTY, "" );
-        ClassLoader cl = new IsolatingClassLoader( JavassistProxyFactory.class,
-                                                   Thread.currentThread().getContextClassLoader()
);
-        assertTrue( ProxyUtils.getProxyFactory( cl ) instanceof CglibProxyFactory );
-        cl = new IsolatingClassLoader( CglibProxyFactory.class, cl );
-        assertTrue( ProxyUtils.getProxyFactory( cl ) instanceof ReflectionProxyFactory );
-        cl = new IsolatingClassLoader( ReflectionProxyFactory.class, cl );
-        try
-        {
-            ProxyUtils.getProxyFactory( cl );
-            fail();
-        }
-        catch( ProxyFactoryException e )
-        {
-        }
-    }
-
-    public void testPrivateProxyFactoryConstructor()
-    {
-        System.setProperty( ProxyUtils.PROXY_FACTORY_PROPERTY, PrivateProxyFactory.class.getName()
);
-        assertTrue( ProxyUtils.getProxyFactory() instanceof JavassistProxyFactory );
-
-    }
-
-    public void testNonConcreteProxyFactoryClass()
-    {
-        System.setProperty( ProxyUtils.PROXY_FACTORY_PROPERTY, AbstractProxyFactory.class.getName()
);
-        assertTrue( ProxyUtils.getProxyFactory() instanceof JavassistProxyFactory );
-    }
-
-    private static class IsolatingClassLoader extends ClassLoader
-    {
-        private Class isolatedClass;
-
-        public IsolatingClassLoader( Class isolatedClass, ClassLoader parent )
-        {
-            super( parent );
-            this.isolatedClass = isolatedClass;
-        }
-
-        public Class loadClass( String name ) throws ClassNotFoundException
-        {
-            if( isolatedClass.getName().equals( name ) )
-            {
-                throw new ClassNotFoundException( name + " not found." );
-            }
-            return getParent().loadClass( name );
-        }
-    }
-
-    public static class PrivateProxyFactory extends ReflectionProxyFactory
-    {
-        private PrivateProxyFactory()
-        {
-        }
     }
 }

Modified: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestMethodInterceptorAdapter.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestMethodInterceptorAdapter.java?rev=345665&r1=345664&r2=345665&view=diff
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestMethodInterceptorAdapter.java
(original)
+++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestMethodInterceptorAdapter.java
Sat Nov 19 10:37:57 2005
@@ -20,6 +20,7 @@
 import org.aopalliance.intercept.MethodInterceptor;
 import org.aopalliance.intercept.MethodInvocation;
 import org.apache.commons.proxy.ProxyUtils;
+import org.apache.commons.proxy.factory.javassist.JavassistProxyFactory;
 import org.apache.commons.proxy.util.Echo;
 import org.apache.commons.proxy.util.EchoImpl;
 
@@ -27,7 +28,7 @@
 {
     public void testMethodInterception()
     {
-        final Echo proxy = ( Echo ) ProxyUtils.getProxyFactory().createInterceptorProxy(
new EchoImpl(),
+        final Echo proxy = ( Echo ) new JavassistProxyFactory().createInterceptorProxy( new
EchoImpl(),
                                                                                         
new MethodInterceptorAdapter( new SuffixMethodInterceptor(
                                                                                         
        " suffix" ) ),
                                                                                         
new Class[]{ Echo.class } );
@@ -38,7 +39,7 @@
     {
         final InterceptorTester tester = new InterceptorTester();
         final EchoImpl target = new EchoImpl();
-        final Echo proxy = ( Echo ) ProxyUtils.getProxyFactory().createInterceptorProxy(
target, new MethodInterceptorAdapter( tester ), new Class[] { Echo.class } );
+        final Echo proxy = ( Echo ) new JavassistProxyFactory().createInterceptorProxy( target,
new MethodInterceptorAdapter( tester ), new Class[] { Echo.class } );
         proxy.echo();
         assertNotNull( tester.invocation.getArguments() );
         assertEquals( 0, tester.invocation.getArguments().length );

Modified: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/invoker/TestInvocationHandlerAdapter.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/invoker/TestInvocationHandlerAdapter.java?rev=345665&r1=345664&r2=345665&view=diff
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/invoker/TestInvocationHandlerAdapter.java
(original)
+++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/invoker/TestInvocationHandlerAdapter.java
Sat Nov 19 10:37:57 2005
@@ -15,10 +15,9 @@
  * limitations under the License.
  */
 package org.apache.commons.proxy.invoker;
-import junit.framework.*;
-import org.apache.commons.proxy.invoker.InvocationHandlerAdapter;
+import junit.framework.TestCase;
+import org.apache.commons.proxy.factory.javassist.JavassistProxyFactory;
 import org.apache.commons.proxy.util.Echo;
-import org.apache.commons.proxy.ProxyUtils;
 
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
@@ -28,7 +27,7 @@
     public void testMethodInvocation() throws Exception
     {
         InvocationHandlerTester tester = new InvocationHandlerTester();
-        final Echo echo = ( Echo ) ProxyUtils.getProxyFactory().createInvokerProxy( new InvocationHandlerAdapter(
tester ), new Class[] { Echo.class } );
+        final Echo echo = ( Echo ) new JavassistProxyFactory().createInvokerProxy( new InvocationHandlerAdapter(
tester ), new Class[] { Echo.class } );
         echo.echoBack( "hello" );
         assertEquals( Echo.class.getMethod( "echoBack", new Class[] { String.class } ), tester.method
);
         assertSame( echo, tester.proxy );

Modified: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/provider/TestJaxRpcProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/provider/TestJaxRpcProvider.java?rev=345665&r1=345664&r2=345665&view=diff
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/provider/TestJaxRpcProvider.java
(original)
+++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/provider/TestJaxRpcProvider.java
Sat Nov 19 10:37:57 2005
@@ -25,6 +25,7 @@
         provider.setWsdlUrl( "http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl"
);
         provider.setServiceNamespaceUri( "http://www.themindelectric.com/wsdl/net.xmethods.services.stockquote.StockQuote/"
);
         provider.setServiceLocalPart( "net.xmethods.services.stockquote.StockQuoteService"
);
+        provider.setPortNamespaceUri( "http://www.themindelectric.com/wsdl/net.xmethods.services.stockquote.StockQuote/"
);
         provider.setPortLocalPart( "net.xmethods.services.stockquote.StockQuotePort" );
         final QuoteService quote = ( QuoteService )provider.getObject();
         assertNotNull( quote );

Modified: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/provider/TestPooledProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/provider/TestPooledProvider.java?rev=345665&r1=345664&r2=345665&view=diff
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/provider/TestPooledProvider.java
(original)
+++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/provider/TestPooledProvider.java
Sat Nov 19 10:37:57 2005
@@ -18,13 +18,13 @@
 import EDU.oswego.cs.dl.util.concurrent.CountDown;
 import junit.framework.TestCase;
 import org.apache.commons.pool.impl.GenericObjectPool;
+import org.apache.commons.proxy.ObjectProvider;
+import org.apache.commons.proxy.exception.ObjectProviderException;
+import org.apache.commons.proxy.factory.javassist.JavassistProxyFactory;
 import org.apache.commons.proxy.provider.cache.SimpleCache;
 import org.apache.commons.proxy.provider.cache.ThreadLocalCache;
 import org.apache.commons.proxy.util.Echo;
 import org.apache.commons.proxy.util.EchoImpl;
-import org.apache.commons.proxy.ObjectProvider;
-import org.apache.commons.proxy.ProxyUtils;
-import org.apache.commons.proxy.exception.ObjectProviderException;
 
 public class TestPooledProvider extends TestCase
 {
@@ -91,7 +91,7 @@
                 final SimpleCache cache = new SimpleCache();
                 provider.setCache( cache );
 
-        final Echo echo = ( Echo )ProxyUtils.getProxyFactory().createDelegatorProxy( provider,
new Class[] { Echo.class } );
+        final Echo echo = ( Echo )new JavassistProxyFactory().createDelegatorProxy( provider,
new Class[] { Echo.class } );
         try
         {
             echo.echoBack( "Hello." );



---------------------------------------------------------------------
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