Removing old src/test
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/proxy/branches/version-2.0-work@965001 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/commons/proxy/Interceptor.java b/src/main/java/org/apache/commons/proxy/Interceptor.java
deleted file mode 100644
index ecb4fe0..0000000
--- a/src/main/java/org/apache/commons/proxy/Interceptor.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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;
-
-import java.io.Serializable;
-
-/**
- * "Intercepts" a method invocation.
- *
- * @author James Carman
- * @since 1.0
- */
-public interface Interceptor extends Serializable
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public Object intercept( Invocation invocation ) throws Throwable;
-}
diff --git a/src/main/java/org/apache/commons/proxy/Invocation.java b/src/main/java/org/apache/commons/proxy/Invocation.java
deleted file mode 100644
index 571790e..0000000
--- a/src/main/java/org/apache/commons/proxy/Invocation.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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;
-
-import java.lang.reflect.Method;
-
-/**
- * Represents a method invocation.
- *
- * @author James Carman
- * @since 1.0
- */
-public interface Invocation
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- /**
- * Returns the arguments being passed to this method invocation. Changes in the elements of this array will be
- * propagated to the recipient of this invocation.
- *
- * @return the arguments being passed to this method invocation
- */
- public Object[] getArguments();
-
- /**
- * Returns the method being called.
- *
- * @return the method being called
- */
- public Method getMethod();
-
- /**
- * Returns the proxy object on which this invocation was invoked.
- *
- * @return the proxy object on which this invocation was invoked
- */
- public Object getProxy();
-
- /**
- * Called in order to let the invocation proceed.
- *
- * @return the return value of the invocation
- * @throws Throwable any exception or error that was thrown as a result of this invocation
- */
- public Object proceed() throws Throwable;
-}
diff --git a/src/main/java/org/apache/commons/proxy/Invoker.java b/src/main/java/org/apache/commons/proxy/Invoker.java
deleted file mode 100644
index ba90110..0000000
--- a/src/main/java/org/apache/commons/proxy/Invoker.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-
-/**
- * An invoker is responsible for handling a method invocation.
- *
- * @author James Carman
- * @since 1.0
- */
-public interface Invoker extends Serializable
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- /**
- * "Invokes" the method. Implementation should throw a {@link org.apache.commons.proxy.exception.InvokerException}
- * if problems arise while trying to invoke the method.
- *
- * @param proxy the proxy object
- * @param method the method being invoked
- * @param arguments the arguments
- * @return the return value
- * @throws Throwable thrown by the implementation
- */
- public Object invoke( Object proxy, Method method, Object[] arguments ) throws Throwable;
-}
diff --git a/src/main/java/org/apache/commons/proxy/ObjectProvider.java b/src/main/java/org/apache/commons/proxy/ObjectProvider.java
deleted file mode 100644
index 420945e..0000000
--- a/src/main/java/org/apache/commons/proxy/ObjectProvider.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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;
-
-/**
- * Provides an object to a delegating proxy.
- *
- * @author James Carman
- * @since 1.0
- */
-public interface ObjectProvider<T>
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- /**
- * Returns an object. Implementing classes should throw a
- * {@link org.apache.commons.proxy.exception.ObjectProviderException} if any problems arise while
- * constructing/finding the object.
- *
- * @return the object on which the method should be called
- */
- public T getObject();
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/ProxyFactory.java b/src/main/java/org/apache/commons/proxy/ProxyFactory.java
deleted file mode 100644
index aa7014c..0000000
--- a/src/main/java/org/apache/commons/proxy/ProxyFactory.java
+++ /dev/null
@@ -1,395 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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;
-
-import java.io.Serializable;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-
-/**
- * A <code>ProxyFactory</code> can be used to create three different "flavors" of proxy objects.
- * <p/>
- * <ul>
- * <li>Delegator - the proxy will delegate to an object provided by an {@link ObjectProvider}</li>
- * <li>Interceptor - the proxy will pass each method invocation through an {@link Interceptor}</li>
- * <li>Invoker - the proxy will allow an {@link Invoker} to handle all method invocations</li>
- * </ul>
- * <p/>
- * <p>
- * Originally, the ProxyFactory class was an interface. However, to allow for future changes to the
- * class without breaking binary or semantic compatibility, it has been changed to a concrete class.
- * <p/>
- * </p>
- * <p>
- * <b>Note</b>: This class uses Java reflection. For more efficient proxies, try using either
- * {@link org.apache.commons.proxy.factory.cglib.CglibProxyFactory CglibProxyFactory} or
- * {@link org.apache.commons.proxy.factory.javassist.JavassistProxyFactory JavassistProxyFactory} instead.
- * </p>
- *
- * @author James Carman
- * @since 1.0
- */
-public class ProxyFactory
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- /**
- * Returns true if all <code>proxyClasses</code> are interfaces.
- *
- * @param proxyClasses the proxy classes
- * @return true if all <code>proxyClasses</code> are interfaces
- */
- public boolean canProxy( Class... proxyClasses )
- {
- for( Class proxyClass : proxyClasses )
- {
- if( !proxyClass.isInterface() )
- {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Creates a proxy which delegates to the object provided by <code>delegateProvider</code>. The proxy will be
- * generated using the current thread's "context class loader."
- *
- * @param delegateProvider the delegate provider
- * @param proxyClasses the interfaces that the proxy should implement
- * @return a proxy which delegates to the object provided by the target object provider
- */
- public Object createDelegatorProxy( ObjectProvider delegateProvider, Class... proxyClasses )
- {
- return createDelegatorProxy(Thread.currentThread().getContextClassLoader(), delegateProvider, proxyClasses);
- }
-
- /**
- * Creates a proxy which delegates to the object provided by <code>delegateProvider</code>. The proxy will be
- * generated using the current thread's "context class loader."
- *
- * @param delegateProvider the delegate provider
- * @param proxyClass the class/interface that the proxy should implement
- * @return a proxy 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 proxy which delegates to the object provided by <code>delegateProvider</code>.
- *
- * @param classLoader the class loader to use when generating the proxy
- * @param delegateProvider the delegate provider
- * @param proxyClasses the interfaces that the proxy should implement
- * @return a proxy which delegates to the object provided by the target <code>delegateProvider>
- */
- public Object createDelegatorProxy( ClassLoader classLoader, ObjectProvider delegateProvider,
- Class... proxyClasses )
- {
- return Proxy.newProxyInstance(classLoader, proxyClasses,
- new DelegatorInvocationHandler(delegateProvider));
- }
-
- /**
- * Creates a proxy which delegates to the object provided by <code>delegateProvider</code>.
- *
- * @param classLoader the class loader to use when generating the proxy
- * @param delegateProvider the delegate provider
- * @param proxyClass the class/interface that the proxy should implement
- * @return a proxy 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 proxy which passes through a {@link Interceptor interceptor} before eventually reaching the
- * <code>target</code> object. The proxy will be generated using the current thread's "context class loader."
- *
- * @param target the target object
- * @param interceptor the method interceptor
- * @param proxyClasses the interfaces that the proxy should implement
- * @return a proxy which passes through a {@link Interceptor interceptor} before eventually reaching the
- * <code>target</code> object.
- */
- public Object createInterceptorProxy( Object target, Interceptor interceptor,
- Class... proxyClasses )
- {
- return createInterceptorProxy(Thread.currentThread().getContextClassLoader(), target, interceptor,
- proxyClasses);
- }
-
- /**
- * Creates a proxy which passes through a {@link Interceptor interceptor} before eventually reaching the
- * <code>target</code> object. The proxy 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 proxy should implement
- * @return a proxy 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 proxy 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 proxy
- * @param target the target object
- * @param interceptor the method interceptor
- * @param proxyClasses the interfaces that the proxy should implement.
- * @return a proxy which passes through a {@link Interceptor interceptor} before eventually reaching the
- * <code>target</code> object.
- */
- public Object createInterceptorProxy( ClassLoader classLoader, Object target, Interceptor interceptor,
- Class... proxyClasses )
- {
- return Proxy
- .newProxyInstance(classLoader, proxyClasses, new InterceptorInvocationHandler(target, interceptor));
- }
-
- /**
- * Creates a proxy 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 proxy
- * @param target the target object
- * @param interceptor the method interceptor
- * @param proxyClass the class/interface that the proxy should implement.
- * @return a proxy 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 proxy which uses the provided {@link Invoker} to handle all method invocations. The proxy will be
- * generated using the current thread's "context class loader."
- *
- * @param invoker the invoker
- * @param proxyClasses the interfaces that the proxy should implement
- * @return a proxy which uses the provided {@link Invoker} to handle all method invocations
- */
- public Object createInvokerProxy( Invoker invoker, Class... proxyClasses )
- {
- return createInvokerProxy(Thread.currentThread().getContextClassLoader(), invoker,
- proxyClasses);
- }
-
- /**
- * Creates a proxy which uses the provided {@link Invoker} to handle all method invocations. The proxy will be
- * generated using the current thread's "context class loader."
- *
- * @param invoker the invoker
- * @param proxyClass the class/interface that the proxy should implement
- * @return a proxy 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 proxy which uses the provided {@link Invoker} to handle all method invocations.
- *
- * @param classLoader the class loader to use when generating the proxy
- * @param invoker the invoker
- * @param proxyClasses the interfaces that the proxy should implement
- * @return a proxy which uses the provided {@link Invoker} to handle all method invocations
- */
- public Object createInvokerProxy( ClassLoader classLoader, Invoker invoker,
- Class... proxyClasses )
- {
- return Proxy.newProxyInstance(classLoader, proxyClasses, new InvokerInvocationHandler(invoker));
- }
-
- /**
- * Creates a proxy which uses the provided {@link Invoker} to handle all method invocations.
- *
- * @param classLoader the class loader to use when generating the proxy
- * @param invoker the invoker
- * @param proxyClass the class/interface that the proxy should implement
- * @return a proxy 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});
- }
-
-//**********************************************************************************************************************
-// Inner Classes
-//**********************************************************************************************************************
-
- private static class DelegatorInvocationHandler extends AbstractInvocationHandler
- {
- private final ObjectProvider delegateProvider;
-
- protected DelegatorInvocationHandler( ObjectProvider delegateProvider )
- {
- this.delegateProvider = delegateProvider;
- }
-
- public Object invokeImpl( Object proxy, Method method, Object[] args ) throws Throwable
- {
- try
- {
- return method.invoke(delegateProvider.getObject(), args);
- }
- catch( InvocationTargetException e )
- {
- throw e.getTargetException();
- }
- }
- }
-
- private static class InterceptorInvocationHandler extends AbstractInvocationHandler
- {
- private final Object target;
- private final Interceptor methodInterceptor;
-
- public InterceptorInvocationHandler( Object target, Interceptor methodInterceptor )
- {
- this.target = target;
- this.methodInterceptor = methodInterceptor;
- }
-
- public Object invokeImpl( Object proxy, Method method, Object[] args ) throws Throwable
- {
- final ReflectionInvocation invocation = new ReflectionInvocation(target, method, args);
- return methodInterceptor.intercept(invocation);
- }
- }
-
- private abstract static class AbstractInvocationHandler implements InvocationHandler, Serializable
- {
- public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable
- {
- if( isHashCode(method) )
- {
- return System.identityHashCode(proxy);
- }
- else if( isEqualsMethod(method) )
- {
- return proxy == args[0];
- }
- else
- {
- return invokeImpl(proxy, method, args);
- }
- }
-
- protected abstract Object invokeImpl( Object proxy, Method method, Object[] args ) throws Throwable;
- }
-
- private static class InvokerInvocationHandler extends AbstractInvocationHandler
- {
- private final Invoker invoker;
-
- public InvokerInvocationHandler( Invoker invoker )
- {
- this.invoker = invoker;
- }
-
- public Object invokeImpl( Object proxy, Method method, Object[] args ) throws Throwable
- {
- return invoker.invoke(proxy, method, args);
- }
- }
-
- protected static boolean isHashCode( Method method )
- {
- return "hashCode".equals(method.getName()) &&
- Integer.TYPE.equals(method.getReturnType()) &&
- method.getParameterTypes().length == 0;
- }
-
- protected static boolean isEqualsMethod( Method method )
- {
- return "equals".equals(method.getName()) &&
- Boolean.TYPE.equals(method.getReturnType()) &&
- method.getParameterTypes().length == 1 &&
- Object.class.equals(method.getParameterTypes()[0]);
- }
-
- private static class ReflectionInvocation implements Invocation, Serializable
- {
- private final Method method;
- private final Object[] arguments;
- private final Object target;
-
- public ReflectionInvocation( Object target, Method method, Object[] arguments )
- {
- this.method = method;
- this.arguments = ( arguments == null ? ProxyUtils.EMPTY_ARGUMENTS : arguments );
- this.target = target;
- }
-
- public Object[] getArguments()
- {
- return arguments;
- }
-
- public Method getMethod()
- {
- return method;
- }
-
- public Object getProxy()
- {
- return target;
- }
-
- public Object proceed() throws Throwable
- {
- try
- {
- return method.invoke(target, arguments);
- }
- catch( InvocationTargetException e )
- {
- throw e.getTargetException();
- }
- }
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/ProxyUtils.java b/src/main/java/org/apache/commons/proxy/ProxyUtils.java
deleted file mode 100644
index 0b7a104..0000000
--- a/src/main/java/org/apache/commons/proxy/ProxyUtils.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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;
-
-import org.apache.commons.proxy.invoker.NullInvoker;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Provides some helpful proxy utility methods.
- *
- * @author James Carman
- * @since 1.0
- */
-public class ProxyUtils
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- public static final Object[] EMPTY_ARGUMENTS = new Object[0];
- public static final Class[] EMPTY_ARGUMENT_TYPES = new Class[0];
- private static final Map<Class,Class> wrapperClassMap = new HashMap<Class,Class>();
- private static Map<Class,Object> nullValueMap = new HashMap<Class,Object>();
-
-//**********************************************************************************************************************
-// Static Methods
-//**********************************************************************************************************************
-
- static
- {
- wrapperClassMap.put(Integer.TYPE, Integer.class);
- wrapperClassMap.put(Character.TYPE, Character.class);
- wrapperClassMap.put(Boolean.TYPE, Boolean.class);
- wrapperClassMap.put(Short.TYPE, Short.class);
- wrapperClassMap.put(Long.TYPE, Long.class);
- wrapperClassMap.put(Float.TYPE, Float.class);
- wrapperClassMap.put(Double.TYPE, Double.class);
- wrapperClassMap.put(Byte.TYPE, Byte.class);
- }
-
- static
- {
- nullValueMap.put(Integer.TYPE, 0);
- nullValueMap.put(Long.TYPE, ( long ) 0);
- nullValueMap.put(Short.TYPE, ( short ) 0);
- nullValueMap.put(Byte.TYPE, ( byte ) 0);
- nullValueMap.put(Float.TYPE, 0.0f);
- nullValueMap.put(Double.TYPE, 0.0);
- nullValueMap.put(Character.TYPE, ( char ) 0);
- nullValueMap.put(Boolean.TYPE, Boolean.FALSE);
- }
-
- /**
- * Creates a "null object" which implements the <code>proxyClasses</code>.
- *
- * @param proxyFactory the proxy factory to be used to create the proxy object
- * @param proxyClasses the proxy interfaces
- * @return a "null object" which implements the <code>proxyClasses</code>.
- */
- public static Object createNullObject( ProxyFactory proxyFactory, Class[] proxyClasses )
- {
- return proxyFactory.createInvokerProxy(new NullInvoker(), proxyClasses);
- }
-
- /**
- * Creates a "null object" which implements the <code>proxyClasses</code>.
- *
- * @param proxyFactory the proxy factory to be used to create the proxy object
- * @param classLoader the class loader to be used by the proxy factory to create the proxy object
- * @param proxyClasses the proxy interfaces
- * @return a "null object" which implements the <code>proxyClasses</code>.
- */
- public static Object createNullObject( ProxyFactory proxyFactory, ClassLoader classLoader, Class[] proxyClasses )
- {
- return proxyFactory.createInvokerProxy(classLoader, new NullInvoker(), proxyClasses);
- }
-
- /**
- * <p>Gets an array of {@link Class} objects representing all interfaces implemented by the given class and its
- * superclasses.</p>
- * <p/>
- * <p>The order is determined by looking through each interface in turn as declared in the source file and following
- * its hierarchy up. Then each superclass is considered in the same way. Later duplicates are ignored, so the order
- * is maintained.</p>
- * <p/>
- * <b>Note</b>: Implementation of this method was "borrowed" from
- * <a href="http://commons.apache.org/lang/">Apache Commons Lang</a> to avoid a dependency.</p>
- *
- * @param cls the class to look up, may be <code>null</code>
- * @return an array of {@link Class} objects representing all interfaces implemented by the given class and its
- * superclasses or <code>null</code> if input class is null.
- */
- public static Class[] getAllInterfaces( Class cls )
- {
- final List interfaces = getAllInterfacesImpl(cls, new LinkedList());
- return interfaces == null ? null : ( Class[] ) interfaces.toArray(new Class[interfaces.size()]);
- }
-
- private static List getAllInterfacesImpl( Class cls, List list )
- {
- if( cls == null )
- {
- return null;
- }
- while( cls != null )
- {
- Class[] interfaces = cls.getInterfaces();
- for( int i = 0; i < interfaces.length; i++ )
- {
- if( !list.contains(interfaces[i]) )
- {
- list.add(interfaces[i]);
- }
- getAllInterfacesImpl(interfaces[i], list);
- }
- cls = cls.getSuperclass();
- }
- return list;
- }
-
- /**
- * Returns the class name as you would expect to see it in Java code.
- * <p/>
- * <b>Examples:</b> <ul> <li>getJavaClassName( Object[].class ) == "Object[]"</li> <li>getJavaClassName(
- * Object[][].class ) == "Object[][]"</li> <li>getJavaClassName( Integer.TYPE ) == "int"</li> </p>
- *
- * @param clazz the class
- * @return the class' name as you would expect to see it in Java code
- */
- public static String getJavaClassName( Class clazz )
- {
- if( clazz.isArray() )
- {
- return getJavaClassName(clazz.getComponentType()) + "[]";
- }
- return clazz.getName();
- }
-
- /**
- * Returns the wrapper class for the given primitive type.
- *
- * @param primitiveType the primitive type
- * @return the wrapper class
- */
- public static Class getWrapperClass( Class primitiveType )
- {
- return wrapperClassMap.get(primitiveType);
- }
-
- /**
- * Returns the proper "null value" as specified by the Java language.
- * @param type the type
- * @return the null value
- */
- public static <T> T nullValue(Class<T> type)
- {
- return (T)nullValueMap.get(type);
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/exception/InvokerException.java b/src/main/java/org/apache/commons/proxy/exception/InvokerException.java
deleted file mode 100644
index 6e98bb4..0000000
--- a/src/main/java/org/apache/commons/proxy/exception/InvokerException.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.exception;
-
-/**
- * To be used by an {@link org.apache.commons.proxy.Invoker} when they encounter an error.
- *
- * @author James Carman
- * @since 1.0
- */
-public class InvokerException extends RuntimeException
-{
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public InvokerException()
- {
- }
-
- public InvokerException( String message )
- {
- super(message);
- }
-
- public InvokerException( Throwable cause )
- {
- super(cause);
- }
-
- public InvokerException( String message, Throwable cause )
- {
- super(message, cause);
- }
-}
diff --git a/src/main/java/org/apache/commons/proxy/exception/ObjectProviderException.java b/src/main/java/org/apache/commons/proxy/exception/ObjectProviderException.java
deleted file mode 100644
index b2c35d2..0000000
--- a/src/main/java/org/apache/commons/proxy/exception/ObjectProviderException.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.exception;
-
-/**
- * {@link org.apache.commons.proxy.ObjectProvider} implementations should throw this exception type to indicate that
- * there was a problem creating/finding the object.
- *
- * @author James Carman
- * @since 1.0
- */
-public class ObjectProviderException extends RuntimeException
-{
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public ObjectProviderException()
- {
- }
-
- public ObjectProviderException( String message )
- {
- super(message);
- }
-
- public ObjectProviderException( Throwable cause )
- {
- super(cause);
- }
-
- public ObjectProviderException( String message, Throwable cause )
- {
- super(message, cause);
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/exception/ProxyFactoryException.java b/src/main/java/org/apache/commons/proxy/exception/ProxyFactoryException.java
deleted file mode 100644
index 073d2f4..0000000
--- a/src/main/java/org/apache/commons/proxy/exception/ProxyFactoryException.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.exception;
-
-/**
- * A runtime exception type to be used by {@link org.apache.commons.proxy.ProxyFactory proxy factories} when a problem
- * occurs.
- *
- * @author James Carman
- * @since 1.0
- */
-public class ProxyFactoryException extends RuntimeException
-{
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public ProxyFactoryException()
- {
- }
-
- public ProxyFactoryException( String message )
- {
- super(message);
- }
-
- public ProxyFactoryException( Throwable cause )
- {
- super(cause);
- }
-
- public ProxyFactoryException( String message, Throwable cause )
- {
- super(message, cause);
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/exception/package.html b/src/main/java/org/apache/commons/proxy/exception/package.html
deleted file mode 100644
index 879bb66..0000000
--- a/src/main/java/org/apache/commons/proxy/exception/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You 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.
- -->
-
-<html>
-<body>
-<p>
- This package contains the exception classes used by the primary API.
-</p>
-</body>
-</html>
diff --git a/src/main/java/org/apache/commons/proxy/factory/cglib/CglibProxyFactory.java b/src/main/java/org/apache/commons/proxy/factory/cglib/CglibProxyFactory.java
deleted file mode 100644
index 0756908..0000000
--- a/src/main/java/org/apache/commons/proxy/factory/cglib/CglibProxyFactory.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.factory.cglib;
-
-import net.sf.cglib.proxy.Callback;
-import net.sf.cglib.proxy.CallbackFilter;
-import net.sf.cglib.proxy.Dispatcher;
-import net.sf.cglib.proxy.Enhancer;
-import net.sf.cglib.proxy.MethodProxy;
-import net.sf.cglib.proxy.MethodInterceptor;
-import org.apache.commons.proxy.Interceptor;
-import org.apache.commons.proxy.Invocation;
-import org.apache.commons.proxy.Invoker;
-import org.apache.commons.proxy.ObjectProvider;
-import org.apache.commons.proxy.factory.util.AbstractSubclassingProxyFactory;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-
-/**
- * A <a href="http://cglib.sourceforge.net/">CGLIB</a>-based {@link org.apache.commons.proxy.ProxyFactory}
- * implementation.
- * <p/>
- * <p/>
- * <b>Dependencies</b>: <ul> <li>CGLIB version 2.0.2 or greater</li> </ul> </p>
- *
- * @author James Carman
- * @since 1.0
- */
-public class CglibProxyFactory extends AbstractSubclassingProxyFactory
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private static CallbackFilter callbackFilter = new CglibProxyFactoryCallbackFilter();
-
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public Object createDelegatorProxy(ClassLoader classLoader, ObjectProvider targetProvider,
- Class... proxyClasses)
- {
- final Enhancer enhancer = new Enhancer();
- enhancer.setClassLoader(classLoader);
- enhancer.setInterfaces(toInterfaces(proxyClasses));
- enhancer.setSuperclass(getSuperclass(proxyClasses));
- enhancer.setCallbackFilter(callbackFilter);
- enhancer.setCallbacks(new Callback[]{new ObjectProviderDispatcher(targetProvider), new EqualsHandler(), new HashCodeHandler()});
- return enhancer.create();
- }
-
- public Object createInterceptorProxy(ClassLoader classLoader, Object target, Interceptor interceptor,
- Class... proxyClasses)
- {
- final Enhancer enhancer = new Enhancer();
- enhancer.setClassLoader(classLoader);
- enhancer.setInterfaces(toInterfaces(proxyClasses));
- enhancer.setSuperclass(getSuperclass(proxyClasses));
- enhancer.setCallbackFilter(callbackFilter);
- enhancer.setCallbacks(new Callback[]{new InterceptorBridge(target, interceptor), new EqualsHandler(), new HashCodeHandler()});
- return enhancer.create();
- }
-
- public Object createInvokerProxy(ClassLoader classLoader, Invoker invoker,
- Class... proxyClasses)
- {
- final Enhancer enhancer = new Enhancer();
- enhancer.setClassLoader(classLoader);
- enhancer.setInterfaces(toInterfaces(proxyClasses));
- enhancer.setSuperclass(getSuperclass(proxyClasses));
- enhancer.setCallbackFilter(callbackFilter);
- enhancer.setCallbacks(new Callback[]{new InvokerBridge(invoker), new EqualsHandler(), new HashCodeHandler()});
- return enhancer.create();
- }
-
-//**********************************************************************************************************************
-// Inner Classes
-//**********************************************************************************************************************
-
- private static class InterceptorBridge implements net.sf.cglib.proxy.MethodInterceptor, Serializable
- {
- private final Interceptor inner;
- private final Object target;
-
- public InterceptorBridge(Object target, Interceptor inner)
- {
- this.inner = inner;
- this.target = target;
- }
-
- public Object intercept(Object object, Method method, Object[] args, MethodProxy methodProxy) throws Throwable
- {
- return inner.intercept(new MethodProxyInvocation(target, method, args, methodProxy));
- }
- }
-
- private static class HashCodeHandler implements MethodInterceptor, Serializable
- {
- public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable
- {
- return System.identityHashCode(o);
- }
- }
-
- private static class EqualsHandler implements MethodInterceptor, Serializable
- {
- public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable
- {
- return o == objects[0];
- }
- }
-
-
- private static class InvokerBridge implements net.sf.cglib.proxy.InvocationHandler, Serializable
- {
- private final Invoker original;
-
- public InvokerBridge(Invoker original)
- {
- this.original = original;
- }
-
- public Object invoke(Object object, Method method, Object[] objects) throws Throwable
- {
- return original.invoke(object, method, objects);
- }
- }
-
- private static class MethodProxyInvocation implements Invocation, Serializable
- {
- private final MethodProxy methodProxy;
- private final Method method;
- private final Object[] args;
- private final Object target;
-
- public MethodProxyInvocation(Object target, Method method, Object[] args, MethodProxy methodProxy)
- {
- this.target = target;
- this.method = method;
- this.methodProxy = methodProxy;
- this.args = args;
- }
-
- public Method getMethod()
- {
- return method;
- }
-
- public Object[] getArguments()
- {
- return args;
- }
-
- public Object proceed() throws Throwable
- {
- return methodProxy.invoke(target, args);
- }
-
- public Object getProxy()
- {
- return target;
- }
- }
-
- private static class ObjectProviderDispatcher implements Dispatcher, Serializable
- {
- private final ObjectProvider delegateProvider;
-
- public ObjectProviderDispatcher(ObjectProvider delegateProvider)
- {
- this.delegateProvider = delegateProvider;
- }
-
- public Object loadObject()
- {
- return delegateProvider.getObject();
- }
- }
-
- private static class CglibProxyFactoryCallbackFilter implements CallbackFilter
- {
- public int accept(Method method)
- {
- if (isEqualsMethod(method))
- {
- return 1;
- }
- else if (isHashCode(method))
- {
- return 2;
- }
- else
- {
- return 0;
- }
- }
-
-
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/factory/cglib/package.html b/src/main/java/org/apache/commons/proxy/factory/cglib/package.html
deleted file mode 100644
index 95ec785..0000000
--- a/src/main/java/org/apache/commons/proxy/factory/cglib/package.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You 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.
- -->
-
-<html>
-<body>
-<p>
- This package contains the <a href="http://cglib.sourceforge.net/">CGLIB</a>-based
- <a href="../../ProxyFactory.html">ProxyFactory</a> implementation.
-</p>
-</body>
-</html>
diff --git a/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistInvocation.java b/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistInvocation.java
deleted file mode 100644
index 5a2e8ae..0000000
--- a/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistInvocation.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.factory.javassist;
-
-import javassist.CannotCompileException;
-import javassist.CtClass;
-import javassist.CtConstructor;
-import javassist.CtMethod;
-import org.apache.commons.proxy.Invocation;
-import org.apache.commons.proxy.ProxyUtils;
-
-import java.lang.ref.WeakReference;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-/**
- * A <a href="http://www.jboss.org/products/javassist">Javassist</a>-based {@link Invocation} implementation. This
- * class actually serves as the superclass for all <a href="http://www.jboss.org/products/javassist">Javassist</a>-based
- * method invocations. Subclasses are dynamically created to deal with specific interface methods (they're hard-wired).
- *
- * @author James Carman
- * @since 1.0
- */
-public abstract class JavassistInvocation implements Invocation
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private static WeakHashMap loaderToClassCache = new WeakHashMap();
- protected final Method method;
- protected final Object target;
- protected final Object[] arguments;
-
-//**********************************************************************************************************************
-// Static Methods
-//**********************************************************************************************************************
-
- private static String createCastExpression( Class type, String objectToCast )
- {
- if( !type.isPrimitive() )
- {
- return "( " + ProxyUtils.getJavaClassName(type) + " )" + objectToCast;
- }
- else
- {
- return "( ( " + ProxyUtils.getWrapperClass(type).getName() + " )" + objectToCast + " )." +
- type.getName() + "Value()";
- }
- }
-
- private static Class createInvocationClass( ClassLoader classLoader, Method interfaceMethod )
- throws CannotCompileException
- {
- Class invocationClass;
- final CtClass ctClass = JavassistUtils.createClass(
- getSimpleName(interfaceMethod.getDeclaringClass()) + "_" + interfaceMethod.getName() +
- "_invocation",
- JavassistInvocation.class);
- final CtConstructor constructor = new CtConstructor(
- JavassistUtils.resolve(new Class[] {Method.class, Object.class, Object[].class}),
- ctClass);
- constructor.setBody("{\n\tsuper($$);\n}");
- ctClass.addConstructor(constructor);
- final CtMethod proceedMethod = new CtMethod(JavassistUtils.resolve(Object.class), "proceed",
- JavassistUtils.resolve(new Class[0]), ctClass);
- final Class[] argumentTypes = interfaceMethod.getParameterTypes();
- final StringBuffer proceedBody = new StringBuffer("{\n");
- if( !Void.TYPE.equals(interfaceMethod.getReturnType()) )
- {
- proceedBody.append("\treturn ");
- if( interfaceMethod.getReturnType().isPrimitive() )
- {
- proceedBody.append("new ");
- proceedBody.append(ProxyUtils.getWrapperClass(interfaceMethod.getReturnType()).getName());
- proceedBody.append("( ");
- }
- }
- else
- {
- proceedBody.append("\t");
- }
- proceedBody.append("( (");
- proceedBody.append(ProxyUtils.getJavaClassName(interfaceMethod.getDeclaringClass()));
- proceedBody.append(" )target ).");
- proceedBody.append(interfaceMethod.getName());
- proceedBody.append("(");
- for( int i = 0; i < argumentTypes.length; ++i )
- {
- final Class argumentType = argumentTypes[i];
- proceedBody.append(createCastExpression(argumentType, "arguments[" + i + "]"));
- if( i != argumentTypes.length - 1 )
- {
- proceedBody.append(", ");
- }
- }
- if( !Void.TYPE.equals(interfaceMethod.getReturnType()) && interfaceMethod.getReturnType().isPrimitive() )
- {
- proceedBody.append(") );\n");
- }
- else
- {
- proceedBody.append(");\n");
- }
- if( Void.TYPE.equals(interfaceMethod.getReturnType()) )
- {
- proceedBody.append("\treturn null;\n");
- }
- proceedBody.append("}");
- final String body = proceedBody.toString();
- proceedMethod.setBody(body);
- ctClass.addMethod(proceedMethod);
- invocationClass = ctClass.toClass(classLoader);
- return invocationClass;
- }
-
- private static Map getClassCache( ClassLoader classLoader )
- {
- Map cache = ( Map ) loaderToClassCache.get(classLoader);
- if( cache == null )
- {
- cache = new HashMap();
- loaderToClassCache.put(classLoader, cache);
- }
- return cache;
- }
-
- /**
- * Returns a method invocation class specifically coded to invoke the supplied interface method.
- *
- * @param classLoader the classloader to use
- * @param interfaceMethod the interface method
- * @return a method invocation class specifically coded to invoke the supplied interface method
- * @throws CannotCompileException if a compilation error occurs
- */
- synchronized static Class getMethodInvocationClass( ClassLoader classLoader,
- Method interfaceMethod )
- throws CannotCompileException
- {
- final Map classCache = getClassCache(classLoader);
- final String key = toClassCacheKey(interfaceMethod);
- final WeakReference invocationClassRef = ( WeakReference ) classCache.get(key);
- Class invocationClass;
- if( invocationClassRef == null )
- {
- invocationClass = createInvocationClass(classLoader, interfaceMethod);
- classCache.put(key, new WeakReference(invocationClass));
- }
- else
- {
- synchronized( invocationClassRef )
- {
- invocationClass = ( Class ) invocationClassRef.get();
- if( invocationClass == null )
- {
- invocationClass = createInvocationClass(classLoader, interfaceMethod);
- classCache.put(key, new WeakReference(invocationClass));
- }
- }
- }
- return invocationClass;
- }
-
- private static String getSimpleName( Class c )
- {
- final String name = c.getName();
- final int ndx = name.lastIndexOf('.');
- return ndx == -1 ? name : name.substring(ndx + 1);
- }
-
- private static String toClassCacheKey( Method method )
- {
- return String.valueOf(method);
- }
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public JavassistInvocation( Method method, Object target, Object[] arguments )
- {
- this.method = method;
- this.target = target;
- this.arguments = arguments;
- }
-
-//**********************************************************************************************************************
-// Invocation Implementation
-//**********************************************************************************************************************
-
- public Object[] getArguments()
- {
- return arguments;
- }
-
- public Method getMethod()
- {
- return method;
- }
-
- public Object getProxy()
- {
- return target;
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistProxyFactory.java b/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistProxyFactory.java
deleted file mode 100644
index 6f86dc3..0000000
--- a/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistProxyFactory.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.factory.javassist;
-
-import javassist.CannotCompileException;
-import javassist.CtClass;
-import javassist.CtConstructor;
-import javassist.CtMethod;
-import org.apache.commons.proxy.Interceptor;
-import org.apache.commons.proxy.Invoker;
-import org.apache.commons.proxy.ObjectProvider;
-import org.apache.commons.proxy.exception.ProxyFactoryException;
-import org.apache.commons.proxy.factory.util.AbstractProxyClassGenerator;
-import org.apache.commons.proxy.factory.util.AbstractSubclassingProxyFactory;
-import org.apache.commons.proxy.factory.util.ProxyClassCache;
-
-import java.lang.reflect.Method;
-
-/**
- * A <a href="http://www.jboss.org/products/javassist">Javassist</a>-based {@link org.apache.commons.proxy.ProxyFactory}
- * implementation.
- * <p/>
- * <b>Dependencies</b>: <ul> <li>Javassist version 3.0 or greater</li> </ul> </p>
- *
- * @author James Carman
- * @since 1.0
- */
-public class JavassistProxyFactory extends AbstractSubclassingProxyFactory
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private static final String GET_METHOD_METHOD_NAME = "_javassistGetMethod";
-
- private static final ProxyClassCache delegatingProxyClassCache = new ProxyClassCache(
- new DelegatingProxyClassGenerator());
- private static final ProxyClassCache interceptorProxyClassCache = new ProxyClassCache(
- new InterceptorProxyClassGenerator());
- private static final ProxyClassCache invocationHandlerProxyClassCache = new ProxyClassCache(
- new InvokerProxyClassGenerator());
-
-//**********************************************************************************************************************
-// Static Methods
-//**********************************************************************************************************************
-
- private static void addGetMethodMethod(CtClass proxyClass) throws CannotCompileException
- {
- final CtMethod method = new CtMethod(JavassistUtils.resolve(Method.class), GET_METHOD_METHOD_NAME,
- JavassistUtils.resolve(new Class[]{String.class, String.class, Class[].class}), proxyClass);
- final String body = "try { return Class.forName($1).getMethod($2, $3); } catch( Exception e ) " +
- "{ throw new RuntimeException(\"Unable to look up method.\", e); }";
- method.setBody(body);
- proxyClass.addMethod(method);
- }
-
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public Object createDelegatorProxy(ClassLoader classLoader, ObjectProvider targetProvider,
- Class... proxyClasses)
- {
- try
- {
- final Class clazz = delegatingProxyClassCache.getProxyClass(classLoader, proxyClasses);
- return clazz.getConstructor(ObjectProvider.class)
- .newInstance(targetProvider);
- }
- catch (Exception e)
- {
- throw new ProxyFactoryException("Unable to instantiate proxy from generated proxy class.", e);
- }
- }
-
- public Object createInterceptorProxy(ClassLoader classLoader, Object target, Interceptor interceptor,
- Class... proxyClasses)
- {
- try
- {
- final Class clazz = interceptorProxyClassCache.getProxyClass(classLoader, proxyClasses);
- return clazz.getConstructor(Object.class, Interceptor.class)
- .newInstance(target, interceptor);
- }
- catch (Exception e)
- {
- throw new ProxyFactoryException("Unable to instantiate proxy class instance.", e);
- }
- }
-
- public Object createInvokerProxy(ClassLoader classLoader, Invoker invoker,
- Class... proxyClasses)
- {
- try
- {
- final Class clazz = invocationHandlerProxyClassCache.getProxyClass(classLoader, proxyClasses);
- return clazz.getConstructor(Invoker.class)
- .newInstance(invoker);
- }
- catch (Exception e)
- {
- throw new ProxyFactoryException("Unable to instantiate proxy from generated proxy class.", e);
- }
- }
-
-//**********************************************************************************************************************
-// Inner Classes
-//**********************************************************************************************************************
-
- private static class DelegatingProxyClassGenerator extends AbstractProxyClassGenerator
- {
- public Class generateProxyClass(ClassLoader classLoader, Class[] proxyClasses)
- {
- try
- {
- final CtClass proxyClass = JavassistUtils.createClass(getSuperclass(proxyClasses));
- JavassistUtils.addField(ObjectProvider.class, "provider", proxyClass);
- final CtConstructor proxyConstructor = new CtConstructor(
- JavassistUtils.resolve(new Class[]{ObjectProvider.class}),
- proxyClass);
- proxyConstructor.setBody("{ this.provider = $1; }");
- proxyClass.addConstructor(proxyConstructor);
- JavassistUtils.addInterfaces(proxyClass, toInterfaces(proxyClasses));
- addHashCodeMethod(proxyClass);
- addEqualsMethod(proxyClass);
- final Method[] methods = getImplementationMethods(proxyClasses);
- for (int i = 0; i < methods.length; ++i)
- {
- if (!isEqualsMethod(methods[i]) && !isHashCode(methods[i]))
- {
- final Method method = methods[i];
- final CtMethod ctMethod = new CtMethod(JavassistUtils.resolve(method.getReturnType()),
- method.getName(),
- JavassistUtils.resolve(method.getParameterTypes()),
- proxyClass);
- final String body = "{ return ( $r ) ( ( " + method.getDeclaringClass().getName() +
- " )provider.getObject() )." +
- method.getName() + "($$); }";
- ctMethod.setBody(body);
- proxyClass.addMethod(ctMethod);
- }
- }
- return proxyClass.toClass(classLoader);
- }
- catch (CannotCompileException e)
- {
- throw new ProxyFactoryException("Could not compile class.", e);
- }
- }
- }
-
- private static class InterceptorProxyClassGenerator extends AbstractProxyClassGenerator
- {
- public Class generateProxyClass(ClassLoader classLoader, Class[] proxyClasses)
- {
- try
- {
- final CtClass proxyClass = JavassistUtils.createClass(getSuperclass(proxyClasses));
- final Method[] methods = getImplementationMethods(proxyClasses);
- JavassistUtils.addInterfaces(proxyClass, toInterfaces(proxyClasses));
- JavassistUtils.addField(Object.class, "target", proxyClass);
- JavassistUtils.addField(Interceptor.class, "interceptor", proxyClass);
- addGetMethodMethod(proxyClass);
- addHashCodeMethod(proxyClass);
- addEqualsMethod(proxyClass);
- final CtConstructor proxyConstructor = new CtConstructor(
- JavassistUtils.resolve(
- new Class[]{Object.class, Interceptor.class}),
- proxyClass);
- proxyConstructor
- .setBody(
- "{\n\tthis.target = $1;\n\tthis.interceptor = $2; }");
- proxyClass.addConstructor(proxyConstructor);
- for (int i = 0; i < methods.length; ++i)
- {
- if (!isEqualsMethod(methods[i]) && !isHashCode(methods[i]))
- {
- final CtMethod method = new CtMethod(JavassistUtils.resolve(methods[i].getReturnType()),
- methods[i].getName(),
- JavassistUtils.resolve(methods[i].getParameterTypes()),
- proxyClass);
- final Class invocationClass = JavassistInvocation
- .getMethodInvocationClass(classLoader, methods[i]);
-
- final String body = "{\n\t return ( $r ) interceptor.intercept( new " + invocationClass.getName() +
- "( " + GET_METHOD_METHOD_NAME + "(\"" + methods[i].getDeclaringClass().getName() +
- "\", \"" + methods[i].getName() + "\", $sig), target, $args ) );\n }";
- method.setBody(body);
- proxyClass.addMethod(method);
- }
-
- }
- return proxyClass.toClass(classLoader);
- }
- catch (CannotCompileException e)
- {
- throw new ProxyFactoryException("Could not compile class.", e);
- }
- }
-
-
- }
-
- private static void addEqualsMethod(CtClass proxyClass)
- throws CannotCompileException
- {
- final CtMethod equalsMethod = new CtMethod(JavassistUtils.resolve(Boolean.TYPE), "equals",
- JavassistUtils.resolve(new Class[]{Object.class}), proxyClass);
- final String body = "{\n\treturn this == $1;\n}";
- equalsMethod.setBody(body);
- proxyClass.addMethod(equalsMethod);
- }
-
- private static void addHashCodeMethod(CtClass proxyClass)
- throws CannotCompileException
- {
- final CtMethod hashCodeMethod = new CtMethod(JavassistUtils.resolve(Integer.TYPE), "hashCode",
- new CtClass[0], proxyClass);
- hashCodeMethod.setBody("{\n\treturn System.identityHashCode(this);\n}");
- proxyClass.addMethod(hashCodeMethod);
- }
-
- private static class InvokerProxyClassGenerator extends AbstractProxyClassGenerator
- {
- public Class generateProxyClass(ClassLoader classLoader, Class[] proxyClasses)
- {
- try
- {
- final CtClass proxyClass = JavassistUtils.createClass(getSuperclass(proxyClasses));
- final Method[] methods = getImplementationMethods(proxyClasses);
- JavassistUtils.addInterfaces(proxyClass, toInterfaces(proxyClasses));
- JavassistUtils.addField(Invoker.class, "invoker", proxyClass);
- final CtConstructor proxyConstructor = new CtConstructor(
- JavassistUtils.resolve(
- new Class[]{Invoker.class}),
- proxyClass);
- proxyConstructor
- .setBody("{\n\tthis.invoker = $1; }");
- proxyClass.addConstructor(proxyConstructor);
- addGetMethodMethod(proxyClass);
- addHashCodeMethod(proxyClass);
- addEqualsMethod(proxyClass);
- for (int i = 0; i < methods.length; ++i)
- {
- if (!isEqualsMethod(methods[i]) && !isHashCode(methods[i]))
- {
- final CtMethod method = new CtMethod(JavassistUtils.resolve(methods[i].getReturnType()),
- methods[i].getName(),
- JavassistUtils.resolve(methods[i].getParameterTypes()),
- proxyClass);
- final String body = "{\n\t return ( $r ) invoker.invoke( this, " + GET_METHOD_METHOD_NAME + "(\"" +
- methods[i].getDeclaringClass().getName() +
- "\", \"" + methods[i].getName() + "\", $sig), $args );\n }";
- method.setBody(body);
- proxyClass.addMethod(method);
- }
- }
- return proxyClass.toClass(classLoader);
- }
- catch (CannotCompileException e)
- {
- throw new ProxyFactoryException("Could not compile class.", e);
- }
- }
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistUtils.java b/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistUtils.java
deleted file mode 100644
index 1b248b4..0000000
--- a/src/main/java/org/apache/commons/proxy/factory/javassist/JavassistUtils.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.factory.javassist;
-
-import javassist.CannotCompileException;
-import javassist.ClassPool;
-import javassist.CtClass;
-import javassist.CtField;
-import javassist.LoaderClassPath;
-import javassist.NotFoundException;
-import org.apache.commons.proxy.ProxyUtils;
-import org.apache.commons.proxy.exception.ObjectProviderException;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Some utility methods for dealing with Javassist. This class is not part of the public API!
- *
- * @author James Carman
- * @since 1.0
- */
-class JavassistUtils
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- public static final String DEFAULT_BASE_NAME = "JavassistUtilsGenerated";
- private static int classNumber = 0;
- private static final ClassPool classPool = new ClassPool();
-
- private static final Set classLoaders = new HashSet();
-
-//**********************************************************************************************************************
-// Static Methods
-//**********************************************************************************************************************
-
- static
- {
- classPool.appendClassPath(new LoaderClassPath(ClassLoader.getSystemClassLoader()));
- }
-
- /**
- * Adds a field to a class.
- *
- * @param fieldType the field's type
- * @param fieldName the field name
- * @param enclosingClass the class receiving the new field
- * @throws CannotCompileException if a compilation problem occurs
- */
- public static void addField( Class fieldType, String fieldName, CtClass enclosingClass )
- throws CannotCompileException
- {
- enclosingClass.addField(new CtField(resolve(fieldType), fieldName, enclosingClass));
- }
-
- /**
- * Adds interfaces to a {@link CtClass}
- *
- * @param ctClass the {@link CtClass}
- * @param proxyClasses the interfaces
- */
- public static void addInterfaces( CtClass ctClass, Class[] proxyClasses )
- {
- for( int i = 0; i < proxyClasses.length; i++ )
- {
- Class proxyInterface = proxyClasses[i];
- ctClass.addInterface(resolve(proxyInterface));
- }
- }
-
- /**
- * Creates a new {@link CtClass} derived from the Java {@link Class} using the default base name.
- *
- * @param superclass the superclass
- * @return the new derived {@link CtClass}
- */
- public static CtClass createClass( Class superclass )
- {
- return createClass(DEFAULT_BASE_NAME, superclass);
- }
-
- /**
- * Creates a new {@link CtClass} derived from the Java {@link Class} using the supplied base name.
- *
- * @param baseName the base name
- * @param superclass the superclass
- * @return the new derived {@link CtClass}
- */
- public synchronized static CtClass createClass( String baseName, Class superclass )
- {
- return classPool.makeClass(baseName + "_" + classNumber++, resolve(superclass));
- }
-
- /**
- * Finds the {@link CtClass} corresponding to the Java {@link Class} passed in.
- *
- * @param clazz the Java {@link Class}
- * @return the {@link CtClass}
- */
- public static CtClass resolve( Class clazz )
- {
- synchronized( classLoaders )
- {
- try
- {
- final ClassLoader loader = clazz.getClassLoader();
- if( loader != null && !classLoaders.contains(loader) )
- {
- classLoaders.add(loader);
- classPool.appendClassPath(new LoaderClassPath(loader));
- }
- return classPool.get(ProxyUtils.getJavaClassName(clazz));
- }
- catch( NotFoundException e )
- {
- throw new ObjectProviderException(
- "Unable to find class " + clazz.getName() + " in default Javassist class pool.", e);
- }
- }
- }
-
- /**
- * Resolves an array of Java {@link Class}es to an array of their corresponding {@link CtClass}es.
- *
- * @param classes the Java {@link Class}es
- * @return the corresponding {@link CtClass}es
- */
- public static CtClass[] resolve( Class[] classes )
- {
- final CtClass[] ctClasses = new CtClass[classes.length];
- for( int i = 0; i < ctClasses.length; ++i )
- {
- ctClasses[i] = resolve(classes[i]);
- }
- return ctClasses;
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/factory/javassist/package.html b/src/main/java/org/apache/commons/proxy/factory/javassist/package.html
deleted file mode 100644
index c8e64ee..0000000
--- a/src/main/java/org/apache/commons/proxy/factory/javassist/package.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You 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.
- -->
-
-<html>
-<body>
-<p>
- This package contains the <a href="http://www.jboss.org/products/javassist">Javassist</a>-based
- <a href="../../ProxyFactory.html">ProxyFactory</a> implementation.
-</p>
-</body>
-</html>
diff --git a/src/main/java/org/apache/commons/proxy/factory/util/AbstractProxyClassGenerator.java b/src/main/java/org/apache/commons/proxy/factory/util/AbstractProxyClassGenerator.java
deleted file mode 100644
index 99ed300..0000000
--- a/src/main/java/org/apache/commons/proxy/factory/util/AbstractProxyClassGenerator.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.factory.util;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A useful superclass for {@link ProxyClassGenerator} implementations.
- *
- * @author James Carman
- * @since 1.0
- */
-public abstract class AbstractProxyClassGenerator implements ProxyClassGenerator
-{
-//**********************************************************************************************************************
-// Static Methods
-//**********************************************************************************************************************
-
- /**
- * 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. Final methods are also excluded from the result.
- *
- * @param proxyClasses the interfaces the proxy class must implement
- * @return all methods that the proxy class must implement
- */
- public static Method[] getImplementationMethods( Class[] proxyClasses )
- {
- final Map signatureMethodMap = new HashMap();
- final Set finalizedSignatures = new HashSet();
- for( int i = 0; i < proxyClasses.length; i++ )
- {
- Class proxyInterface = proxyClasses[i];
- final Method[] methods = proxyInterface.getMethods();
- for( int j = 0; j < methods.length; j++ )
- {
- final MethodSignature signature = new MethodSignature(methods[j]);
- if( Modifier.isFinal(methods[j].getModifiers()) )
- {
- finalizedSignatures.add(signature);
- }
- else if( !signatureMethodMap.containsKey(signature) )
- {
- signatureMethodMap.put(signature, methods[j]);
- }
- }
- }
- final Collection resultingMethods = signatureMethodMap.values();
- for( Iterator i = finalizedSignatures.iterator(); i.hasNext(); )
- {
- MethodSignature signature = ( MethodSignature ) i.next();
- resultingMethods.remove(signatureMethodMap.get(signature));
- }
- return ( Method[] ) resultingMethods.toArray(new Method[resultingMethods.size()]);
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/factory/util/AbstractSubclassingProxyFactory.java b/src/main/java/org/apache/commons/proxy/factory/util/AbstractSubclassingProxyFactory.java
deleted file mode 100644
index aa6d952..0000000
--- a/src/main/java/org/apache/commons/proxy/factory/util/AbstractSubclassingProxyFactory.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.factory.util;
-
-import org.apache.commons.proxy.ProxyFactory;
-import org.apache.commons.proxy.exception.ProxyFactoryException;
-
-import java.io.Serializable;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Modifier;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * A useful superclass for a {@link ProxyFactory} which supports subclassing rather than merely implementing interfaces.
- *
- * @author James Carman
- * @since 1.0
- */
-public abstract class AbstractSubclassingProxyFactory extends ProxyFactory
-{
-//**********************************************************************************************************************
-// Static Methods
-//**********************************************************************************************************************
-
- /**
- * Returns either {@link Object} if all of the <code>proxyClasses</code> are interfaces or the single non-interface
- * class from <code>proxyClasses</code>.
- *
- * @param proxyClasses the proxy classes
- * @return either {@link Object} if all of the <code>proxyClasses</code> are interfaces or the single non-interface
- * class from <code>proxyClasses</code>
- * @throws ProxyFactoryException if multiple non-interface classes are contained in <code>proxyClasses</code> or any
- * of the non-interface classes are final
- */
- public static Class getSuperclass( Class[] proxyClasses )
- {
- final Class[] superclasses = toNonInterfaces(proxyClasses);
- switch( superclasses.length )
- {
- case 0:
- return Object.class;
- case 1:
- final Class superclass = superclasses[0];
- if( Modifier.isFinal(superclass.getModifiers()) )
- {
- throw new ProxyFactoryException(
- "Proxy class cannot extend " + superclass.getName() + " as it is final.");
- }
- if( !hasSuitableDefaultConstructor(superclass) )
- {
- throw new ProxyFactoryException("Proxy class cannot extend " + superclass.getName() +
- ", because it has no visible \"default\" constructor.");
- }
- return superclass;
- default:
- final StringBuffer errorMessage = new StringBuffer("Proxy class cannot extend ");
- for( int i = 0; i < superclasses.length; i++ )
- {
- Class c = superclasses[i];
- errorMessage.append(c.getName());
- if( i != superclasses.length - 1 )
- {
- errorMessage.append(", ");
- }
- }
- errorMessage.append("; multiple inheritance not allowed.");
- throw new ProxyFactoryException(errorMessage.toString());
- }
- }
-
- private static boolean hasSuitableDefaultConstructor( Class superclass )
- {
- final Constructor[] declaredConstructors = superclass.getDeclaredConstructors();
- for( int i = 0; i < declaredConstructors.length; i++ )
- {
- Constructor constructor = declaredConstructors[i];
- if( constructor.getParameterTypes().length == 0 && ( Modifier.isPublic(constructor.getModifiers()) ||
- Modifier.isProtected(constructor.getModifiers()) ) )
- {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Returns the <code>proxyClasses</code> transformed into an array of only the interface classes.
- * <p/>
- * <b>Note</b>: This class will append {@link Serializable} to the end of the list if it's
- * not found!
- *
- * @param proxyClasses the proxy classes
- * @return the <code>proxyClasses</code> transformed into an array of only the interface classes
- */
- protected static Class[] toInterfaces( Class[] proxyClasses )
- {
- final Collection interfaces = new LinkedList();
- boolean serializableFound = false;
- for( int i = 0; i < proxyClasses.length; i++ )
- {
- Class proxyInterface = proxyClasses[i];
- if( proxyInterface.isInterface() )
- {
- interfaces.add(proxyInterface);
- }
- serializableFound |= ( Serializable.class.equals(proxyInterface) );
- }
- if( !serializableFound )
- {
- interfaces.add(Serializable.class);
- }
- return ( Class[] ) interfaces.toArray(new Class[interfaces.size()]);
- }
-
- private static Class[] toNonInterfaces( Class[] proxyClasses )
- {
- final List superclasses = new LinkedList();
- for( int i = 0; i < proxyClasses.length; i++ )
- {
- Class proxyClass = proxyClasses[i];
- if( !proxyClass.isInterface() )
- {
- superclasses.add(proxyClass);
- }
- }
- return ( Class[] ) superclasses.toArray(new Class[superclasses.size()]);
- }
-
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- /**
- * Returns true if a suitable superclass can be found, given the desired <code>proxyClasses</code>.
- *
- * @param proxyClasses the proxy classes
- * @return true if a suitable superclass can be found, given the desired <code>proxyClasses</code>
- */
- public boolean canProxy( Class... proxyClasses )
- {
- try
- {
- getSuperclass(proxyClasses);
- return true;
- }
- catch( ProxyFactoryException e )
- {
- return false;
- }
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/factory/util/MethodSignature.java b/src/main/java/org/apache/commons/proxy/factory/util/MethodSignature.java
deleted file mode 100644
index fabd415..0000000
--- a/src/main/java/org/apache/commons/proxy/factory/util/MethodSignature.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.factory.util;
-
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * A class for capturing the signature of a method (its name and parameter types).
- *
- * @author James Carman
- * @since 1.0
- */
-public class MethodSignature
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private final String name;
- private final List parameterTypes;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public MethodSignature( Method method )
- {
- this.name = method.getName();
- this.parameterTypes = Arrays.asList(method.getParameterTypes());
- }
-
-//**********************************************************************************************************************
-// Canonical Methods
-//**********************************************************************************************************************
-
- public boolean equals( Object o )
- {
- if( this == o )
- {
- return true;
- }
- if( o == null || getClass() != o.getClass() )
- {
- return false;
- }
- final MethodSignature that = ( MethodSignature ) o;
- if( !name.equals(that.name) )
- {
- return false;
- }
- if( !parameterTypes.equals(that.parameterTypes) )
- {
- return false;
- }
- return true;
- }
-
- public int hashCode()
- {
- int result;
- result = name.hashCode();
- result = 29 * result + parameterTypes.hashCode();
- return result;
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/factory/util/ProxyClassCache.java b/src/main/java/org/apache/commons/proxy/factory/util/ProxyClassCache.java
deleted file mode 100644
index ead88fc..0000000
--- a/src/main/java/org/apache/commons/proxy/factory/util/ProxyClassCache.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.factory.util;
-
-import java.lang.ref.WeakReference;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-/**
- * A cache for storing implementation classes for proxies based on a specific type of {@link ProxyClassGenerator}. A
- * proxy class cache ensures that there is only one class for every
- * {@link ProxyClassGenerator}/{@link ClassLoader}/proxy class array combination.
- *
- * @author James Carman
- * @since 1.0
- */
-public class ProxyClassCache
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private final Map loaderToClassCache = new WeakHashMap();
- private final ProxyClassGenerator proxyClassGenerator;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public ProxyClassCache( ProxyClassGenerator proxyClassGenerator )
- {
- this.proxyClassGenerator = proxyClassGenerator;
- }
-
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- private Map getClassCache( ClassLoader classLoader )
- {
- Map cache = ( Map ) loaderToClassCache.get(classLoader);
- if( cache == null )
- {
- cache = new HashMap();
- loaderToClassCache.put(classLoader, cache);
- }
- return cache;
- }
-
- private String toClassCacheKey( Class[] proxyClasses )
- {
- final StringBuffer sb = new StringBuffer();
- for( int i = 0; i < proxyClasses.length; i++ )
- {
- Class proxyInterface = proxyClasses[i];
- sb.append(proxyInterface.getName());
- if( i != proxyClasses.length - 1 )
- {
- sb.append(",");
- }
- }
- return sb.toString();
- }
-
- /**
- * Returns the proxy class generated by the {@link ProxyClassGenerator} using the specified {@link ClassLoader} and
- * array of proxy classes.
- *
- * @param classLoader the classloader
- * @param proxyClasses the proxy classes
- * @return the proxy class generated by the {@link ProxyClassGenerator} using the specified {@link ClassLoader} and
- * array of proxy classes
- */
- public synchronized Class getProxyClass( ClassLoader classLoader, Class[] proxyClasses )
- {
- final Map classCache = getClassCache(classLoader);
- final String key = toClassCacheKey(proxyClasses);
- Class proxyClass;
- WeakReference proxyClassReference = ( WeakReference ) classCache.get(key);
- if( proxyClassReference == null )
- {
- proxyClass = proxyClassGenerator.generateProxyClass(classLoader, proxyClasses);
- classCache.put(key, new WeakReference(proxyClass));
- }
- else
- {
- synchronized( proxyClassReference )
- {
- proxyClass = ( Class ) proxyClassReference.get();
- if( proxyClass == null )
- {
- proxyClass = proxyClassGenerator.generateProxyClass(classLoader, proxyClasses);
- classCache.put(key, new WeakReference(proxyClass));
- }
- }
- }
- return proxyClass;
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/factory/util/ProxyClassGenerator.java b/src/main/java/org/apache/commons/proxy/factory/util/ProxyClassGenerator.java
deleted file mode 100644
index effd113..0000000
--- a/src/main/java/org/apache/commons/proxy/factory/util/ProxyClassGenerator.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.factory.util;
-
-/**
- * A proxy class generator generates specific type of proxies (interceptor, invoker, etc.).
- *
- * @author James Carman
- * @since 1.0
- */
-public interface ProxyClassGenerator
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- /**
- * Generates a proxy class for the supplied {@link ClassLoader} and proxy classes.
- *
- * @param classLoader the classloader
- * @param proxyClasses the proxy classes
- * @return the dynamically generated proxy class
- */
- public Class generateProxyClass( ClassLoader classLoader, Class[] proxyClasses );
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/factory/util/package.html b/src/main/java/org/apache/commons/proxy/factory/util/package.html
deleted file mode 100644
index 0fea8e8..0000000
--- a/src/main/java/org/apache/commons/proxy/factory/util/package.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You 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.
- -->
-
-<html>
-<body>
-<p>
- This package contains some classes useful for writing your own <a href="../../ProxyFactory.html">ProxyFactory</a>
- implementation.
-</p>
-</body>
-</html>
diff --git a/src/main/java/org/apache/commons/proxy/interceptor/ExecutorInterceptor.java b/src/main/java/org/apache/commons/proxy/interceptor/ExecutorInterceptor.java
deleted file mode 100644
index 0608ea3..0000000
--- a/src/main/java/org/apache/commons/proxy/interceptor/ExecutorInterceptor.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.interceptor;
-
-import EDU.oswego.cs.dl.util.concurrent.Executor;
-import org.apache.commons.proxy.Interceptor;
-import org.apache.commons.proxy.Invocation;
-
-/**
- * A method interceptor that uses an {@link Executor} to execute the method invocation.
- * <p/>
- * <b>Note</b>: Only <em>void</em> methods can be intercepted using this class! Any attempts to intercept non-void
- * methods will result in an {@link IllegalArgumentException}. If the proxy interfaces include non-void methods, try
- * using a {@link FilteredInterceptor} along with a
- * {@link org.apache.commons.proxy.interceptor.filter.ReturnTypeFilter} to wrap an instance of this class.
- * <p/>
- * <p>
- * <b>Dependencies</b>:
- * <ul>
- * <li>Concurrent API version 1.3.4 or greater</li>
- * </ul>
- * </p>
- *
- * @author James Carman
- * @since 1.0
- */
-public class ExecutorInterceptor implements Interceptor
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private final Executor executor;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public ExecutorInterceptor( Executor executor )
- {
- this.executor = executor;
- }
-
-//**********************************************************************************************************************
-// Interceptor Implementation
-//**********************************************************************************************************************
-
-
- public Object intercept( final Invocation invocation ) throws Throwable
- {
- if( Void.TYPE.equals(invocation.getMethod().getReturnType()) )
- {
- // Special case for finalize() method (should not be run in a different thread)...
- if( !( invocation.getMethod().getName().equals("finalize") &&
- invocation.getMethod().getParameterTypes().length == 0 ) )
- {
- executor.execute(new Runnable()
- {
- public void run()
- {
- try
- {
- invocation.proceed();
- }
- catch( Throwable t )
- {
- // What to do here? I can't convey the failure back to the caller.
- }
- }
- });
- return null;
- }
- else
- {
- return invocation.proceed();
- }
- }
- else
- {
- throw new IllegalArgumentException("Only void methods can be executed in a different thread.");
- }
- }
-}
diff --git a/src/main/java/org/apache/commons/proxy/interceptor/FilteredInterceptor.java b/src/main/java/org/apache/commons/proxy/interceptor/FilteredInterceptor.java
deleted file mode 100644
index 2479c69..0000000
--- a/src/main/java/org/apache/commons/proxy/interceptor/FilteredInterceptor.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.interceptor;
-
-import org.apache.commons.proxy.Interceptor;
-import org.apache.commons.proxy.Invocation;
-
-/**
- * Decorates another <code>MethodInterceptor</code> by only calling it if the method is accepted by the supplied
- * <code>MethodFilter</code>.
- *
- * @author James Carman
- * @since 1.0
- */
-public class FilteredInterceptor implements Interceptor
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private final Interceptor inner;
- private final MethodFilter filter;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public FilteredInterceptor( Interceptor inner, MethodFilter filter )
- {
- this.inner = inner;
- this.filter = filter;
- }
-
-//**********************************************************************************************************************
-// Interceptor Implementation
-//**********************************************************************************************************************
-
- public Object intercept( Invocation invocation ) throws Throwable
- {
- if( filter.accepts(invocation.getMethod()) )
- {
- return inner.intercept(invocation);
- }
- else
- {
- return invocation.proceed();
- }
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/interceptor/InterceptorChain.java b/src/main/java/org/apache/commons/proxy/interceptor/InterceptorChain.java
deleted file mode 100644
index b9437df..0000000
--- a/src/main/java/org/apache/commons/proxy/interceptor/InterceptorChain.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.interceptor;
-
-import org.apache.commons.proxy.Interceptor;
-import org.apache.commons.proxy.ObjectProvider;
-import org.apache.commons.proxy.ProxyFactory;
-import org.apache.commons.proxy.ProxyUtils;
-
-/**
- * An <code>InterceptorChain</code> assists with creating proxies which go through a series of
- * {@link Interceptor interceptors}.
- * <p/>
- * <pre>
- * MyServiceInterface serviceImpl = ...;
- * ProxyFactory factory = ...;
- * Interceptor[] interceptors = ...;
- * InterceptorChain chain = new InterceptorChain(interceptors);
- * ObjectProvider provider = chain.createProxyProvider(factory, serviceImpl);
- * MyServiceInterface serviceProxy = ( MyServiceInterface )provider.getObject();
- * serviceProxy.someServiceMethod(...); // This will go through the interceptors!
- * </pre>
- *
- * @author James Carman
- * @since 1.0
- */
-public class InterceptorChain
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private final Interceptor[] interceptors;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public InterceptorChain( Interceptor[] interceptors )
- {
- this.interceptors = interceptors;
- }
-
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- private Object createProxy( ProxyFactory proxyFactory, ClassLoader classLoader, Object terminus,
- Class[] proxyClasses )
- {
- Object currentTarget = terminus;
- for( int i = interceptors.length - 1; i >= 0; --i )
- {
- currentTarget = proxyFactory
- .createInterceptorProxy(classLoader, currentTarget, interceptors[i], proxyClasses);
- }
- return currentTarget;
- }
-
- /**
- * Creates an {@link ObjectProvider} which will return a proxy that sends method invocations through this
- * chain of interceptors and ultimately arrive at the supplied terminus object. The proxy will support all
- * interfaces implemented by the terminus object. The thread context classloader will be used to generate the
- * proxy class.
- *
- * @param proxyFactory the {@link ProxyFactory} to use to create the proxy
- * @param terminus the terminus
- * @return an {@link ObjectProvider} which will return a proxy that sends method invocations through this
- * chain of interceptors and ultimately arrive at the supplied terminus object
- */
- public ObjectProvider createProxyProvider( ProxyFactory proxyFactory, Object terminus )
- {
- return createProxyProvider(proxyFactory, terminus, null);
- }
-
- /**
- * Creates an {@link ObjectProvider} which will return a proxy that sends method invocations through this
- * chain of interceptors and ultimately arrive at the supplied terminus object. The proxy will support only
- * the specified interfaces/classes. The thread context classloader will be used to generate the
- * proxy class.
- *
- * @param proxyFactory the {@link ProxyFactory} to use to create the proxy
- * @param terminus the terminus
- * @param proxyClasses the interfaces to support
- * @return an {@link ObjectProvider} which will return a proxy that sends method invocations through this
- * chain of interceptors and ultimately arrive at the supplied terminus object
- */
- public ObjectProvider createProxyProvider( ProxyFactory proxyFactory, Object terminus, Class[] proxyClasses )
- {
- return createProxyProvider(proxyFactory, Thread.currentThread().getContextClassLoader(), terminus,
- proxyClasses);
- }
-
- /**
- * Creates an {@link ObjectProvider} which will return a proxy that sends method invocations through this
- * chain of interceptors and ultimately arrive at the supplied terminus object. The proxy will support only
- * the specified interfaces/classes. The specified classloader will be used to generate the
- * proxy class.
- *
- * @param proxyFactory the {@link ProxyFactory} to use to create the proxy
- * @param classLoader the classloader to be used to generate the proxy class
- * @param terminus the terminus
- * @param proxyClasses the interfaces to support
- * @return an {@link ObjectProvider} which will return a proxy that sends method invocations through this
- * chain of interceptors and ultimately arrive at the supplied terminus object
- */
- public ObjectProvider createProxyProvider( ProxyFactory proxyFactory, ClassLoader classLoader, Object terminus,
- Class[] proxyClasses )
- {
- if( proxyClasses == null || proxyClasses.length == 0 )
- {
- proxyClasses = ProxyUtils.getAllInterfaces(terminus.getClass());
- }
- return new ProxyObjectProvider(proxyFactory, classLoader, terminus, proxyClasses);
- }
-
-//**********************************************************************************************************************
-// Inner Classes
-//**********************************************************************************************************************
-
- private class ProxyObjectProvider implements ObjectProvider
- {
- private final ClassLoader classLoader;
- private final Class[] proxyClasses;
- private final Object terminus;
- private final ProxyFactory proxyFactory;
-
- public ProxyObjectProvider( ProxyFactory proxyFactory, ClassLoader classLoader, Object terminus,
- Class[] proxyClasses )
- {
- this.classLoader = classLoader;
- this.proxyClasses = proxyClasses;
- this.terminus = terminus;
- this.proxyFactory = proxyFactory;
- }
-
- public Object getObject()
- {
- return createProxy(proxyFactory, classLoader, terminus, proxyClasses);
- }
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/interceptor/MethodFilter.java b/src/main/java/org/apache/commons/proxy/interceptor/MethodFilter.java
deleted file mode 100644
index db0c80d..0000000
--- a/src/main/java/org/apache/commons/proxy/interceptor/MethodFilter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.interceptor;
-
-import java.lang.reflect.Method;
-import java.io.Serializable;
-
-/**
- * A <code>MethodFilter</code> determines whether or not a method is accepted.
- *
- * @author James Carman
- * @since 1.0
- */
-public interface MethodFilter extends Serializable
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- /**
- * Returns whether or not this filter accepts this method.
- *
- * @param method the method
- * @return whether or not this filter accepts this method
- */
- public boolean accepts( Method method );
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/interceptor/MethodInterceptorAdapter.java b/src/main/java/org/apache/commons/proxy/interceptor/MethodInterceptorAdapter.java
deleted file mode 100644
index 09ad3ba..0000000
--- a/src/main/java/org/apache/commons/proxy/interceptor/MethodInterceptorAdapter.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.interceptor;
-
-import org.aopalliance.intercept.MethodInterceptor;
-import org.aopalliance.intercept.MethodInvocation;
-import org.apache.commons.proxy.Interceptor;
-import org.apache.commons.proxy.Invocation;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Method;
-
-/**
- * An adapter class to adapt AOP Alliance's {@link MethodInterceptor} interface to Commons Proxy's
- * {@link Interceptor} interface.
- * <p/>
- * <p>
- * <b>Dependencies</b>:
- * <ul>
- * <li>AOP Alliance API version 1.0 or greater</li>
- * </ul>
- * </p>
- *
- * @author James Carman
- * @since 1.0
- */
-public class MethodInterceptorAdapter implements Interceptor
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private final MethodInterceptor methodInterceptor;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public MethodInterceptorAdapter( MethodInterceptor methodInterceptor )
- {
- this.methodInterceptor = methodInterceptor;
- }
-
-//**********************************************************************************************************************
-// Interceptor Implementation
-//**********************************************************************************************************************
-
-
- public Object intercept( Invocation invocation ) throws Throwable
- {
- return methodInterceptor.invoke(new MethodInvocationAdapter(invocation));
- }
-
-//**********************************************************************************************************************
-// Inner Classes
-//**********************************************************************************************************************
-
- private static class MethodInvocationAdapter implements MethodInvocation
- {
- private final Invocation invocation;
-
- public MethodInvocationAdapter( Invocation invocation )
- {
- this.invocation = invocation;
- }
-
- public Method getMethod()
- {
- return invocation.getMethod();
- }
-
- public Object[] getArguments()
- {
- return invocation.getArguments();
- }
-
- public Object proceed() throws Throwable
- {
- return invocation.proceed();
- }
-
- public Object getThis()
- {
- return invocation.getProxy();
- }
-
- public AccessibleObject getStaticPart()
- {
- return invocation.getMethod();
- }
- }
-}
diff --git a/src/main/java/org/apache/commons/proxy/interceptor/SerializingInterceptor.java b/src/main/java/org/apache/commons/proxy/interceptor/SerializingInterceptor.java
deleted file mode 100644
index 8dc3025..0000000
--- a/src/main/java/org/apache/commons/proxy/interceptor/SerializingInterceptor.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.interceptor;
-
-import org.apache.commons.proxy.Interceptor;
-import org.apache.commons.proxy.Invocation;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-
-/**
- * An interceptor which makes a serialized copy of all parameters and return values. This
- * is useful when testing remote services to ensure that all parameter/return types
- * are in fact serializable/deserializable.
- *
- * @since 1.0
- */
-public class SerializingInterceptor implements Interceptor, Serializable
-{
-//**********************************************************************************************************************
-// Interceptor Implementation
-//**********************************************************************************************************************
-
- public Object intercept( Invocation invocation ) throws Throwable
- {
- Object[] arguments = invocation.getArguments();
- for( int i = 0; i < arguments.length; i++ )
- {
- arguments[i] = serializedCopy(arguments[i]);
- }
- return serializedCopy(invocation.proceed());
- }
-
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- private Object serializedCopy( Object original )
- {
- try
- {
- final ByteArrayOutputStream bout = new ByteArrayOutputStream();
- final ObjectOutputStream oout = new ObjectOutputStream(bout);
- oout.writeObject(original);
- oout.close();
- bout.close();
- final ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- final ObjectInputStream oin = new ObjectInputStream(bin);
- final Object copy = oin.readObject();
- oin.close();
- bin.close();
- return copy;
- }
- catch( IOException e )
- {
- throw new RuntimeException("Unable to make serialized copy of " +
- original.getClass().getName() + " object.", e);
- }
- catch( ClassNotFoundException e )
- {
- throw new RuntimeException("Unable to make serialized copy of " +
- original.getClass().getName() + " object.", e);
- }
- }
-}
diff --git a/src/main/java/org/apache/commons/proxy/interceptor/filter/PatternFilter.java b/src/main/java/org/apache/commons/proxy/interceptor/filter/PatternFilter.java
deleted file mode 100644
index a926b0b..0000000
--- a/src/main/java/org/apache/commons/proxy/interceptor/filter/PatternFilter.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.interceptor.filter;
-
-import org.apache.commons.proxy.interceptor.MethodFilter;
-
-import java.lang.reflect.Method;
-
-/**
- * A method filter implementation that returns true if the method's name matches a supplied regular expression (JDK
- * regex) pattern string.
- *
- * @author James Carman
- * @since 1.0
- */
-public class PatternFilter implements MethodFilter
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- public static String GETTER_SETTER_PATTERN = "get\\w+|set\\w+";
- private final String pattern;
-
-//**********************************************************************************************************************
-// Static Methods
-//**********************************************************************************************************************
-
- /**
- * Returns a {@link MethodFilter} which accepts only "getters" and "setters."
- *
- * @return a {@link MethodFilter} which accepts only "getters" and "setters."
- */
- public static MethodFilter getterSetterFilter()
- {
- return new PatternFilter(GETTER_SETTER_PATTERN);
- }
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public PatternFilter( String pattern )
- {
- this.pattern = pattern;
- }
-
-//**********************************************************************************************************************
-// MethodFilter Implementation
-//**********************************************************************************************************************
-
- public boolean accepts( Method method )
- {
- return method.getName().matches(pattern);
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/interceptor/filter/ReturnTypeFilter.java b/src/main/java/org/apache/commons/proxy/interceptor/filter/ReturnTypeFilter.java
deleted file mode 100644
index bfae910..0000000
--- a/src/main/java/org/apache/commons/proxy/interceptor/filter/ReturnTypeFilter.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.interceptor.filter;
-
-import org.apache.commons.proxy.interceptor.MethodFilter;
-
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Filters methods based on their return type.
- *
- * @author James Carman
- * @since 1.0
- */
-public class ReturnTypeFilter implements MethodFilter
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private final Set validReturnTypes = new HashSet();
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public ReturnTypeFilter( Class[] validReturnTypes )
- {
- this(Arrays.asList(validReturnTypes));
- }
-
- public ReturnTypeFilter( Collection validReturnTypes )
- {
- this.validReturnTypes.addAll(validReturnTypes);
- }
-
-//**********************************************************************************************************************
-// MethodFilter Implementation
-//**********************************************************************************************************************
-
-
- public boolean accepts( Method method )
- {
- return validReturnTypes.contains(method.getReturnType());
- }
-}
diff --git a/src/main/java/org/apache/commons/proxy/interceptor/filter/SimpleFilter.java b/src/main/java/org/apache/commons/proxy/interceptor/filter/SimpleFilter.java
deleted file mode 100644
index 4f9f08a..0000000
--- a/src/main/java/org/apache/commons/proxy/interceptor/filter/SimpleFilter.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.interceptor.filter;
-
-import org.apache.commons.proxy.interceptor.MethodFilter;
-
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * A simple method filter implementation that merely returns true if the method's name is in a set of accepted names.
- *
- * @author James Carman
- * @since 1.0
- */
-public class SimpleFilter implements MethodFilter
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private final Set methodNames;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- /**
- * Creates a simple filter that accepts no methods.
- */
- public SimpleFilter()
- {
- this.methodNames = new HashSet();
- }
-
- /**
- * Creates a simple filter that accepts methods matching the supplied names.
- *
- * @param methodNames the names
- */
- public SimpleFilter( String[] methodNames )
- {
- this.methodNames = new HashSet(Arrays.asList(methodNames));
- }
-
-//**********************************************************************************************************************
-// MethodFilter Implementation
-//**********************************************************************************************************************
-
- public boolean accepts( Method method )
- {
- return methodNames.contains(method.getName());
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/interceptor/filter/package.html b/src/main/java/org/apache/commons/proxy/interceptor/filter/package.html
deleted file mode 100644
index 97e6fdc..0000000
--- a/src/main/java/org/apache/commons/proxy/interceptor/filter/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You 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.
- -->
-
-<html>
-<body>
-<p>
- This package contains some useful <a href="../MethodFilter.html">MethodFilter</a> implementations.
-</p>
-</body>
-</html>
diff --git a/src/main/java/org/apache/commons/proxy/interceptor/logging/AbstractLoggingInterceptor.java b/src/main/java/org/apache/commons/proxy/interceptor/logging/AbstractLoggingInterceptor.java
deleted file mode 100644
index 074b2ea..0000000
--- a/src/main/java/org/apache/commons/proxy/interceptor/logging/AbstractLoggingInterceptor.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.interceptor.logging;
-
-import org.apache.commons.proxy.Interceptor;
-import org.apache.commons.proxy.Invocation;
-import org.apache.commons.proxy.ProxyUtils;
-
-import java.lang.reflect.Method;
-
-/**
- * @auothor James Carman
- * @since 1.1
- */
-public abstract class AbstractLoggingInterceptor implements Interceptor
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private static final int BUFFER_SIZE = 100;
-
-//**********************************************************************************************************************
-// Abstract Methods
-//**********************************************************************************************************************
-
- protected abstract boolean isLoggingEnabled();
-
- protected abstract void logMessage( String message );
-
- protected abstract void logMessage( String message, Throwable t );
-
-//**********************************************************************************************************************
-// Interceptor Implementation
-//**********************************************************************************************************************
-
- public Object intercept( Invocation invocation ) throws Throwable
- {
- if( isLoggingEnabled() )
- {
- final Method method = invocation.getMethod();
- entering(method, invocation.getArguments());
- try
- {
- Object result = invocation.proceed();
- exiting(method, result);
- return result;
- }
- catch( Throwable t )
- {
- throwing(method, t);
- throw t;
- }
- }
- else
- {
- return invocation.proceed();
- }
- }
-
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- protected void entering( Method method, Object[] args )
- {
- StringBuffer buffer = new StringBuffer(BUFFER_SIZE);
- buffer.append("BEGIN ");
- buffer.append(method.getName());
- buffer.append("(");
- int count = args.length;
- for( int i = 0; i < count; i++ )
- {
- Object arg = args[i];
- if( i > 0 )
- {
- buffer.append(", ");
- }
- convert(buffer, arg);
- }
- buffer.append(")");
- logMessage(buffer.toString());
- }
-
- protected void convert( StringBuffer buffer, Object input )
- {
- if( input == null )
- {
- buffer.append("<null>");
- return;
- }
-
- // Primitive types, and non-object arrays
- // use toString(). Less than ideal for int[], etc., but
- // that's a lot of work for a rare case.
- if( !( input instanceof Object[] ) )
- {
- buffer.append(input.toString());
- return;
- }
- buffer.append("(");
- buffer.append(ProxyUtils.getJavaClassName(input.getClass()));
- buffer.append("){");
- Object[] array = ( Object[] ) input;
- int count = array.length;
- for( int i = 0; i < count; i++ )
- {
- if( i > 0 )
- {
- buffer.append(", ");
- }
-
- // We use convert() again, because it could be a multi-dimensional array
- // (god help us) where each element must be converted.
- convert(buffer, array[i]);
- }
- buffer.append("}");
- }
-
- protected void exiting( Method method, Object result )
- {
- StringBuffer buffer = new StringBuffer(BUFFER_SIZE);
- buffer.append("END ");
- buffer.append(method.getName());
- buffer.append("()");
- if( !Void.TYPE.equals(method.getReturnType()) )
- {
- buffer.append(" [");
- convert(buffer, result);
- buffer.append("]");
- }
- logMessage(buffer.toString());
- }
-
- protected void throwing( Method method, Throwable t )
- {
- StringBuffer buffer = new StringBuffer(BUFFER_SIZE);
- buffer.append("EXCEPTION ");
- buffer.append(method);
- buffer.append("() -- ");
- buffer.append(t.getClass().getName());
- logMessage(buffer.toString(), t);
- }
-}
diff --git a/src/main/java/org/apache/commons/proxy/interceptor/logging/CommonsLoggingInterceptor.java b/src/main/java/org/apache/commons/proxy/interceptor/logging/CommonsLoggingInterceptor.java
deleted file mode 100644
index 5538527..0000000
--- a/src/main/java/org/apache/commons/proxy/interceptor/logging/CommonsLoggingInterceptor.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.interceptor.logging;
-
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.Log;
-
-/**
- * An interceptor which logs method invocations using an <a href="http://commons.apache.org/logging">Apache Commons
- * Logging</a> {@link Log} object at the "trace" level.
- *
- * @auothor James Carman
- * @since 1.1
- */
-public class CommonsLoggingInterceptor extends AbstractLoggingInterceptor
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private final String logName;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public CommonsLoggingInterceptor( String logName )
- {
- this.logName = logName;
- }
-
- public CommonsLoggingInterceptor(Class clazz)
- {
- this(clazz.getName());
- }
-
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- private Log getLog()
- {
- return LogFactory.getLog(logName);
- }
-
- protected boolean isLoggingEnabled()
- {
- return getLog().isTraceEnabled();
- }
-
- protected void logMessage( String message )
- {
- getLog().trace(message);
- }
-
- protected void logMessage( String message, Throwable t )
- {
- getLog().trace(message, t);
- }
-}
diff --git a/src/main/java/org/apache/commons/proxy/interceptor/logging/JdkLoggingInterceptor.java b/src/main/java/org/apache/commons/proxy/interceptor/logging/JdkLoggingInterceptor.java
deleted file mode 100644
index cb94865..0000000
--- a/src/main/java/org/apache/commons/proxy/interceptor/logging/JdkLoggingInterceptor.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.interceptor.logging;
-
-import java.lang.reflect.Method;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * An interceptor which logs method invocations using a {@link Logger JDK logger} using the "finer" logging level.
- *
- * @auothor James Carman
- * @since 1.1
- */
-public class JdkLoggingInterceptor extends AbstractLoggingInterceptor
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private final String loggerName;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public JdkLoggingInterceptor( Class clazz )
- {
- this(clazz.getName());
- }
-
- public JdkLoggingInterceptor( String loggerName )
- {
- this.loggerName = loggerName;
- }
-
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- private Logger getLogger()
- {
- return Logger.getLogger(loggerName);
- }
-
- protected void entering( Method method, Object[] args )
- {
- getLogger().entering(method.getDeclaringClass().getName(), method.getName(), args);
- }
-
- protected void exiting( Method method, Object result )
- {
- getLogger().exiting(method.getDeclaringClass().getName(), method.getName(), result);
- }
-
- protected boolean isLoggingEnabled()
- {
- return getLogger().isLoggable(Level.FINER);
- }
-
- protected void logMessage( String message )
- {
- // Do nothing!
- }
-
- protected void logMessage( String message, Throwable t )
- {
- // Do nothing!
- }
-
- protected void throwing( Method method, Throwable t )
- {
- getLogger().throwing(method.getDeclaringClass().getName(), method.getName(), t);
- }
-}
diff --git a/src/main/java/org/apache/commons/proxy/interceptor/logging/Slf4jInterceptor.java b/src/main/java/org/apache/commons/proxy/interceptor/logging/Slf4jInterceptor.java
deleted file mode 100644
index 54d1ab1..0000000
--- a/src/main/java/org/apache/commons/proxy/interceptor/logging/Slf4jInterceptor.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.interceptor.logging;
-
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
-
-/**
- * An interceptor which logs method invocations using an <a href="http://www.slf4j.org/">SLF4J</a> {@link Logger} at the
- * "trace" logging level.
- *
- * @auothor James Carman
- * @since 1.1
- */
-public class Slf4jInterceptor extends AbstractLoggingInterceptor
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private final String loggerName;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public Slf4jInterceptor( Class clazz )
- {
- this(clazz.getName());
- }
-
- public Slf4jInterceptor( String loggerName )
- {
- this.loggerName = loggerName;
- }
-
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- private Logger getLogger()
- {
- return LoggerFactory.getLogger(loggerName);
- }
-
- protected boolean isLoggingEnabled()
- {
- return getLogger().isTraceEnabled();
- }
-
- protected void logMessage( String message )
- {
- getLogger().debug(message);
- }
-
- protected void logMessage( String message, Throwable t )
- {
- getLogger().debug(message, t);
- }
-}
diff --git a/src/main/java/org/apache/commons/proxy/interceptor/package.html b/src/main/java/org/apache/commons/proxy/interceptor/package.html
deleted file mode 100644
index 2d4df26..0000000
--- a/src/main/java/org/apache/commons/proxy/interceptor/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You 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.
- -->
-
-<html>
-<body>
-<p>
- This package contains some useful <a href="../Interceptor.html">Interceptor</a> implementations.
-</p>
-</body>
-</html>
diff --git a/src/main/java/org/apache/commons/proxy/invoker/DuckTypingInvoker.java b/src/main/java/org/apache/commons/proxy/invoker/DuckTypingInvoker.java
deleted file mode 100644
index 1992594..0000000
--- a/src/main/java/org/apache/commons/proxy/invoker/DuckTypingInvoker.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.commons.proxy.Invoker;
-import org.apache.commons.proxy.ObjectProvider;
-
-import java.lang.reflect.Method;
-
-/**
- * An invoker which supports <a href="http://en.wikipedia.org/wiki/Duck_typing">"duck typing"</a>, meaning
- * that it finds a matching method on the object returned from the target provider and invokes it. This class is
- * useful for adapting an existing class to an interface it does not implement.
- * <p>
- * <b>Example:</b>
- * </p>
- * <p>
- * <pre>
- * public class LegacyDuck // Does not implement interface!
- * {
- * public void quack()
- * {
- * // Quacking logic...
- * }
- * }
- * <p/>
- * public interface Duck
- * {
- * public void quack();
- * }
- * <p/>
- * ObjectProvider targetProvider = new ConstantProvider(new LegacyDuck()); // Always returns a "legacy" duck
- * DuckTypingInvoker invoker = new DuckTypingInvoker(targetProvider);
- * Duck duck = ( Duck )proxyFactory.createInvokerProxy( invoker, new Class[] { Duck.class } );
- * </pre>
- * </p>
- */
-public class DuckTypingInvoker implements Invoker
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private final ObjectProvider targetProvider;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public DuckTypingInvoker( final ObjectProvider targetProvider )
- {
- this.targetProvider = targetProvider;
- }
-
-//**********************************************************************************************************************
-// Invoker Implementation
-//**********************************************************************************************************************
-
- public Object invoke( final Object proxy, final Method method, final Object[] arguments ) throws Throwable
- {
- final Object target = targetProvider.getObject();
- final Class targetClass = target.getClass();
- try
- {
- final Method targetMethod = targetClass.getMethod(method.getName(), method.getParameterTypes());
- if( method.getReturnType().isAssignableFrom(targetMethod.getReturnType()) )
- {
- return targetMethod.invoke(target, arguments);
- }
- throw new UnsupportedOperationException(
- "Target type " + targetClass.getName() + " method has incompatible return type.");
- }
- catch( NoSuchMethodException e )
- {
- throw new UnsupportedOperationException(
- "Target type " + targetClass.getName() + " does not have a method matching " + method + ".");
- }
- }
-}
diff --git a/src/main/java/org/apache/commons/proxy/invoker/InvocationHandlerAdapter.java b/src/main/java/org/apache/commons/proxy/invoker/InvocationHandlerAdapter.java
deleted file mode 100644
index f59efb3..0000000
--- a/src/main/java/org/apache/commons/proxy/invoker/InvocationHandlerAdapter.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.commons.proxy.Invoker;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-
-/**
- * An adapter class to adapt the JDK's {@link InvocationHandler} interface to Commons Proxy's
- * {@link Invoker} interface.
- *
- * @author James Carman
- * @since 1.0
- */
-public class InvocationHandlerAdapter implements Invoker
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private final InvocationHandler invocationHandler;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public InvocationHandlerAdapter( InvocationHandler invocationHandler )
- {
- this.invocationHandler = invocationHandler;
- }
-
-//**********************************************************************************************************************
-// Invoker Implementation
-//**********************************************************************************************************************
-
-
- public Object invoke( Object proxy, Method method, Object[] arguments ) throws Throwable
- {
- return invocationHandler.invoke(proxy, method, arguments);
- }
-}
diff --git a/src/main/java/org/apache/commons/proxy/invoker/NullInvoker.java b/src/main/java/org/apache/commons/proxy/invoker/NullInvoker.java
deleted file mode 100644
index f2b8a94..0000000
--- a/src/main/java/org/apache/commons/proxy/invoker/NullInvoker.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.commons.proxy.Invoker;
-import org.apache.commons.proxy.ProxyUtils;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * An {@link 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
- * @since 1.0
- */
-public class NullInvoker implements Invoker, Serializable
-{
-//**********************************************************************************************************************
-// Invoker Implementation
-//**********************************************************************************************************************
-
- public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable
- {
- final Class returnType = method.getReturnType();
- return ProxyUtils.nullValue(returnType);
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/invoker/XmlRpcInvoker.java b/src/main/java/org/apache/commons/proxy/invoker/XmlRpcInvoker.java
deleted file mode 100644
index a9c8f2d..0000000
--- a/src/main/java/org/apache/commons/proxy/invoker/XmlRpcInvoker.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.commons.proxy.Invoker;
-import org.apache.commons.proxy.exception.InvokerException;
-import org.apache.xmlrpc.XmlRpcException;
-import org.apache.xmlrpc.XmlRpcHandler;
-
-import java.lang.reflect.Method;
-import java.util.Vector;
-
-/**
- * Uses <a href="http://ws.apache.org/xmlrpc/">Apache XML-RPC</a> to invoke methods on an XML-RPC service.
- * <p/>
- * <p>
- * <b>Dependencies</b>:
- * <ul>
- * <li>Apache XML-RPC version 2.0 or greater</li>
- * </ul>
- * </p>
- *
- * @author James Carman
- * @since 1.0
- */
-public class XmlRpcInvoker implements Invoker
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private final XmlRpcHandler handler;
- private final String handlerName;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public XmlRpcInvoker( XmlRpcHandler handler, String handlerName )
- {
- this.handler = handler;
- this.handlerName = handlerName;
- }
-
-//**********************************************************************************************************************
-// Invoker Implementation
-//**********************************************************************************************************************
-
-
- public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable
- {
- final Object returnValue = handler.execute(handlerName + "." + method.getName(), toArgumentVector(args));
- if( returnValue instanceof XmlRpcException )
- {
- throw new InvokerException("Unable to execute XML-RPC call.", ( XmlRpcException ) returnValue);
- }
- return returnValue;
- }
-
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- private Vector toArgumentVector( Object[] args )
- {
- final Vector v = new Vector();
- for( int i = 0; i < args.length; i++ )
- {
- Object arg = args[i];
- v.addElement(arg);
- }
- return v;
- }
-}
diff --git a/src/main/java/org/apache/commons/proxy/invoker/package.html b/src/main/java/org/apache/commons/proxy/invoker/package.html
deleted file mode 100644
index 63de2f5..0000000
--- a/src/main/java/org/apache/commons/proxy/invoker/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You 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.
- -->
-
-<html>
-<body>
-<p>
- This package contains some useful <a href="../Invoker.html">Invoker</a> implementations.
-</p>
-</body>
-</html>
diff --git a/src/main/java/org/apache/commons/proxy/invoker/recorder/InvocationRecorder.java b/src/main/java/org/apache/commons/proxy/invoker/recorder/InvocationRecorder.java
deleted file mode 100644
index 3a30702..0000000
--- a/src/main/java/org/apache/commons/proxy/invoker/recorder/InvocationRecorder.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.recorder;
-
-import org.apache.commons.proxy.Invoker;
-import org.apache.commons.proxy.ProxyFactory;
-import org.apache.commons.proxy.ProxyUtils;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * @auothor James Carman
- */
-public class InvocationRecorder
-{
- private final ProxyFactory proxyFactory;
- private List<RecordedInvocation> recordedInvocations = new LinkedList<RecordedInvocation>();
-
- public InvocationRecorder( ProxyFactory proxyFactory )
- {
- this.proxyFactory = proxyFactory;
- }
-
- public List<RecordedInvocation> getRecordedInvocations()
- {
- return recordedInvocations;
- }
-
- public <T> T proxy( Class<T> type )
- {
- return proxy(type, type);
- }
-
- public <T> T proxy( Type genericType, Class<T> type )
- {
- if( proxyFactory.canProxy(type) )
- {
- return proxyFactory.createInvokerProxy(new InvocationRecorderInvoker(genericType), type);
- }
- return ProxyUtils.nullValue(type);
- }
-
- private class InvocationRecorderInvoker implements Invoker
- {
- private final Type targetType;
-
- private InvocationRecorderInvoker( Type targetType )
- {
- this.targetType = targetType;
- }
-
- @SuppressWarnings("unchecked")
- public Object invoke( Object o, Method method, Object[] args ) throws Throwable
- {
- recordedInvocations.add(new RecordedInvocation(method, args));
- final Class returnType = getReturnType(targetType, method);
- return proxy(method.getGenericReturnType(), returnType);
- }
- }
-
- public void reset()
- {
- recordedInvocations.clear();
- }
-
- public static Class getReturnType( Type enclosingType, Method method ) throws Exception
- {
- Type returnType = method.getGenericReturnType();
- if( returnType instanceof Class )
- {
- return ( Class ) returnType;
- }
- else if( returnType instanceof TypeVariable )
- {
- return resolveVariable(enclosingType, ( TypeVariable ) returnType);
- }
- else if( returnType instanceof ParameterizedType )
- {
- return ( Class ) ( ( ParameterizedType ) returnType ).getRawType();
- }
- return null;
- }
-
- public static Class resolveVariable( Type enclosingType, TypeVariable typeVar ) throws Exception
- {
- if( enclosingType instanceof ParameterizedType )
- {
- ParameterizedType pt = ( ParameterizedType ) enclosingType;
- final Class rawType = ( Class ) pt.getRawType();
- TypeVariable[] typeParameters = rawType.getTypeParameters();
- for( int i = 0; i < typeParameters.length; i++ )
- {
- TypeVariable typeParameter = typeParameters[i];
- if( typeParameter == typeVar )
- {
- return ( Class ) pt.getActualTypeArguments()[i];
- }
- }
- }
- else if( enclosingType instanceof Class )
- {
- return resolveVariable(( ( Class ) enclosingType ).getGenericSuperclass(), typeVar);
- }
- return null;
- }
-}
diff --git a/src/main/java/org/apache/commons/proxy/invoker/recorder/RecordedInvocation.java b/src/main/java/org/apache/commons/proxy/invoker/recorder/RecordedInvocation.java
deleted file mode 100644
index 9eafbba..0000000
--- a/src/main/java/org/apache/commons/proxy/invoker/recorder/RecordedInvocation.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.recorder;
-
-import org.apache.commons.proxy.ProxyUtils;
-
-import java.lang.reflect.Method;
-
-/**
- * @auothor James Carman
- */
-public class RecordedInvocation
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private final Method invokedMethod;
- private final Object[] arguments;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public RecordedInvocation( Method invokedMethod, Object[] arguments )
- {
- this.invokedMethod = invokedMethod;
- this.arguments = arguments;
- }
-
-//**********************************************************************************************************************
-// Canonical Methods
-//**********************************************************************************************************************
-
- public Method getInvokedMethod()
- {
- return invokedMethod;
- }
-
- public Object[] getArguments()
- {
- return arguments;
- }
-
- public String toString()
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append(invokedMethod.getDeclaringClass().getName());
- buffer.append(".");
- buffer.append(invokedMethod.getName());
- buffer.append("(");
- int count = arguments.length;
- for( int i = 0; i < count; i++ )
- {
- Object arg = arguments[i];
- if( i > 0 )
- {
- buffer.append(", ");
- }
- convert(buffer, arg);
- }
- buffer.append(")");
- return buffer.toString();
- }
-
- protected void convert( StringBuffer buffer, Object input )
- {
- if( input == null )
- {
- buffer.append("<null>");
- return;
- }
-
- // Primitive types, and non-object arrays
- // use toString().
- if( !( input instanceof Object[] ) )
- {
- buffer.append(input.toString());
- return;
- }
- else
- {
- buffer.append("(");
- buffer.append(ProxyUtils.getJavaClassName(input.getClass()));
- buffer.append("){");
- Object[] array = ( Object[] ) input;
- int count = array.length;
- for( int i = 0; i < count; i++ )
- {
- if( i > 0 )
- {
- buffer.append(", ");
- }
- // We use convert() again, because it could be a multi-dimensional array
- // where each element must be converted.
- convert(buffer, array[i]);
- }
- buffer.append("}");
- }
- }
-}
diff --git a/src/main/java/org/apache/commons/proxy/package.html b/src/main/java/org/apache/commons/proxy/package.html
deleted file mode 100644
index 98a831a..0000000
--- a/src/main/java/org/apache/commons/proxy/package.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You 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.
- -->
-
-<body>
-<p>
- This package contains the primary API.
-</p>
-</body>
\ No newline at end of file
diff --git a/src/main/java/org/apache/commons/proxy/provider/BeanProvider.java b/src/main/java/org/apache/commons/proxy/provider/BeanProvider.java
deleted file mode 100644
index 66fa64e..0000000
--- a/src/main/java/org/apache/commons/proxy/provider/BeanProvider.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.provider;
-
-import org.apache.commons.proxy.ObjectProvider;
-import org.apache.commons.proxy.exception.ObjectProviderException;
-
-import java.io.Serializable;
-
-/**
- * Uses <code>Class.newInstance()</code> to instantiate an object.
- *
- * @author James Carman
- * @since 1.0
- */
-public class BeanProvider<T> implements ObjectProvider<T>, Serializable
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private Class<T> beanClass;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public BeanProvider()
- {
- }
-
- /**
- * Constructs a provider which instantiates objects of the specified bean class.
- *
- * @param beanClass the bean class
- */
- public BeanProvider( Class<T> beanClass )
- {
- this.beanClass = beanClass;
- }
-
-//**********************************************************************************************************************
-// ObjectProvider Implementation
-//**********************************************************************************************************************
-
- public T getObject()
- {
- try
- {
- if( beanClass == null )
- {
- throw new ObjectProviderException("No bean class provided.");
- }
- return beanClass.newInstance();
- }
- catch( InstantiationException e )
- {
- throw new ObjectProviderException("Class " + beanClass.getName() + " is not concrete.", e);
- }
- catch( IllegalAccessException e )
- {
- throw new ObjectProviderException("Constructor for class " + beanClass.getName() + " is not accessible.",
- e);
- }
- }
-
-//**********************************************************************************************************************
-// Getter/Setter Methods
-//**********************************************************************************************************************
-
- public void setBeanClass( Class<T> beanClass )
- {
- this.beanClass = beanClass;
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/provider/CloningProvider.java b/src/main/java/org/apache/commons/proxy/provider/CloningProvider.java
deleted file mode 100644
index eb60ff1..0000000
--- a/src/main/java/org/apache/commons/proxy/provider/CloningProvider.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.provider;
-
-import org.apache.commons.proxy.ObjectProvider;
-import org.apache.commons.proxy.ProxyUtils;
-import org.apache.commons.proxy.exception.ObjectProviderException;
-
-import java.io.Serializable;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-/**
- * Merely calls <code>clone()</code> (reflectively) on the given {@link Cloneable} object.
- *
- * @author James Carman
- * @since 1.0
- */
-public class CloningProvider<T extends Cloneable> implements ObjectProvider<T>, Serializable
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private final T cloneable;
- private Method cloneMethod;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- /**
- * Constructs a provider which returns clone copies of the specified {@link Cloneable}
- * object.
- *
- * @param cloneable the object to clone
- */
- public CloningProvider( T cloneable )
- {
- this.cloneable = cloneable;
- }
-
-//**********************************************************************************************************************
-// ObjectProvider Implementation
-//**********************************************************************************************************************
-
- @SuppressWarnings("unchecked")
- public T getObject()
- {
- try
- {
- return (T)getCloneMethod().invoke(cloneable, ProxyUtils.EMPTY_ARGUMENTS);
- }
- catch( IllegalAccessException e )
- {
- throw new ObjectProviderException(
- "Class " + cloneable.getClass().getName() + " does not have a public clone() method.", e);
- }
- catch( InvocationTargetException e )
- {
- throw new ObjectProviderException(
- "Attempt to clone object of type " + cloneable.getClass().getName() + " threw an exception.", e);
- }
- }
-
-//**********************************************************************************************************************
-// Getter/Setter Methods
-//**********************************************************************************************************************
-
- private synchronized Method getCloneMethod()
- {
- if( cloneMethod == null )
- {
- try
- {
- cloneMethod = cloneable.getClass().getMethod("clone", ProxyUtils.EMPTY_ARGUMENT_TYPES);
- }
- catch( NoSuchMethodException e )
- {
- throw new ObjectProviderException(
- "Class " + cloneable.getClass().getName() + " does not have a public clone() method.");
- }
- }
- return cloneMethod;
- }
-}
diff --git a/src/main/java/org/apache/commons/proxy/provider/ConstantProvider.java b/src/main/java/org/apache/commons/proxy/provider/ConstantProvider.java
deleted file mode 100644
index 312608e..0000000
--- a/src/main/java/org/apache/commons/proxy/provider/ConstantProvider.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.provider;
-
-import org.apache.commons.proxy.ObjectProvider;
-
-import java.io.Serializable;
-
-/**
- * Always returns the same object.
- *
- * @author James Carman
- * @since 1.0
- */
-public class ConstantProvider<T> implements ObjectProvider<T>, Serializable
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private final T constant;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public ConstantProvider( T constant )
- {
- this.constant = constant;
- }
-
-//**********************************************************************************************************************
-// ObjectProvider Implementation
-//**********************************************************************************************************************
-
- public T getObject()
- {
- return constant;
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/provider/NullProvider.java b/src/main/java/org/apache/commons/proxy/provider/NullProvider.java
deleted file mode 100644
index 88ad1dc..0000000
--- a/src/main/java/org/apache/commons/proxy/provider/NullProvider.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.provider;
-
-/**
- * Always returns null.
- *
- * @author James Carman
- * @since 1.0
- */
-public class NullProvider<T> extends ConstantProvider<T>
-{
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public NullProvider()
- {
- super(null);
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/provider/ProviderDecorator.java b/src/main/java/org/apache/commons/proxy/provider/ProviderDecorator.java
deleted file mode 100644
index d4ada2c..0000000
--- a/src/main/java/org/apache/commons/proxy/provider/ProviderDecorator.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.provider;
-
-import org.apache.commons.proxy.ObjectProvider;
-
-/**
- * Returns the result of the inner {@link ObjectProvider provider}. Subclasses can override the {@link #getObject()}
- * method and decorate what comes back from the inner provider in some way (by {@link SingletonProvider caching it} for
- * example).
- *
- * @author James Carman
- * @since 1.0
- */
-public class ProviderDecorator<T> implements ObjectProvider<T>
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- protected ObjectProvider<T> inner;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public ProviderDecorator( ObjectProvider<T> inner )
- {
- this.inner = inner;
- }
-
-//**********************************************************************************************************************
-// ObjectProvider Implementation
-//**********************************************************************************************************************
-
- public T getObject()
- {
- return inner.getObject();
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/provider/SingletonProvider.java b/src/main/java/org/apache/commons/proxy/provider/SingletonProvider.java
deleted file mode 100644
index d4cb2db..0000000
--- a/src/main/java/org/apache/commons/proxy/provider/SingletonProvider.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.provider;
-
-import org.apache.commons.proxy.ObjectProvider;
-
-/**
- * Wraps another object provider, making sure to only call it once, returning the value returned from the wrapped
- * provider on all subsequent invocations.
- *
- * @author James Carman
- * @since 1.0
- */
-public class SingletonProvider<T> extends ProviderDecorator<T>
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private T instance;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public SingletonProvider( ObjectProvider<T> inner )
- {
- super(inner);
- }
-
-//**********************************************************************************************************************
-// ObjectProvider Implementation
-//**********************************************************************************************************************
-
- public T getObject()
- {
- synchronized( this )
- {
- if( instance == null )
- {
- instance = super.getObject();
- inner = null; // Garbage collection
- }
- }
- return instance;
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/provider/package.html b/src/main/java/org/apache/commons/proxy/provider/package.html
deleted file mode 100644
index c5a0977..0000000
--- a/src/main/java/org/apache/commons/proxy/provider/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You 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.
- -->
-
-<html>
-<body>
-<p>
- This package contains some general-use <a href="../ObjectProvider.html">ObjectProvider</a> implementations.
-</p>
-</body>
-</html>
diff --git a/src/main/java/org/apache/commons/proxy/provider/remoting/BurlapProvider.java b/src/main/java/org/apache/commons/proxy/provider/remoting/BurlapProvider.java
deleted file mode 100644
index 291b607..0000000
--- a/src/main/java/org/apache/commons/proxy/provider/remoting/BurlapProvider.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.provider.remoting;
-
-import com.caucho.burlap.client.BurlapProxyFactory;
-import org.apache.commons.proxy.ObjectProvider;
-import org.apache.commons.proxy.exception.ObjectProviderException;
-
-import java.io.Serializable;
-import java.net.MalformedURLException;
-
-/**
- * Provides a burlap service object.
- * <p/>
- * <p>
- * <b>Dependencies</b>:
- * <ul>
- * <li>Burlap version 2.1.7 or greater</li>
- * </ul>
- * </p>
- *
- * @author James Carman
- * @since 1.0
- */
-public class BurlapProvider<T> implements ObjectProvider<T>, Serializable
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private Class<T> serviceInterface;
- private String url;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public BurlapProvider()
- {
- }
-
- public BurlapProvider( Class<T> serviceInterface, String url )
- {
- this.serviceInterface = serviceInterface;
- this.url = url;
- }
-
-//**********************************************************************************************************************
-// ObjectProvider Implementation
-//**********************************************************************************************************************
-
- @SuppressWarnings("unchecked")
- public T getObject()
- {
- try
- {
- return (T)new BurlapProxyFactory().create(serviceInterface, url);
- }
- catch( MalformedURLException e )
- {
- throw new ObjectProviderException("Invalid url given.", e);
- }
- }
-
-//**********************************************************************************************************************
-// Getter/Setter Methods
-//**********************************************************************************************************************
-
- public void setServiceInterface( Class<T> serviceInterface )
- {
- this.serviceInterface = serviceInterface;
- }
-
- public void setUrl( String url )
- {
- this.url = url;
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/provider/remoting/HessianProvider.java b/src/main/java/org/apache/commons/proxy/provider/remoting/HessianProvider.java
deleted file mode 100644
index b91191d..0000000
--- a/src/main/java/org/apache/commons/proxy/provider/remoting/HessianProvider.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.provider.remoting;
-
-import com.caucho.hessian.client.HessianProxyFactory;
-import org.apache.commons.proxy.ObjectProvider;
-import org.apache.commons.proxy.exception.ObjectProviderException;
-
-import java.io.Serializable;
-import java.net.MalformedURLException;
-
-/**
- * Provides a hessian service object.
- * <p/>
- * <p>
- * <b>Dependencies</b>:
- * <ul>
- * <li>Hessian version 3.0.1 or greater</li>
- * </ul>
- * </p>
- *
- * @author James Carman
- * @since 1.0
- */
-public class HessianProvider<T> implements ObjectProvider<T>, Serializable
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private Class<T> serviceInterface;
- private String url;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public HessianProvider()
- {
- }
-
- public HessianProvider( Class<T> serviceInterface, String url )
- {
- this.serviceInterface = serviceInterface;
- this.url = url;
- }
-
-//**********************************************************************************************************************
-// ObjectProvider Implementation
-//**********************************************************************************************************************
-
- @SuppressWarnings("unchecked")
- public T getObject()
- {
- try
- {
- return (T)new HessianProxyFactory().create(serviceInterface, url);
- }
- catch( MalformedURLException e )
- {
- throw new ObjectProviderException("Invalid url given.", e);
- }
- }
-
-//**********************************************************************************************************************
-// Getter/Setter Methods
-//**********************************************************************************************************************
-
- public void setServiceInterface( Class<T> serviceInterface )
- {
- this.serviceInterface = serviceInterface;
- }
-
- public void setUrl( String url )
- {
- this.url = url;
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/provider/remoting/JaxRpcProvider.java b/src/main/java/org/apache/commons/proxy/provider/remoting/JaxRpcProvider.java
deleted file mode 100644
index 014c363..0000000
--- a/src/main/java/org/apache/commons/proxy/provider/remoting/JaxRpcProvider.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.provider.remoting;
-
-import org.apache.commons.proxy.ObjectProvider;
-import org.apache.commons.proxy.exception.ObjectProviderException;
-
-import javax.xml.namespace.QName;
-import javax.xml.rpc.Service;
-import javax.xml.rpc.ServiceException;
-import javax.xml.rpc.ServiceFactory;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-/**
- * Returns a proxy for a JAX-RPC-based service.
- * <p/>
- * <p>
- * <b>Dependencies</b>:
- * <ul>
- * <li>A JAX-RPC implementation</li>
- * </ul>
- * </p>
- *
- * @author James Carman
- * @since 1.0
- */
-public class JaxRpcProvider<T> implements ObjectProvider<T>
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private Class<T> serviceInterface;
- private String wsdlUrl;
- private String serviceNamespaceUri;
- private String serviceLocalPart;
- private String servicePrefix;
- private String portNamespaceUri;
- private String portLocalPart;
- private String portPrefix;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public JaxRpcProvider()
- {
- }
-
- public JaxRpcProvider( Class<T> serviceInterface )
- {
- this.serviceInterface = serviceInterface;
- }
-
-//**********************************************************************************************************************
-// ObjectProvider Implementation
-//**********************************************************************************************************************
-
- public T getObject()
- {
- try
- {
- final Service service = ( wsdlUrl == null ?
- ServiceFactory.newInstance().createService(getServiceQName()) : ServiceFactory
- .newInstance().createService(new URL(wsdlUrl), getServiceQName()) );
- final QName portQName = getPortQName();
- return serviceInterface.cast(portQName == null ? service.getPort(serviceInterface) :
- service.getPort(portQName, serviceInterface));
- }
- catch( ServiceException e )
- {
- throw new ObjectProviderException("Unable to create JAX-RPC service proxy.", e);
- }
- catch( MalformedURLException e )
- {
- throw new ObjectProviderException("Invalid URL given.", e);
- }
- }
-
-//**********************************************************************************************************************
-// Getter/Setter Methods
-//**********************************************************************************************************************
-
- public void setPortLocalPart( String portLocalPart )
- {
- this.portLocalPart = portLocalPart;
- }
-
- public void setPortNamespaceUri( String portNamespaceUri )
- {
- this.portNamespaceUri = portNamespaceUri;
- }
-
- public void setPortPrefix( String portPrefix )
- {
- this.portPrefix = portPrefix;
- }
-
- public void setServiceInterface( Class<T> serviceInterface )
- {
- this.serviceInterface = serviceInterface;
- }
-
- public void setServiceLocalPart( String serviceLocalPart )
- {
- this.serviceLocalPart = serviceLocalPart;
- }
-
- public void setServiceNamespaceUri( String serviceNamespaceUri )
- {
- this.serviceNamespaceUri = serviceNamespaceUri;
- }
-
- public void setServicePrefix( String servicePrefix )
- {
- this.servicePrefix = servicePrefix;
- }
-
- public void setWsdlUrl( String wsdlUrl )
- {
- this.wsdlUrl = wsdlUrl;
- }
-
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- private QName getPortQName()
- {
- return getQName(portNamespaceUri, portLocalPart, portPrefix);
- }
-
- private QName getQName( String namespaceUri, String localPart, String prefix )
- {
- if( namespaceUri != null && localPart != null && prefix != null )
- {
- return new QName(namespaceUri, localPart, prefix);
- }
- else if( namespaceUri != null && localPart != null )
- {
- return new QName(namespaceUri, localPart);
- }
- else if( localPart != null )
- {
- return new QName(localPart);
- }
- return null;
- }
-
- private QName getServiceQName()
- {
- return getQName(serviceNamespaceUri, serviceLocalPart, servicePrefix);
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/provider/remoting/RmiProvider.java b/src/main/java/org/apache/commons/proxy/provider/remoting/RmiProvider.java
deleted file mode 100644
index a538711..0000000
--- a/src/main/java/org/apache/commons/proxy/provider/remoting/RmiProvider.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.provider.remoting;
-
-import org.apache.commons.proxy.ObjectProvider;
-import org.apache.commons.proxy.exception.ObjectProviderException;
-
-import java.rmi.NotBoundException;
-import java.rmi.RemoteException;
-import java.rmi.registry.LocateRegistry;
-import java.rmi.registry.Registry;
-import java.rmi.server.RMIClientSocketFactory;
-
-/**
- * Provides an object by looking it up in an RMI registry.
- *
- * @author James Carman
- * @since 1.0
- */
-public class RmiProvider<T> implements ObjectProvider<T>
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private String host = "localhost";
- private int port = Registry.REGISTRY_PORT;
- private RMIClientSocketFactory clientSocketFactory;
- private String name;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public RmiProvider()
- {
- }
-
- public RmiProvider( String name )
- {
- setName(name);
- }
-
- public RmiProvider( String host, String name )
- {
- setHost(host);
- setName(name);
- }
-
- public RmiProvider( String host, int port, String name )
- {
- setHost(host);
- setName(name);
- setPort(port);
- }
-
- public RmiProvider( String host, int port, RMIClientSocketFactory clientSocketFactory, String name )
- {
- setHost(host);
- setPort(port);
- setClientSocketFactory(clientSocketFactory);
- setName(name);
- }
-
-//**********************************************************************************************************************
-// ObjectProvider Implementation
-//**********************************************************************************************************************
-
- @SuppressWarnings("unchecked")
- public T getObject()
- {
- Registry reg;
- try
- {
- reg = getRegistry();
- return (T)reg.lookup(name);
- }
- catch( NotBoundException e )
- {
- throw new ObjectProviderException("Name " + name + " not found in registry at " + host + ":" + port + ".",
- e);
- }
- catch( RemoteException e )
- {
- throw new ObjectProviderException(
- "Unable to lookup service named " + name + " in registry at " + host + ":" + port + ".", e);
- }
- }
-
-//**********************************************************************************************************************
-// Getter/Setter Methods
-//**********************************************************************************************************************
-
- public void setClientSocketFactory( RMIClientSocketFactory clientSocketFactory )
- {
- this.clientSocketFactory = clientSocketFactory;
- }
-
- public void setHost( String host )
- {
- this.host = host;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public void setPort( int port )
- {
- this.port = port;
- }
-
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- private Registry getRegistry()
- {
- try
- {
- if( clientSocketFactory != null )
- {
- return LocateRegistry.getRegistry(host, port, clientSocketFactory);
- }
- else
- {
- return LocateRegistry.getRegistry(host, port);
- }
- }
- catch( RemoteException e )
- {
- throw new ObjectProviderException("Unable to locate registry at " + host + ":" + port + ".", e);
- }
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/provider/remoting/SessionBeanProvider.java b/src/main/java/org/apache/commons/proxy/provider/remoting/SessionBeanProvider.java
deleted file mode 100644
index 971d0a6..0000000
--- a/src/main/java/org/apache/commons/proxy/provider/remoting/SessionBeanProvider.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.provider.remoting;
-
-import org.apache.commons.proxy.ObjectProvider;
-import org.apache.commons.proxy.ProxyUtils;
-import org.apache.commons.proxy.exception.ObjectProviderException;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.rmi.PortableRemoteObject;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Properties;
-
-/**
- * Provides a reference to a session bean by looking up the home object and calling (via reflection) the no-argument
- * create() method. This will work for both local and remote session beans.
- *
- * @author James Carman
- * @since 1.0
- */
-public class SessionBeanProvider<T> implements ObjectProvider<T>
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private final String jndiName;
- private final Class homeInterface;
- private final Properties properties;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public SessionBeanProvider( String jndiName, Class homeInterface )
- {
- this.jndiName = jndiName;
- this.homeInterface = homeInterface;
- this.properties = null;
- }
-
- public SessionBeanProvider( String jndiName, Class homeInterface, Properties properties )
- {
- this.jndiName = jndiName;
- this.homeInterface = homeInterface;
- this.properties = properties;
- }
-
-//**********************************************************************************************************************
-// ObjectProvider Implementation
-//**********************************************************************************************************************
-
- @SuppressWarnings("unchecked")
- public T getObject()
- {
- try
- {
- final InitialContext initialContext = properties == null ? new InitialContext() :
- new InitialContext(properties);
- Object homeObject = PortableRemoteObject.narrow(initialContext.lookup(jndiName), homeInterface);
- final Method createMethod = homeObject.getClass().getMethod("create", ProxyUtils.EMPTY_ARGUMENT_TYPES);
- return (T)createMethod.invoke(homeObject, ProxyUtils.EMPTY_ARGUMENTS);
- }
- catch( NoSuchMethodException e )
- {
- throw new ObjectProviderException(
- "Unable to find no-arg create() method on home interface " + homeInterface.getName() + ".", e);
- }
- catch( IllegalAccessException e )
- {
- throw new ObjectProviderException(
- "No-arg create() method on home interface " + homeInterface.getName() + " is not accessible.",
- e); // Should never happen!
- }
- catch( NamingException e )
- {
- throw new ObjectProviderException("Unable to lookup EJB home object in JNDI.", e);
- }
- catch( InvocationTargetException e )
- {
- throw new ObjectProviderException(
- "No-arg create() method on home interface " + homeInterface.getName() + " threw an exception.", e);
- }
- }
-}
-
diff --git a/src/main/java/org/apache/commons/proxy/provider/remoting/package.html b/src/main/java/org/apache/commons/proxy/provider/remoting/package.html
deleted file mode 100644
index e906038..0000000
--- a/src/main/java/org/apache/commons/proxy/provider/remoting/package.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You 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.
- -->
-
-<html>
-<body>
-<p>
- This package contains some useful <a href="../../ObjectProvider.html">ObjectProvider</a> implementations for use
- in remoting situations (EJB, RMI, Burlap, Hessian, JAX-RPC, etc).
-</p>
-</body>
-</html>
diff --git a/src/test/java/org/apache/commons/proxy/TestProxyFactory.java b/src/test/java/org/apache/commons/proxy/TestProxyFactory.java
deleted file mode 100644
index adcb216..0000000
--- a/src/test/java/org/apache/commons/proxy/TestProxyFactory.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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;
-
-import org.apache.commons.proxy.factory.AbstractProxyFactoryTestCase;
-
-public class TestProxyFactory extends AbstractProxyFactoryTestCase
-{
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public TestProxyFactory()
- {
- super(new ProxyFactory());
- }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/commons/proxy/TestProxyUtils.java b/src/test/java/org/apache/commons/proxy/TestProxyUtils.java
deleted file mode 100644
index bb3fa79..0000000
--- a/src/test/java/org/apache/commons/proxy/TestProxyUtils.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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;
-
-import junit.framework.TestCase;
-import org.apache.commons.proxy.factory.javassist.JavassistProxyFactory;
-import org.apache.commons.proxy.util.DuplicateEcho;
-import org.apache.commons.proxy.util.Echo;
-import org.apache.commons.proxy.util.EchoImpl;
-
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.Properties;
-
-public class TestProxyUtils extends TestCase
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private Properties prevProperties;
-
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- protected void setUp() throws Exception
- {
- prevProperties = System.getProperties();
- System.setProperties(new Properties());
- }
-
- protected void tearDown() throws Exception
- {
- System.setProperties(prevProperties);
- }
-
- public void testNullValue()
- {
- assertNullValue(null, String.class);
- assertNullValue(( char ) 0, Character.TYPE);
- assertNullValue(0, Integer.TYPE);
- assertNullValue(( long ) 0, Long.TYPE);
- assertNullValue(( short ) 0, Short.TYPE);
- assertNullValue(( double ) 0, Double.TYPE);
- assertNullValue(( float ) 0, Float.TYPE);
- assertNullValue(false, Boolean.TYPE);
- assertNullValue(( byte ) 0, Byte.TYPE);
- }
-
- private void assertNullValue( Object expected, Class type )
- {
- assertEquals(expected, ProxyUtils.nullValue(type));
- }
-
- public void testCreateNullObject() throws Exception
- {
- final Echo nullEcho = ( Echo ) ProxyUtils
- .createNullObject(new JavassistProxyFactory(), new Class[] {Echo.class});
- assertNull(nullEcho.echoBack("hello"));
- assertNull(nullEcho.echoBack("hello", "world"));
- assertEquals(( int ) 0, nullEcho.echoBack(12345));
- }
-
- public void testCreateNullObjectWithClassLoader() throws Exception
- {
- final Echo nullEcho = ( Echo ) ProxyUtils.createNullObject(new JavassistProxyFactory(),
- Echo.class.getClassLoader(),
- new Class[] {Echo.class});
- assertNull(nullEcho.echoBack("hello"));
- assertNull(nullEcho.echoBack("hello", "world"));
- assertEquals(( int ) 0, nullEcho.echoBack(12345));
- }
-
- public void testGetAllInterfaces()
- {
- assertNull(ProxyUtils.getAllInterfaces(null));
- assertEquals(Arrays.asList(new Class[] {DuplicateEcho.class, Serializable.class, Echo.class}),
- Arrays.asList(ProxyUtils.getAllInterfaces(EchoImpl.class)));
- }
-
- public void testGetJavaClassName() throws Exception
- {
- assertEquals("java.lang.Object[]", ProxyUtils.getJavaClassName(Object[].class));
- assertEquals("java.lang.Object[][]", ProxyUtils.getJavaClassName(Object[][].class));
- assertEquals("java.lang.String[][][]", ProxyUtils.getJavaClassName(String[][][].class));
- assertEquals("int", ProxyUtils.getJavaClassName(Integer.TYPE));
- assertEquals("float", ProxyUtils.getJavaClassName(Float.TYPE));
- assertEquals("long", ProxyUtils.getJavaClassName(Long.TYPE));
- assertEquals("double", ProxyUtils.getJavaClassName(Double.TYPE));
- assertEquals("short", ProxyUtils.getJavaClassName(Short.TYPE));
- assertEquals("byte", ProxyUtils.getJavaClassName(Byte.TYPE));
- assertEquals("char", ProxyUtils.getJavaClassName(Character.TYPE));
- assertEquals("boolean", ProxyUtils.getJavaClassName(Boolean.TYPE));
- }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/commons/proxy/exception/AbstractExceptionClassTestCase.java b/src/test/java/org/apache/commons/proxy/exception/AbstractExceptionClassTestCase.java
deleted file mode 100644
index 343ddd6..0000000
--- a/src/test/java/org/apache/commons/proxy/exception/AbstractExceptionClassTestCase.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.exception;
-
-import junit.framework.TestCase;
-
-/**
- * @author James Carman
- * @since 1.0
- */
-public abstract class AbstractExceptionClassTestCase extends TestCase
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private final Class exceptionClass;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public AbstractExceptionClassTestCase( Class exceptionClass )
- {
- this.exceptionClass = exceptionClass;
- }
-
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public void testCauseOnlyConstructor() throws Exception
- {
- final Exception cause = new Exception();
- Exception e = ( Exception ) exceptionClass.getConstructor(new Class[] {Throwable.class}).newInstance(new Object[] {cause});
- assertEquals(cause.toString(), e.getMessage());
- assertEquals(cause, e.getCause());
- }
-
- public void testMessageAndCauseConstructor() throws Exception
- {
- final Exception cause = new Exception();
- final String message = "message";
- Exception e = ( Exception ) exceptionClass.getConstructor(new Class[] {String.class, Throwable.class}).newInstance(new Object[] {message, cause});
- assertEquals(message, e.getMessage());
- assertEquals(cause, e.getCause());
- }
-
- public void testMessageOnlyConstructor() throws Exception
- {
- final String message = "message";
- Exception e = ( Exception ) exceptionClass.getConstructor(new Class[] {String.class}).newInstance(new Object[] {message});
- assertEquals(message, e.getMessage());
- assertNull(e.getCause());
- }
-
- public void testNoArgConstructor() throws Exception
- {
- Exception e = ( Exception ) exceptionClass.getConstructor(new Class[] {}).newInstance(new Object[] {});
- assertNull(e.getMessage());
- assertNull(e.getCause());
- }
-}
diff --git a/src/test/java/org/apache/commons/proxy/exception/TestDelegateProviderException.java b/src/test/java/org/apache/commons/proxy/exception/TestDelegateProviderException.java
deleted file mode 100644
index 45af58c..0000000
--- a/src/test/java/org/apache/commons/proxy/exception/TestDelegateProviderException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.exception;
-
-public class TestDelegateProviderException extends AbstractExceptionClassTestCase
-{
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public TestDelegateProviderException()
- {
- super(ObjectProviderException.class);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/commons/proxy/exception/TestInvocationHandlerException.java b/src/test/java/org/apache/commons/proxy/exception/TestInvocationHandlerException.java
deleted file mode 100644
index 13ed169..0000000
--- a/src/test/java/org/apache/commons/proxy/exception/TestInvocationHandlerException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.exception;
-
-public class TestInvocationHandlerException extends AbstractExceptionClassTestCase
-{
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public TestInvocationHandlerException()
- {
- super(InvokerException.class);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/commons/proxy/exception/TestProxyFactoryException.java b/src/test/java/org/apache/commons/proxy/exception/TestProxyFactoryException.java
deleted file mode 100644
index 4498a29..0000000
--- a/src/test/java/org/apache/commons/proxy/exception/TestProxyFactoryException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.exception;
-
-/**
- * @author James Carman
- * @since 1.0
- */
-public class TestProxyFactoryException extends AbstractExceptionClassTestCase
-{
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public TestProxyFactoryException()
- {
- super(ProxyFactoryException.class);
- }
-}
diff --git a/src/test/java/org/apache/commons/proxy/factory/AbstractProxyFactoryTestCase.java b/src/test/java/org/apache/commons/proxy/factory/AbstractProxyFactoryTestCase.java
deleted file mode 100644
index 351b7dd..0000000
--- a/src/test/java/org/apache/commons/proxy/factory/AbstractProxyFactoryTestCase.java
+++ /dev/null
@@ -1,397 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.factory;
-
-import org.apache.commons.proxy.Interceptor;
-import org.apache.commons.proxy.Invocation;
-import org.apache.commons.proxy.Invoker;
-import org.apache.commons.proxy.ObjectProvider;
-import org.apache.commons.proxy.ProxyFactory;
-import org.apache.commons.proxy.provider.BeanProvider;
-import org.apache.commons.proxy.provider.ConstantProvider;
-import org.apache.commons.proxy.provider.SingletonProvider;
-import org.apache.commons.proxy.util.AbstractTestCase;
-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.SuffixInterceptor;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-/**
- * @author James Carman
- * @since 1.0
- */
-public abstract class AbstractProxyFactoryTestCase extends AbstractTestCase
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private static final Class[] ECHO_ONLY = new Class[]{Echo.class};
- protected final ProxyFactory factory;
- private static final Class[] COMPARABLE_ONLY = new Class[] { Comparable.class };
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- protected AbstractProxyFactoryTestCase(ProxyFactory factory)
- {
- this.factory = factory;
- }
-
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- private ObjectProvider createSingletonEcho()
- {
- return new SingletonProvider(new BeanProvider(EchoImpl.class));
- }
-
- public void testInterceptorHashCode()
- {
- final Echo proxy = (Echo) factory.createInterceptorProxy(new EchoImpl(), new NoOpMethodInterceptor(), ECHO_ONLY);
- assertEquals(proxy.hashCode(), System.identityHashCode(proxy));
- }
-
- public void testInvokerHashCode() throws Exception
- {
- final Echo proxy = (Echo) factory.createInvokerProxy(new InvokerTester(), ECHO_ONLY);
- assertEquals(proxy.hashCode(), System.identityHashCode(proxy));
- }
-
- public void testDelegatorHashCode() throws Exception
- {
- final Echo proxy = factory.createDelegatorProxy(new ConstantProvider<Echo>(new EchoImpl()), Echo.class);
- assertEquals(proxy.hashCode(), System.identityHashCode(proxy));
- }
-
-
- public void testInterceptorEquals()
- {
- final Date date = new Date();
- final Comparable proxy1 = (Comparable) factory.createInterceptorProxy(date,
- new NoOpMethodInterceptor(), COMPARABLE_ONLY);
- final Comparable proxy2 = (Comparable) factory.createInterceptorProxy(date,
- new NoOpMethodInterceptor(), COMPARABLE_ONLY);
- assertEquals(proxy1, proxy1);
- assertFalse(proxy1.equals(proxy2));
- assertFalse(proxy2.equals(proxy1));
- }
-
- public void testInvokerEquals() throws Exception
- {
- final Comparable proxy1 = (Comparable) factory.createInvokerProxy(new InvokerTester(), COMPARABLE_ONLY);
- final Comparable proxy2 = (Comparable) factory.createInvokerProxy(new InvokerTester(), COMPARABLE_ONLY);
- assertEquals(proxy1, proxy1);
- assertFalse(proxy1.equals(proxy2));
- assertFalse(proxy2.equals(proxy1));
- }
-
- public void testDelegatorEquals() throws Exception
- {
- final Date date = new Date();
- final Comparable proxy1 = (Comparable) factory.createDelegatorProxy(new ConstantProvider<Date>(date),
- COMPARABLE_ONLY);
- final Comparable proxy2 = (Comparable) factory.createDelegatorProxy(new ConstantProvider<Date>(date),
- COMPARABLE_ONLY);
- assertEquals(proxy1, proxy1);
- assertFalse(proxy1.equals(proxy2));
- assertFalse(proxy2.equals(proxy1));
- }
-
- public void testBooleanInterceptorParameter()
- {
- final Echo echo = (Echo) factory.createInterceptorProxy(new EchoImpl(), new InterceptorTester(), ECHO_ONLY);
- assertFalse(echo.echoBack(false));
- assertTrue(echo.echoBack(true));
- }
-
- public void testCanProxy()
- {
- assertTrue(factory.canProxy(Echo.class));
- assertFalse(factory.canProxy(EchoImpl.class));
- }
-
- public void testChangingArguments()
- {
- final Echo proxy = (Echo) factory.createInterceptorProxy(new EchoImpl(), new ChangeArgumentInterceptor(), ECHO_ONLY);
- assertEquals("something different", proxy.echoBack("whatever"));
- }
-
- public void testCreateDelegatingProxy()
- {
- final Echo echo = (Echo) factory.createDelegatorProxy(createSingletonEcho(), ECHO_ONLY);
- echo.echo();
- assertEquals("message", echo.echoBack("message"));
- assertEquals("ab", echo.echoBack("a", "b"));
- }
-
- public void testCreateInterceptorProxy()
- {
- final Echo target = (Echo) factory.createDelegatorProxy(createSingletonEcho(), ECHO_ONLY);
- final Echo proxy = (Echo) factory.createInterceptorProxy(target, new SuffixInterceptor(" suffix"), ECHO_ONLY);
- proxy.echo();
- assertEquals("message suffix", proxy.echoBack("message"));
- }
-
- public void testDelegatingProxyClassCaching() throws Exception
- {
- final Echo proxy1 = factory.createDelegatorProxy(new ConstantProvider<Echo>(new EchoImpl()), Echo.class);
- final Echo proxy2 = factory.createDelegatorProxy(new ConstantProvider<Echo>(new EchoImpl()), Echo.class);
- assertNotSame(proxy1, proxy2);
- assertSame(proxy1.getClass(), proxy2.getClass());
- }
-
- public void testDelegatingProxyInterfaceOrder()
- {
- final Echo echo = (Echo) factory.createDelegatorProxy(createSingletonEcho(), Echo.class, DuplicateEcho.class);
- 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);
- }
-
- public void testDelegatingProxySerializable() throws Exception
- {
- final Echo proxy = factory.createDelegatorProxy(new ConstantProvider<Echo>(new EchoImpl()), Echo.class);
- assertSerializable(proxy);
- }
-
- public void testInterceptingProxyClassCaching() throws Exception
- {
- final Echo proxy1 = (Echo) factory.createInterceptorProxy(new EchoImpl(), new NoOpMethodInterceptor(), ECHO_ONLY);
- final Echo proxy2 = (Echo) factory.createInterceptorProxy(new EchoImpl(), new NoOpMethodInterceptor(), ECHO_ONLY);
- assertNotSame(proxy1, proxy2);
- assertSame(proxy1.getClass(), proxy2.getClass());
- }
-
- public void testInterceptingProxySerializable() throws Exception
- {
- final Echo proxy = (Echo) factory.createInterceptorProxy(new EchoImpl(), new NoOpMethodInterceptor(), ECHO_ONLY);
- assertSerializable(proxy);
- }
-
- public void testInterceptorProxyWithCheckedException() throws Exception
- {
- final Echo proxy = (Echo) factory.createInterceptorProxy(new EchoImpl(), new NoOpMethodInterceptor(), ECHO_ONLY);
- try
- {
- proxy.ioException();
- fail();
- }
- catch (IOException e)
- {
- }
- }
-
- public void testInterceptorProxyWithUncheckedException() throws Exception
- {
- final Echo proxy = (Echo) factory.createInterceptorProxy(new EchoImpl(), new NoOpMethodInterceptor(), ECHO_ONLY);
- try
- {
- proxy.illegalArgument();
- fail();
- }
- catch (IllegalArgumentException e)
- {
- }
- }
-
- @SuppressWarnings("unchecked")
- public void testInterfaceHierarchies()
- {
- final SortedSet set = factory.createDelegatorProxy(new ConstantProvider<SortedSet>(new TreeSet()), SortedSet.class);
- set.add("Hello");
- }
-
- public void testInvokerProxy() throws Exception
- {
- final InvokerTester tester = new InvokerTester();
- final Echo echo = (Echo) factory.createInvokerProxy(tester, ECHO_ONLY);
- echo.echoBack("hello");
- assertEquals(Echo.class.getMethod("echoBack", String.class), tester.method);
- assertSame(echo, tester.proxy);
- assertNotNull(tester.args);
- assertEquals(1, tester.args.length);
- assertEquals("hello", tester.args[0]);
- }
-
- public void testInvokerProxyClassCaching() throws Exception
- {
- final Echo proxy1 = (Echo) factory.createInvokerProxy(new InvokerTester(), ECHO_ONLY);
- final Echo proxy2 = (Echo) factory.createInvokerProxy(new InvokerTester(), ECHO_ONLY);
- assertNotSame(proxy1, proxy2);
- assertSame(proxy1.getClass(), proxy2.getClass());
- }
-
- public void testInvokerProxySerializable() throws Exception
- {
- final Echo proxy = (Echo) factory.createInvokerProxy(new InvokerTester(), ECHO_ONLY);
- assertSerializable(proxy);
- }
-
- public void testMethodInvocationClassCaching() throws Exception
- {
- 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, Echo.class, DuplicateEcho.class);
- proxy1.echoBack("hello1");
- final Class invocationClass1 = tester.invocationClass;
- proxy2.echoBack("hello2");
- assertSame(invocationClass1, tester.invocationClass);
- }
-
- public void testMethodInvocationDuplicateMethods() throws Exception
- {
- final InterceptorTester tester = new InterceptorTester();
- final EchoImpl target = new EchoImpl();
- final Echo proxy = (Echo) factory.createInterceptorProxy(target, tester, Echo.class, DuplicateEcho.class);
- proxy.echoBack("hello");
- assertEquals(Echo.class.getMethod("echoBack", String.class), tester.method);
- }
-
- public void testMethodInvocationImplementation() throws Exception
- {
- 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"), tester.method);
- assertEquals(target, tester.proxy);
- proxy.echoBack("Hello");
- assertNotNull(tester.arguments);
- assertEquals(1, tester.arguments.length);
- assertEquals("Hello", tester.arguments[0]);
- assertEquals(Echo.class.getMethod("echoBack", String.class), tester.method);
- proxy.echoBack("Hello", "World");
- assertNotNull(tester.arguments);
- assertEquals(2, tester.arguments.length);
- assertEquals("Hello", tester.arguments[0]);
- assertEquals("World", tester.arguments[1]);
- assertEquals(Echo.class.getMethod("echoBack", String.class, String.class), tester.method);
- }
-
- public void testPrimitiveParameter()
- {
- final Echo echo = (Echo) factory.createDelegatorProxy(createSingletonEcho(), ECHO_ONLY);
- assertEquals(1, echo.echoBack(1));
- }
-
- public void testProxyWithCheckedException() throws Exception
- {
- final Echo proxy = factory.createDelegatorProxy(new ConstantProvider<Echo>(new EchoImpl()), Echo.class);
- try
- {
- proxy.ioException();
- fail();
- }
- catch (IOException e)
- {
- }
- }
-
- public void testProxyWithUncheckedException() throws Exception
- {
- final Echo proxy = factory.createDelegatorProxy(new ConstantProvider<Echo>(new EchoImpl()), Echo.class);
- try
- {
- proxy.illegalArgument();
- fail();
- }
- catch (IllegalArgumentException e)
- {
- }
- }
-
- public void testWithNonAccessibleTargetType()
- {
- final Echo proxy = (Echo) factory.createInterceptorProxy(new PrivateEcho(), new NoOpMethodInterceptor(), ECHO_ONLY);
- proxy.echo();
- }
-
-//**********************************************************************************************************************
-// Inner Classes
-//**********************************************************************************************************************
-
- private static class ChangeArgumentInterceptor implements Interceptor
- {
- public Object intercept(Invocation methodInvocation) throws Throwable
- {
- methodInvocation.getArguments()[0] = "something different";
- return methodInvocation.proceed();
- }
- }
-
- protected static class InterceptorTester implements Interceptor
- {
- private Object[] arguments;
- private Method method;
- private Object proxy;
- private Class invocationClass;
-
- public Object intercept(Invocation methodInvocation) throws Throwable
- {
- arguments = methodInvocation.getArguments();
- method = methodInvocation.getMethod();
- proxy = methodInvocation.getProxy();
- invocationClass = methodInvocation.getClass();
- return methodInvocation.proceed();
- }
- }
-
- protected static class InvokerTester implements Invoker
- {
- private Object method;
- private Object[] args;
- private Object proxy;
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
- {
- this.proxy = proxy;
- this.method = method;
- this.args = args;
- return null;
- }
- }
-
- protected static class NoOpMethodInterceptor implements Interceptor, Serializable
- {
- public Object intercept(Invocation methodInvocation) throws Throwable
- {
- return methodInvocation.proceed();
- }
- }
-
- private static class PrivateEcho extends EchoImpl
- {
- }
-}
diff --git a/src/test/java/org/apache/commons/proxy/factory/AbstractSubclassingProxyFactoryTestCase.java b/src/test/java/org/apache/commons/proxy/factory/AbstractSubclassingProxyFactoryTestCase.java
deleted file mode 100644
index 9733f58..0000000
--- a/src/test/java/org/apache/commons/proxy/factory/AbstractSubclassingProxyFactoryTestCase.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.factory;
-
-import org.apache.commons.proxy.ProxyFactory;
-import org.apache.commons.proxy.exception.ProxyFactoryException;
-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;
-import org.apache.commons.proxy.util.EchoImpl;
-
-import java.util.Date;
-
-/**
- * @author James Carman
- * @since 1.0
- */
-public abstract class AbstractSubclassingProxyFactoryTestCase extends AbstractProxyFactoryTestCase
-{
- private static final Class[] DATE_ONLY = new Class[]{Date.class};
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- protected AbstractSubclassingProxyFactoryTestCase(ProxyFactory factory)
- {
- super(factory);
- }
-
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public void testCanProxy()
- {
- assertTrue(factory.canProxy(new Class[]{Echo.class}));
- assertTrue(factory.canProxy(new Class[]{EchoImpl.class}));
- assertFalse(factory.canProxy(new Class[]{FinalEcho.class}));
- assertTrue(factory.canProxy(new Class[]{FinalMethodEcho.class, Echo.class}));
- assertFalse(factory.canProxy(new Class[]{NoDefaultConstructorEcho.class}));
- assertTrue(factory.canProxy(new Class[]{ProtectedConstructorEcho.class}));
- assertFalse(factory.canProxy(new Class[]{InvisibleEcho.class}));
- assertFalse(factory.canProxy(new Class[]{Echo.class, EchoImpl.class, String.class}));
- }
-
- public void testDelegatorWithMultipleSuperclasses()
- {
- try
- {
- factory.createDelegatorProxy(new ConstantProvider(new EchoImpl()),
- new Class[]{EchoImpl.class, String.class});
- fail();
- }
- catch (ProxyFactoryException e)
- {
- }
- }
-
- public void testDelegatorWithSuperclass()
- {
- final Echo echo = (Echo) factory
- .createDelegatorProxy(new ConstantProvider(new EchoImpl()), new Class[]{Echo.class, EchoImpl.class});
- assertTrue(echo instanceof EchoImpl);
- }
-
- public void testInterceptorWithMultipleSuperclasses()
- {
- try
- {
- factory.createInterceptorProxy(new EchoImpl(), new NoOpMethodInterceptor(),
- new Class[]{EchoImpl.class, String.class});
- fail();
- }
- catch (ProxyFactoryException e)
- {
- }
- }
-
- public void testInterceptorWithSuperclass()
- {
- final Echo echo = (Echo) factory
- .createInterceptorProxy(new EchoImpl(), new NoOpMethodInterceptor(), new Class[]{Echo.class, EchoImpl.class});
- assertTrue(echo instanceof EchoImpl);
- }
-
- public void testInvocationHandlerWithMultipleSuperclasses()
- {
- try
- {
- factory.createInvokerProxy(new NullInvoker(),
- new Class[]{EchoImpl.class, String.class});
- fail();
- }
- catch (ProxyFactoryException e)
- {
- }
- }
-
- public void testInvokerWithSuperclass()
- {
- final Echo echo = (Echo) factory
- .createInvokerProxy(new NullInvoker(), new Class[]{Echo.class, EchoImpl.class});
- assertTrue(echo instanceof EchoImpl);
- }
-
- public void testProxiesWithClashingFinalMethodInSuperclass()
- {
- final Class[] proxyClasses = new Class[]{Echo.class, FinalMethodEcho.class};
- Echo proxy = (Echo) factory.createDelegatorProxy(new ConstantProvider(new EchoImpl()), proxyClasses);
- assertEquals("final", proxy.echoBack("echo"));
-
- proxy = (Echo) factory.createInterceptorProxy(new EchoImpl(), new NoOpMethodInterceptor(), proxyClasses);
- assertEquals("final", proxy.echoBack("echo"));
-
- proxy = (Echo) factory.createInvokerProxy(new NullInvoker(), proxyClasses);
- assertEquals("final", proxy.echoBack("echo"));
- }
-
- public void testWithAbstractSuperclass()
- {
- final Echo echo = (Echo) factory.createDelegatorProxy(new ConstantProvider(new EchoImpl()), new Class[]{AbstractEcho.class});
- assertEquals("hello", echo.echoBack("hello"));
- assertEquals("helloworld", echo.echoBack("hello", "world"));
- }
-
- public void testInterceptorEquals()
- {
- final EqualsEcho echo = new EqualsEcho("text");
- final Echo proxy1 = (Echo) factory.createInterceptorProxy(echo,
- new NoOpMethodInterceptor(), new Class[] { EqualsEcho.class } );
- final Echo proxy2 = (Echo) factory.createInterceptorProxy(echo,
- new NoOpMethodInterceptor(), new Class[] { EqualsEcho.class } );
- assertEquals(proxy1, proxy1);
- assertFalse(proxy1.equals(proxy2));
- assertFalse(proxy2.equals(proxy1));
- }
-
- public void testInvokerEquals() throws Exception
- {
- final Date proxy1 = (Date) factory.createInvokerProxy(new InvokerTester(), DATE_ONLY);
- final Date proxy2 = (Date) factory.createInvokerProxy(new InvokerTester(), DATE_ONLY);
- assertEquals(proxy1, proxy1);
- assertFalse(proxy1.equals(proxy2));
- assertFalse(proxy2.equals(proxy1));
- }
-
- public void testDelegatorEquals() throws Exception
- {
- final EqualsEcho echo = new EqualsEcho("text");
- final Echo proxy1 = (Echo) factory.createDelegatorProxy(new ConstantProvider(echo),
- new Class[] { EqualsEcho.class });
- final Echo proxy2 = (Echo) factory.createDelegatorProxy(new ConstantProvider(echo),
- new Class[] { EqualsEcho.class });
- assertEquals(proxy1, proxy1);
- assertFalse(proxy1.equals(proxy2));
- assertFalse(proxy2.equals(proxy1));
- }
-
-//**********************************************************************************************************************
-// Inner Classes
-//**********************************************************************************************************************
-
- public static final class FinalEcho extends EchoImpl
- {
- }
-
- public static class FinalMethodEcho extends EchoImpl
- {
- public final String echoBack(String message)
- {
- return "final";
- }
- }
-
- public static class EqualsEcho extends EchoImpl
- {
- private final String text;
-
- public EqualsEcho()
- {
- this("testing");
- }
-
- public EqualsEcho(String text)
- {
- this.text = text;
- }
- }
-
- private static class InvisibleEcho extends EchoImpl
- {
- }
-
- public static class NoDefaultConstructorEcho extends EchoImpl
- {
- public NoDefaultConstructorEcho(String param)
- {
- }
- }
-
- public static class ProtectedConstructorEcho extends EchoImpl
- {
- protected ProtectedConstructorEcho()
- {
- }
- }
-}
diff --git a/src/test/java/org/apache/commons/proxy/factory/cglib/TestCglibProxyFactory.java b/src/test/java/org/apache/commons/proxy/factory/cglib/TestCglibProxyFactory.java
deleted file mode 100644
index 1bb2f57..0000000
--- a/src/test/java/org/apache/commons/proxy/factory/cglib/TestCglibProxyFactory.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.factory.cglib;
-
-import org.apache.commons.proxy.factory.AbstractSubclassingProxyFactoryTestCase;
-
-/**
- * @author James Carman
- * @since 1.0
- */
-public class TestCglibProxyFactory extends AbstractSubclassingProxyFactoryTestCase
-{
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public TestCglibProxyFactory()
- {
- super(new CglibProxyFactory());
- }
-}
diff --git a/src/test/java/org/apache/commons/proxy/factory/javassist/TestJavassistProxyFactory.java b/src/test/java/org/apache/commons/proxy/factory/javassist/TestJavassistProxyFactory.java
deleted file mode 100644
index 031221f..0000000
--- a/src/test/java/org/apache/commons/proxy/factory/javassist/TestJavassistProxyFactory.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.factory.javassist;
-
-import org.apache.commons.proxy.factory.AbstractSubclassingProxyFactoryTestCase;
-
-/**
- * @author James Carman
- * @since 1.0
- */
-public class TestJavassistProxyFactory extends AbstractSubclassingProxyFactoryTestCase
-{
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public TestJavassistProxyFactory()
- {
- super(new JavassistProxyFactory());
- }
-}
diff --git a/src/test/java/org/apache/commons/proxy/factory/util/TestMethodSignature.java b/src/test/java/org/apache/commons/proxy/factory/util/TestMethodSignature.java
deleted file mode 100644
index 30c5ea4..0000000
--- a/src/test/java/org/apache/commons/proxy/factory/util/TestMethodSignature.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.factory.util;
-
-import junit.framework.TestCase;
-import org.apache.commons.proxy.util.DuplicateEcho;
-import org.apache.commons.proxy.util.Echo;
-
-public class TestMethodSignature extends TestCase
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public void testEquals() throws Exception
- {
- final MethodSignature sig = new MethodSignature(Echo.class.getMethod("echoBack", new Class[] {String.class}));
- assertTrue(sig.equals(sig));
- assertFalse(sig.equals("echoBack"));
- assertEquals(sig, new MethodSignature(Echo.class.getMethod("echoBack", new Class[] {String.class})));
- assertEquals(sig, new MethodSignature(DuplicateEcho.class.getMethod("echoBack", new Class[] {String.class})));
- assertFalse(sig.equals(new MethodSignature(Echo.class.getMethod("echoBack", new Class[] {String.class, String.class}))));
- assertFalse(sig.equals(new MethodSignature(Echo.class.getMethod("echo", new Class[] {}))));
- }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/commons/proxy/interceptor/TestExecutorInterceptor.java b/src/test/java/org/apache/commons/proxy/interceptor/TestExecutorInterceptor.java
deleted file mode 100644
index f927fe0..0000000
--- a/src/test/java/org/apache/commons/proxy/interceptor/TestExecutorInterceptor.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.interceptor;
-
-import EDU.oswego.cs.dl.util.concurrent.CountDown;
-import EDU.oswego.cs.dl.util.concurrent.Executor;
-import junit.framework.TestCase;
-import org.apache.commons.proxy.factory.cglib.CglibProxyFactory;
-import org.apache.commons.proxy.util.Echo;
-import org.apache.commons.proxy.util.EchoImpl;
-
-public class TestExecutorInterceptor extends TestCase
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public void testMethodThrowsException()
- {
- final ExceptionEcho impl = new ExceptionEcho();
- final OneShotExecutor executor = new OneShotExecutor();
- final Echo proxy = ( Echo ) new CglibProxyFactory()
- .createInterceptorProxy(impl, new ExecutorInterceptor(executor), new Class[] {Echo.class});
- proxy.echo();
- }
-
- public void testNonVoidMethod() throws Exception
- {
- final ExecutedEcho impl = new ExecutedEcho();
- final OneShotExecutor executor = new OneShotExecutor();
- final Echo proxy = ( Echo ) new CglibProxyFactory()
- .createInterceptorProxy(impl, new ExecutorInterceptor(executor), new Class[] {Echo.class});
- try
- {
- proxy.echoBack("hello");
- fail();
- }
- catch( IllegalArgumentException e )
- {
- }
- }
-
- public void testVoidMethod() throws Exception
- {
- final ExecutedEcho impl = new ExecutedEcho();
- final OneShotExecutor executor = new OneShotExecutor();
- final Echo proxy = ( Echo ) new CglibProxyFactory()
- .createInterceptorProxy(impl, new ExecutorInterceptor(executor), new Class[] {Echo.class});
- proxy.echo();
- executor.getLatch().acquire();
- assertEquals(executor.getThread(), impl.getExecutionThread());
- }
-
-//**********************************************************************************************************************
-// Inner Classes
-//**********************************************************************************************************************
-
-//
-// Inner Classes
-//
- public static class ExceptionEcho extends EchoImpl
- {
- public void echo()
- {
- throw new RuntimeException("Oops!");
- }
- }
-
- public static class ExecutedEcho extends EchoImpl
- {
- private Thread executionThread;
-
- public void echo()
- {
- executionThread = Thread.currentThread();
- }
-
- public Thread getExecutionThread()
- {
- return executionThread;
- }
- }
-
- private static class OneShotExecutor implements Executor
- {
- private Thread thread;
- private CountDown latch = new CountDown(1);
-
- public void execute( final Runnable command )
- {
- thread = new Thread(new Runnable()
- {
- public void run()
- {
- try
- {
- command.run();
- }
- finally
- {
- latch.release();
- }
- }
- });
- thread.start();
- }
-
- public Thread getThread()
- {
- return thread;
- }
-
- public CountDown getLatch()
- {
- return latch;
- }
- }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/commons/proxy/interceptor/TestFilteredInterceptor.java b/src/test/java/org/apache/commons/proxy/interceptor/TestFilteredInterceptor.java
deleted file mode 100644
index 403d19a..0000000
--- a/src/test/java/org/apache/commons/proxy/interceptor/TestFilteredInterceptor.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.interceptor;
-
-import org.apache.commons.proxy.Interceptor;
-import org.apache.commons.proxy.factory.cglib.CglibProxyFactory;
-import org.apache.commons.proxy.interceptor.filter.SimpleFilter;
-import org.apache.commons.proxy.util.AbstractTestCase;
-import org.apache.commons.proxy.util.Echo;
-import org.apache.commons.proxy.util.EchoImpl;
-import org.apache.commons.proxy.util.SuffixInterceptor;
-
-/**
- * @author James Carman
- * @since 1.0
- */
-public class TestFilteredInterceptor extends AbstractTestCase
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public void testSerialization()
- {
- assertSerializable(new FilteredInterceptor(new SuffixInterceptor("a"), new SimpleFilter(new String[] {"echoBack"})));
- }
-
- public void testFilterAccepts()
- {
- 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 InterceptorChain(new Interceptor[] {new FilteredInterceptor(new SuffixInterceptor("a"), new SimpleFilter())}).createProxyProvider(new CglibProxyFactory(), new EchoImpl()).getObject();
- assertEquals("message", echo.echoBack("message"));
- }
-}
diff --git a/src/test/java/org/apache/commons/proxy/interceptor/TestInterceptorChain.java b/src/test/java/org/apache/commons/proxy/interceptor/TestInterceptorChain.java
deleted file mode 100644
index daea4db..0000000
--- a/src/test/java/org/apache/commons/proxy/interceptor/TestInterceptorChain.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.interceptor;
-
-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.EchoImpl;
-import org.apache.commons.proxy.util.SuffixInterceptor;
-import org.apache.commons.proxy.util.AbstractTestCase;
-
-/**
- * @author James Carman
- * @since 1.0
- */
-public class TestInterceptorChain extends AbstractTestCase
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public void testSerializable()
- {
- Echo echo = ( Echo ) new InterceptorChain(new Interceptor[] {new SuffixInterceptor("a"), new SuffixInterceptor("b")}).createProxyProvider(new CglibProxyFactory(), new EchoImpl(), new Class[] {Echo.class}).getObject();
- assertSerializable(echo);
- }
-
- public void testWithMultipleInterceptors()
- {
- 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"));
- }
-
- public void testWithSingleInterceptor()
- {
- 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"));
- }
-}
-
diff --git a/src/test/java/org/apache/commons/proxy/interceptor/TestMethodInterceptorAdapter.java b/src/test/java/org/apache/commons/proxy/interceptor/TestMethodInterceptorAdapter.java
deleted file mode 100644
index 108d376..0000000
--- a/src/test/java/org/apache/commons/proxy/interceptor/TestMethodInterceptorAdapter.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.interceptor;
-
-import org.aopalliance.intercept.MethodInterceptor;
-import org.aopalliance.intercept.MethodInvocation;
-import org.apache.commons.proxy.factory.javassist.JavassistProxyFactory;
-import org.apache.commons.proxy.util.AbstractTestCase;
-import org.apache.commons.proxy.util.Echo;
-import org.apache.commons.proxy.util.EchoImpl;
-
-import java.io.Serializable;
-
-public class TestMethodInterceptorAdapter extends AbstractTestCase
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public void testSerialization()
- {
- final Echo proxy = ( Echo ) new JavassistProxyFactory().createInterceptorProxy(new EchoImpl(),
- new MethodInterceptorAdapter(new SuffixMethodInterceptor(
- " suffix")),
- new Class[] {Echo.class});
- assertSerializable(proxy);
- }
-
- public void testMethodInterception()
- {
- final Echo proxy = ( Echo ) new JavassistProxyFactory().createInterceptorProxy(new EchoImpl(),
- new MethodInterceptorAdapter(new SuffixMethodInterceptor(
- " suffix")),
- new Class[] {Echo.class});
- assertEquals("message suffix", proxy.echoBack("message"));
- }
-
- public void testMethodInvocationImplementation() throws Exception
- {
- final InterceptorTester tester = new InterceptorTester();
- final EchoImpl target = new EchoImpl();
- 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);
- assertEquals(Echo.class.getMethod("echo", new Class[] {}), tester.invocation.getMethod());
- assertEquals(Echo.class.getMethod("echo", new Class[] {}), tester.invocation.getStaticPart());
- assertEquals(target, tester.invocation.getThis());
- proxy.echoBack("Hello");
- assertNotNull(tester.invocation.getArguments());
- assertEquals(1, tester.invocation.getArguments().length);
- assertEquals("Hello", tester.invocation.getArguments()[0]);
- assertEquals(Echo.class.getMethod("echoBack", new Class[] {String.class}), tester.invocation.getMethod());
- assertEquals(Echo.class.getMethod("echoBack", new Class[] {String.class}), tester.invocation.getStaticPart());
- proxy.echoBack("Hello", "World");
- assertNotNull(tester.invocation.getArguments());
- assertEquals(2, tester.invocation.getArguments().length);
- assertEquals("Hello", tester.invocation.getArguments()[0]);
- assertEquals("World", tester.invocation.getArguments()[1]);
- assertEquals(Echo.class.getMethod("echoBack", new Class[] {String.class, String.class}), tester.invocation.getMethod());
- assertEquals(Echo.class.getMethod("echoBack", new Class[] {String.class, String.class}), tester.invocation.getStaticPart());
- }
-
-//**********************************************************************************************************************
-// Inner Classes
-//**********************************************************************************************************************
-
- private static class InterceptorTester implements MethodInterceptor
- {
- private MethodInvocation invocation;
-
- public Object invoke( MethodInvocation methodInvocation ) throws Throwable
- {
- this.invocation = methodInvocation;
- return methodInvocation.proceed();
- }
- }
-
- private static class SuffixMethodInterceptor implements MethodInterceptor, Serializable
- {
- private final String suffix;
-
- public SuffixMethodInterceptor( String suffix )
- {
- this.suffix = suffix;
- }
-
- public Object invoke( MethodInvocation methodInvocation ) throws Throwable
- {
- return methodInvocation.proceed() + suffix;
- }
- }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/commons/proxy/interceptor/TestSerializingInterceptor.java b/src/test/java/org/apache/commons/proxy/interceptor/TestSerializingInterceptor.java
deleted file mode 100644
index cb29b37..0000000
--- a/src/test/java/org/apache/commons/proxy/interceptor/TestSerializingInterceptor.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.interceptor;
-
-import org.apache.commons.proxy.ProxyFactory;
-import org.apache.commons.proxy.util.AbstractTestCase;
-
-import java.io.ByteArrayOutputStream;
-
-public class TestSerializingInterceptor extends AbstractTestCase
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public void testSerialization()
- {
- assertSerializable(new SerializingInterceptor());
- }
-
- public void testWithInvalidParameterType()
- {
- try
- {
- final ObjectEchoImpl target = new ObjectEchoImpl();
- ObjectEcho echo =
- ( ObjectEcho ) new ProxyFactory().createInterceptorProxy(target,
- new SerializingInterceptor(),
- new Class[] {ObjectEcho.class});
- final Object originalParameter = new ByteArrayOutputStream();
- echo.echoBack(originalParameter);
- fail("Should not be able to call method with non-serializable parameter type.");
- }
- catch( RuntimeException e )
- {
- }
- }
-
- public void testWithSerializableParametersAndReturn()
- {
- final ObjectEchoImpl target = new ObjectEchoImpl();
- ObjectEcho echo =
- ( ObjectEcho ) new ProxyFactory().createInterceptorProxy(target,
- new SerializingInterceptor(),
- new Class[] {ObjectEcho.class});
- final Object originalParameter = "Hello, World!";
- final Object returnValue = echo.echoBack(originalParameter);
- assertNotSame(originalParameter, target.parameter);
- assertNotSame(originalParameter, returnValue);
- assertNotSame(returnValue, target.parameter);
- }
-
-//**********************************************************************************************************************
-// Inner Classes
-//**********************************************************************************************************************
-
- public static interface ObjectEcho
- {
- public Object echoBack( Object object );
- }
-
- public static class ObjectEchoImpl implements ObjectEcho
- {
- private Object parameter;
-
- public Object echoBack( Object object )
- {
- this.parameter = object;
- return object;
- }
- }
-}
diff --git a/src/test/java/org/apache/commons/proxy/interceptor/filter/TestPatternFilter.java b/src/test/java/org/apache/commons/proxy/interceptor/filter/TestPatternFilter.java
deleted file mode 100644
index 165abbe..0000000
--- a/src/test/java/org/apache/commons/proxy/interceptor/filter/TestPatternFilter.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.interceptor.filter;
-
-import junit.framework.TestCase;
-import org.apache.commons.proxy.interceptor.MethodFilter;
-
-import java.util.Date;
-
-/**
- * @author James Carman
- * @since 1.0
- */
-public class TestPatternFilter extends TestCase
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public void testAccepts() throws Exception
- {
- 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[] {})));
- }
-}
diff --git a/src/test/java/org/apache/commons/proxy/interceptor/filter/TestReturnTypeFilter.java b/src/test/java/org/apache/commons/proxy/interceptor/filter/TestReturnTypeFilter.java
deleted file mode 100644
index 6ab7862..0000000
--- a/src/test/java/org/apache/commons/proxy/interceptor/filter/TestReturnTypeFilter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.interceptor.filter;
-
-import junit.framework.TestCase;
-
-public class TestReturnTypeFilter extends TestCase
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public void testAcceptsMethod() throws Exception
- {
- final ReturnTypeFilter filter = new ReturnTypeFilter(new Class[] {String.class, Integer.TYPE});
- assertTrue(filter.accepts(Object.class.getMethod("toString", new Class[] {})));
- assertTrue(filter.accepts(Object.class.getMethod("hashCode", new Class[] {})));
- assertFalse(filter.accepts(Object.class.getMethod("equals", new Class[] {Object.class})));
- }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/commons/proxy/interceptor/filter/TestSimpleFilter.java b/src/test/java/org/apache/commons/proxy/interceptor/filter/TestSimpleFilter.java
deleted file mode 100644
index 366393d..0000000
--- a/src/test/java/org/apache/commons/proxy/interceptor/filter/TestSimpleFilter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.interceptor.filter;
-
-import junit.framework.TestCase;
-import org.apache.commons.proxy.util.Echo;
-import org.apache.commons.proxy.util.EchoImpl;
-
-/**
- * @author James Carman
- * @since 1.0
- */
-public class TestSimpleFilter extends TestCase
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public void testAccepts() throws Exception
- {
- 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[] {})));
- }
-}
diff --git a/src/test/java/org/apache/commons/proxy/invoker/TestDuckTypingInvoker.java b/src/test/java/org/apache/commons/proxy/invoker/TestDuckTypingInvoker.java
deleted file mode 100644
index 353e62d..0000000
--- a/src/test/java/org/apache/commons/proxy/invoker/TestDuckTypingInvoker.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.commons.proxy.ObjectProvider;
-import org.apache.commons.proxy.ProxyFactory;
-import org.apache.commons.proxy.provider.ConstantProvider;
-import org.apache.commons.proxy.util.AbstractTestCase;
-
-import java.io.Serializable;
-
-/**
- *
- */
-public class TestDuckTypingInvoker extends AbstractTestCase
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public void testExactSignatureMatch()
- {
- final ObjectProvider targetProvider = new ConstantProvider(new LegacyDuck());
- final DuckTypingInvoker invoker = new DuckTypingInvoker(targetProvider);
- final Duck duck = ( Duck ) new ProxyFactory().createInvokerProxy(invoker, new Class[] {Duck.class});
- assertEquals("Quack!", duck.sayQuack());
- }
-
- public void testMismatchingParameterType()
- {
- final ObjectProvider targetProvider = new ConstantProvider(new LegacyDuck());
- final DuckTypingInvoker invoker = new DuckTypingInvoker(targetProvider);
- final ParameterizedDuck parameterizedDuck = ( ParameterizedDuck ) new ProxyFactory()
- .createInvokerProxy(invoker, new Class[] {ParameterizedDuck.class});
- try
- {
- parameterizedDuck.sayQuack("Elmer");
- fail("No matching method should be found.");
- }
- catch( UnsupportedOperationException e )
- {
- // Do nothing, expected behavior!
- }
- }
-
- public void testMismatchingReturnType()
- {
- final ObjectProvider targetProvider = new ConstantProvider(new LegacyDuck());
- final DuckTypingInvoker invoker = new DuckTypingInvoker(targetProvider);
- final VoidReturnDuck voidDuck = ( VoidReturnDuck ) new ProxyFactory().createInvokerProxy(invoker, new Class[] {
- VoidReturnDuck.class});
- try
- {
- voidDuck.sayQuack();
- fail("No matching method should be found.");
- }
- catch( UnsupportedOperationException e )
- {
- // Do nothing, expected behavior!
- }
- }
-
- public void testNoMatchingMethod()
- {
- final ObjectProvider targetProvider = new ConstantProvider(new LegacyDuck());
- final DuckTypingInvoker invoker = new DuckTypingInvoker(targetProvider);
- final Goose goose = ( Goose ) new ProxyFactory().createInvokerProxy(invoker, new Class[] {Goose.class});
- try
- {
- goose.sayHonk();
- fail("No matching method should be found.");
- }
- catch( UnsupportedOperationException e )
- {
- // Do nothing, expected behavior!
- }
- }
-
- public void testSerialization()
- {
- final ObjectProvider targetProvider = new ConstantProvider(new LegacyDuck());
- final DuckTypingInvoker invoker = new DuckTypingInvoker(targetProvider);
- assertSerializable(invoker);
- }
-
- public void testTargetHasCompatibleReturnType()
- {
- final ObjectProvider targetProvider = new ConstantProvider(new LegacyDuck());
- final DuckTypingInvoker invoker = new DuckTypingInvoker(targetProvider);
- final SerializableDuck duck = ( SerializableDuck ) new ProxyFactory().createInvokerProxy(invoker, new Class[] {
- SerializableDuck.class});
- assertEquals("Quack!", duck.sayQuack());
- }
-
-//**********************************************************************************************************************
-// Inner Classes
-//**********************************************************************************************************************
-
- public interface Duck
- {
- public String sayQuack();
- }
-
- public interface Goose
- {
- public void sayHonk();
- }
-
- public static class LegacyDuck implements Serializable
- {
- public String sayQuack()
- {
- return "Quack!";
- }
- }
-
- public interface ParameterizedDuck
- {
- public String sayQuack( String recipient );
- }
-
- public interface SerializableDuck
- {
- public Serializable sayQuack();
- }
-
- public interface VoidReturnDuck
- {
- public void sayQuack();
- }
-}
diff --git a/src/test/java/org/apache/commons/proxy/invoker/TestInvocationHandlerAdapter.java b/src/test/java/org/apache/commons/proxy/invoker/TestInvocationHandlerAdapter.java
deleted file mode 100644
index ebd337c..0000000
--- a/src/test/java/org/apache/commons/proxy/invoker/TestInvocationHandlerAdapter.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.commons.proxy.factory.javassist.JavassistProxyFactory;
-import org.apache.commons.proxy.util.AbstractTestCase;
-import org.apache.commons.proxy.util.Echo;
-
-import java.io.Serializable;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-
-public class TestInvocationHandlerAdapter extends AbstractTestCase
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public void testSerialization()
- {
- assertSerializable( new InvocationHandlerAdapter( new InvocationHandlerTester() ) );
- }
-
- public void testMethodInvocation() throws Exception
- {
- InvocationHandlerTester tester = new InvocationHandlerTester();
- 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);
- assertNotNull(tester.arguments);
- assertEquals(1, tester.arguments.length);
- assertEquals("hello", tester.arguments[0]);
- }
-
-//**********************************************************************************************************************
-// Inner Classes
-//**********************************************************************************************************************
-
- private static class InvocationHandlerTester implements InvocationHandler, Serializable
- {
- private Object proxy;
- private Method method;
- private Object[] arguments;
-
- public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable
- {
- this.proxy = proxy;
- this.method = method;
- this.arguments = args;
- return null;
- }
- }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/commons/proxy/invoker/TestNullInvoker.java b/src/test/java/org/apache/commons/proxy/invoker/TestNullInvoker.java
deleted file mode 100644
index 0b9c6f9..0000000
--- a/src/test/java/org/apache/commons/proxy/invoker/TestNullInvoker.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.commons.proxy.ProxyUtils;
-import org.apache.commons.proxy.factory.cglib.CglibProxyFactory;
-import org.apache.commons.proxy.util.AbstractTestCase;
-
-public class TestNullInvoker extends AbstractTestCase
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- 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 void testSerialization()
- {
- assertSerializable(new NullInvoker());
- }
-
-//**********************************************************************************************************************
-// Inner Classes
-//**********************************************************************************************************************
-
- 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
diff --git a/src/test/java/org/apache/commons/proxy/invoker/TestXmlRpcInvoker.java b/src/test/java/org/apache/commons/proxy/invoker/TestXmlRpcInvoker.java
deleted file mode 100644
index 5a2cc56..0000000
--- a/src/test/java/org/apache/commons/proxy/invoker/TestXmlRpcInvoker.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.InvokerException;
-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
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private static WebServer server;
- private static XmlRpcClient client;
-
-//**********************************************************************************************************************
-// Static Methods
-//**********************************************************************************************************************
-
- 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();
- }
- };
- }
-
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- 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( InvokerException 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
diff --git a/src/test/java/org/apache/commons/proxy/invoker/recorder/TestInvocationRecorder.java b/src/test/java/org/apache/commons/proxy/invoker/recorder/TestInvocationRecorder.java
deleted file mode 100644
index 47b82df..0000000
--- a/src/test/java/org/apache/commons/proxy/invoker/recorder/TestInvocationRecorder.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.recorder;
-
-import org.apache.commons.proxy.factory.cglib.CglibProxyFactory;
-import org.apache.commons.proxy.util.AbstractTestCase;
-import org.apache.commons.proxy.ProxyUtils;
-
-import java.util.List;
-
-/**
- * @auothor James Carman
- */
-public class TestInvocationRecorder extends AbstractTestCase
-{
- public void testNestedMethodRecording() throws Exception
- {
- InvocationRecorder recorder = new InvocationRecorder(new CglibProxyFactory());
- Person personProxy = recorder.proxy(Person.class);
-
- assertEquals(null, personProxy.getAddress().getCity());
- List<RecordedInvocation> recordedInvocations = recorder.getRecordedInvocations();
- final RecordedInvocation getAddressInvocation = recordedInvocations.get(0);
- assertEquals(Person.class.getMethod("getAddress"), getAddressInvocation.getInvokedMethod());
- assertEquals(0, getAddressInvocation.getArguments().length);
- }
-
- public void testNestedGenericMethodRecording() throws Exception
- {
- InvocationRecorder recorder = new InvocationRecorder(new CglibProxyFactory());
- Person personProxy = recorder.proxy(Person.class);
- assertEquals(null, personProxy.getNicknames().get(0));
- List<RecordedInvocation> recordedInvocations = recorder.getRecordedInvocations();
-
- assertEquals(2, recordedInvocations.size());
-
- RecordedInvocation invocation = recordedInvocations.get(0);
- assertEquals(Person.class.getMethod("getNicknames"), invocation.getInvokedMethod());
- assertEquals(0, invocation.getArguments().length);
-
- invocation = recordedInvocations.get(1);
- assertEquals(List.class.getMethod("get", int.class), invocation.getInvokedMethod());
- assertEquals(1, invocation.getArguments().length);
- assertEquals(0, invocation.getArguments()[0] );
- }
-
- public void testProxyNonProxyableType()
- {
- InvocationRecorder recorder = new InvocationRecorder(new CglibProxyFactory());
- assertProxyIsNullValue(recorder, String.class);
- assertProxyIsNullValue(recorder, Long.TYPE);
- assertProxyIsNullValue(recorder, Integer.TYPE);
- assertProxyIsNullValue(recorder, Short.TYPE);
- assertProxyIsNullValue(recorder, Byte.TYPE);
-
- assertProxyIsNullValue(recorder, Double.TYPE);
- assertProxyIsNullValue(recorder, Float.TYPE);
-
- assertProxyIsNullValue(recorder, Boolean.TYPE);
-
- assertProxyIsNullValue(recorder, Character.TYPE);
- }
-
- private <T> void assertProxyIsNullValue( InvocationRecorder recorder, Class<T> type )
- {
- assertNullValue(recorder.proxy(type), type);
- }
-
- public <T> void assertNullValue( T value, Class<T> type )
- {
- assertEquals(value, ProxyUtils.nullValue(type));
- }
-
- public static interface Person
- {
- public Address getAddress();
-
- public List<String> getNicknames();
- }
-
- public static interface Address
- {
- public String getCity();
- }
-
-}
diff --git a/src/test/java/org/apache/commons/proxy/invoker/recorder/TestRecordedInvocation.java b/src/test/java/org/apache/commons/proxy/invoker/recorder/TestRecordedInvocation.java
deleted file mode 100644
index be3d75c..0000000
--- a/src/test/java/org/apache/commons/proxy/invoker/recorder/TestRecordedInvocation.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.recorder;
-
-import org.apache.commons.proxy.util.AbstractTestCase;
-
-/**
- * @auothor James Carman
- */
-public class TestRecordedInvocation extends AbstractTestCase
-{
- public void testToString() throws Exception
- {
- RecordedInvocation invocation = new RecordedInvocation(String.class.getMethod("toString"), new Object[0] );
- assertEquals("java.lang.String.toString()", invocation.toString());
-
- invocation = new RecordedInvocation(String.class.getMethod("substring", Integer.TYPE), new Object[] { 1 } );
- assertEquals("java.lang.String.substring(1)", invocation.toString());
-
- invocation = new RecordedInvocation(String.class.getMethod("substring", Integer.TYPE, Integer.TYPE), new Object[] { 1, 2 } );
- assertEquals("java.lang.String.substring(1, 2)", invocation.toString());
-
- invocation = new RecordedInvocation(String.class.getMethod("equals", Object.class), new Object[] { null } );
- assertEquals("java.lang.String.equals(<null>)", invocation.toString());
- }
-}
diff --git a/src/test/java/org/apache/commons/proxy/provider/CountingProvider.java b/src/test/java/org/apache/commons/proxy/provider/CountingProvider.java
deleted file mode 100644
index ae4d3e6..0000000
--- a/src/test/java/org/apache/commons/proxy/provider/CountingProvider.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.provider;
-
-import org.apache.commons.proxy.ObjectProvider;
-
-/**
- * @author James Carman
- * @since 1.0
- */
-public class CountingProvider extends ProviderDecorator
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private int count = 0;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public CountingProvider( ObjectProvider inner )
- {
- super(inner);
- }
-
-//**********************************************************************************************************************
-// ObjectProvider Implementation
-//**********************************************************************************************************************
-
-
- public synchronized Object getObject()
- {
- count++;
- return super.getObject();
- }
-
-//**********************************************************************************************************************
-// Getter/Setter Methods
-//**********************************************************************************************************************
-
- public synchronized int getCount()
- {
- return count;
- }
-}
diff --git a/src/test/java/org/apache/commons/proxy/provider/TestBeanProvider.java b/src/test/java/org/apache/commons/proxy/provider/TestBeanProvider.java
deleted file mode 100644
index 8973bfa..0000000
--- a/src/test/java/org/apache/commons/proxy/provider/TestBeanProvider.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.provider;
-
-import org.apache.commons.proxy.exception.ObjectProviderException;
-import org.apache.commons.proxy.util.AbstractTestCase;
-
-public class TestBeanProvider extends AbstractTestCase
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public void testAbstractBeanClass()
- {
- try
- {
- final BeanProvider p = new BeanProvider();
- p.setBeanClass(Number.class);
- p.getObject();
- fail();
- }
- catch( ObjectProviderException e )
- {
- }
- }
-
- public void testNonAccessibleConstructor()
- {
- try
- {
- new BeanProvider(MyBean.class).getObject();
- fail();
- }
- catch( ObjectProviderException e )
- {
- }
- }
-
- public void testSerialization()
- {
- assertSerializable(new BeanProvider(MyBean.class));
- }
-
- public void testWithNullBeanClass()
- {
- try
- {
- final BeanProvider p = new BeanProvider();
- p.getObject();
- fail();
- }
- catch( ObjectProviderException e )
- {
- }
- }
-
-//**********************************************************************************************************************
-// Inner Classes
-//**********************************************************************************************************************
-
- public static class MyBean
- {
- private MyBean()
- {
-
- }
- }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/commons/proxy/provider/TestCloningProvider.java b/src/test/java/org/apache/commons/proxy/provider/TestCloningProvider.java
deleted file mode 100644
index adac321..0000000
--- a/src/test/java/org/apache/commons/proxy/provider/TestCloningProvider.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.provider;
-
-import org.apache.commons.proxy.exception.ObjectProviderException;
-import org.apache.commons.proxy.util.AbstractTestCase;
-
-import java.util.Date;
-
-public class TestCloningProvider extends AbstractTestCase
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public void testSerialization()
- {
- assertSerializable(new CloningProvider(new Date()));
- }
-
- public void testValidCloneable()
- {
- final Date now = new Date();
- final CloningProvider provider = new CloningProvider(now);
- final Date clone1 = ( Date ) provider.getObject();
- assertEquals(now, clone1);
- assertNotSame(now, clone1);
- final Date clone2 = ( Date ) provider.getObject();
- assertEquals(now, clone2);
- assertNotSame(now, clone2);
- assertNotSame(clone2, clone1);
- }
-
- public void testWithExceptionThrown()
- {
- final CloningProvider provider = new CloningProvider(new ExceptionCloneable());
- try
- {
- provider.getObject();
- fail();
- }
- catch( ObjectProviderException e )
- {
- }
- }
-
- public void testWithInvalidCloneable()
- {
- final CloningProvider provider = new CloningProvider(new InvalidCloneable());
- try
- {
- provider.getObject();
- fail();
- }
- catch( ObjectProviderException e )
- {
- }
- }
-
- public void testWithPrivateCloneMethod()
- {
- final CloningProvider provider = new CloningProvider(new PrivateCloneable());
- try
- {
- provider.getObject();
- fail();
- }
- catch( ObjectProviderException e )
- {
- }
- }
-
-//**********************************************************************************************************************
-// Inner Classes
-//**********************************************************************************************************************
-
- public static class ExceptionCloneable implements Cloneable
- {
- public Object clone()
- {
- throw new RuntimeException("No clone for you!");
- }
- }
-
- public static class InvalidCloneable implements Cloneable
- {
- }
-
- public static class PrivateCloneable implements Cloneable
- {
- protected Object clone()
- {
- return this;
- }
- }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/commons/proxy/provider/TestConstantProvider.java b/src/test/java/org/apache/commons/proxy/provider/TestConstantProvider.java
deleted file mode 100644
index 8c4eee3..0000000
--- a/src/test/java/org/apache/commons/proxy/provider/TestConstantProvider.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.provider;
-
-import org.apache.commons.proxy.util.AbstractTestCase;
-
-/**
- * @since 1.0
- */
-public class TestConstantProvider extends AbstractTestCase
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public void testGetObject() throws Exception
- {
- final String s = "Hello, World!";
- final ConstantProvider provider = new ConstantProvider(s);
- assertSame(s, provider.getObject());
- }
-
- public void testSerialization()
- {
- assertSerializable(new ConstantProvider("Hello, World!"));
- }
-}
diff --git a/src/test/java/org/apache/commons/proxy/provider/TestNullProvider.java b/src/test/java/org/apache/commons/proxy/provider/TestNullProvider.java
deleted file mode 100644
index 12f59f5..0000000
--- a/src/test/java/org/apache/commons/proxy/provider/TestNullProvider.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.provider;
-
-import org.apache.commons.proxy.util.AbstractTestCase;
-
-/**
- * @author James Carman
- * @since 1.0
- */
-public class TestNullProvider extends AbstractTestCase
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public void testGetObject()
- {
- final NullProvider provider = new NullProvider();
- assertNull(provider.getObject());
- }
-
- public void testSerialization()
- {
- assertSerializable(new NullProvider());
- }
-}
diff --git a/src/test/java/org/apache/commons/proxy/provider/remoting/TestBurlapProvider.java b/src/test/java/org/apache/commons/proxy/provider/remoting/TestBurlapProvider.java
deleted file mode 100644
index f3dcc3a..0000000
--- a/src/test/java/org/apache/commons/proxy/provider/remoting/TestBurlapProvider.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.provider.remoting;
-
-import org.apache.commons.proxy.exception.ObjectProviderException;
-import org.apache.commons.proxy.util.AbstractTestCase;
-import org.apache.commons.proxy.util.Echo;
-
-public class TestBurlapProvider extends AbstractTestCase
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public void testSerialization()
- {
- final BurlapProvider p = new BurlapProvider();
- p.setServiceInterface(Echo.class);
- p.setUrl("a malformed URL");
- assertSerializable(p);
- }
-
- public void testWithMalformedUrl()
- {
- try
- {
- final BurlapProvider p = new BurlapProvider(Echo.class, "a malformed URL");
- p.getObject();
- fail();
- }
- catch( ObjectProviderException e )
- {
- }
- }
-
- public void testWithMalformedUrlBean()
- {
- try
- {
- final BurlapProvider p = new BurlapProvider();
- p.setServiceInterface(Echo.class);
- p.setUrl("a malformed URL");
- p.getObject();
- fail();
- }
- catch( ObjectProviderException e )
- {
- }
- }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/commons/proxy/util/AbstractEcho.java b/src/test/java/org/apache/commons/proxy/util/AbstractEcho.java
deleted file mode 100644
index 68459b0..0000000
--- a/src/test/java/org/apache/commons/proxy/util/AbstractEcho.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.util;
-
-import java.io.Serializable;
-
-/**
- * @author James Carman
- * @since 1.0
- */
-public abstract class AbstractEcho implements Echo, Serializable
-{
-//**********************************************************************************************************************
-// Echo Implementation
-//**********************************************************************************************************************
-
- public String echoBack( String message )
- {
- return message;
- }
-}
diff --git a/src/test/java/org/apache/commons/proxy/util/AbstractTestCase.java b/src/test/java/org/apache/commons/proxy/util/AbstractTestCase.java
deleted file mode 100644
index 54f79d3..0000000
--- a/src/test/java/org/apache/commons/proxy/util/AbstractTestCase.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.util;
-
-import junit.framework.TestCase;
-import org.apache.commons.lang.SerializationUtils;
-
-import java.io.Serializable;
-
-/**
- * @auothor James Carman
- * @since 1.1
- */
-public abstract class AbstractTestCase extends TestCase
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- protected void assertSerializable( Object o )
- {
- assertTrue(o instanceof Serializable);
- SerializationUtils.clone(( Serializable ) o);
- }
-}
diff --git a/src/test/java/org/apache/commons/proxy/util/DuplicateEcho.java b/src/test/java/org/apache/commons/proxy/util/DuplicateEcho.java
deleted file mode 100644
index f73551d..0000000
--- a/src/test/java/org/apache/commons/proxy/util/DuplicateEcho.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.util;
-
-/**
- * @author James Carman
- * @since 1.0
- */
-public interface DuplicateEcho
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public String echoBack( String message );
-}
diff --git a/src/test/java/org/apache/commons/proxy/util/Echo.java b/src/test/java/org/apache/commons/proxy/util/Echo.java
deleted file mode 100644
index 549fe29..0000000
--- a/src/test/java/org/apache/commons/proxy/util/Echo.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.util;
-
-import java.io.IOException;
-
-/**
- * @author James Carman
- * @since 1.0
- */
-public interface Echo
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public void echo();
-
- public String echoBack( String message );
-
- public String echoBack( String[] messages );
-
- public int echoBack( int i );
-
- public boolean echoBack( boolean b );
-
- public String echoBack( String message1, String message2 );
-
- public void illegalArgument();
-
- public void ioException() throws IOException;
-}
diff --git a/src/test/java/org/apache/commons/proxy/util/EchoImpl.java b/src/test/java/org/apache/commons/proxy/util/EchoImpl.java
deleted file mode 100644
index 10cd019..0000000
--- a/src/test/java/org/apache/commons/proxy/util/EchoImpl.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.util;
-
-import java.io.IOException;
-import java.io.Serializable;
-
-/**
- * @author James Carman
- * @since 1.0
- */
-public class EchoImpl extends AbstractEcho implements DuplicateEcho, Serializable
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private static final long serialVersionUID = -4844873352607521103L;
-
-//**********************************************************************************************************************
-// Echo Implementation
-//**********************************************************************************************************************
-
-
- public void echo()
- {
- }
-
- public boolean echoBack( boolean b )
- {
- return b;
- }
-
- public String echoBack( String[] messages )
- {
- final StringBuffer sb = new StringBuffer();
- for( int i = 0; i < messages.length; i++ )
- {
- String message = messages[i];
- sb.append(message);
- }
- return sb.toString();
- }
-
- public int echoBack( int i )
- {
- return i;
- }
-
- public String echoBack( String message1, String message2 )
- {
- return message1 + message2;
- }
-
- public void illegalArgument()
- {
- throw new IllegalArgumentException("dummy message");
- }
-
- public void ioException() throws IOException
- {
- throw new IOException("dummy message");
- }
-}
diff --git a/src/test/java/org/apache/commons/proxy/util/QuoteService.java b/src/test/java/org/apache/commons/proxy/util/QuoteService.java
deleted file mode 100644
index 82c37d7..0000000
--- a/src/test/java/org/apache/commons/proxy/util/QuoteService.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.util;
-
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-
-/**
- * @author James Carman
- * @since 1.0
- */
-public interface QuoteService extends Remote
-{
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
- public float getQuote( String symbol ) throws RemoteException;
-}
diff --git a/src/test/java/org/apache/commons/proxy/util/SuffixInterceptor.java b/src/test/java/org/apache/commons/proxy/util/SuffixInterceptor.java
deleted file mode 100644
index c98a6de..0000000
--- a/src/test/java/org/apache/commons/proxy/util/SuffixInterceptor.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.util;
-
-import org.apache.commons.proxy.Interceptor;
-import org.apache.commons.proxy.Invocation;
-
-/**
- * @author James Carman
- * @since 1.0
- */
-public class SuffixInterceptor implements Interceptor
-{
-//**********************************************************************************************************************
-// Fields
-//**********************************************************************************************************************
-
- private final String suffix;
-
-//**********************************************************************************************************************
-// Constructors
-//**********************************************************************************************************************
-
- public SuffixInterceptor( String suffix )
- {
- this.suffix = suffix;
- }
-
-//**********************************************************************************************************************
-// Interceptor Implementation
-//**********************************************************************************************************************
-
-
- public Object intercept( Invocation methodInvocation ) throws Throwable
- {
- return methodInvocation.proceed() + suffix;
- }
-}