commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r966001 - in /commons/proper/proxy/branches/version-2.0-work: cglib/src/main/java/org/apache/commons/proxy2/cglib/ javassist/src/main/java/org/apache/commons/proxy2/javassist/ jdk/src/main/java/org/apache/commons/proxy2/jdk/
Date Tue, 20 Jul 2010 20:49:28 GMT
Author: mbenson
Date: Tue Jul 20 20:49:28 2010
New Revision: 966001

URL: http://svn.apache.org/viewvc?rev=966001&view=rev
Log:
warnings/javadoc

Modified:
    commons/proper/proxy/branches/version-2.0-work/cglib/src/main/java/org/apache/commons/proxy2/cglib/CglibProxyFactory.java
    commons/proper/proxy/branches/version-2.0-work/javassist/src/main/java/org/apache/commons/proxy2/javassist/JavassistInvocation.java
    commons/proper/proxy/branches/version-2.0-work/javassist/src/main/java/org/apache/commons/proxy2/javassist/JavassistProxyFactory.java
    commons/proper/proxy/branches/version-2.0-work/javassist/src/main/java/org/apache/commons/proxy2/javassist/JavassistUtils.java
    commons/proper/proxy/branches/version-2.0-work/jdk/src/main/java/org/apache/commons/proxy2/jdk/JdkProxyFactory.java

Modified: commons/proper/proxy/branches/version-2.0-work/cglib/src/main/java/org/apache/commons/proxy2/cglib/CglibProxyFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/branches/version-2.0-work/cglib/src/main/java/org/apache/commons/proxy2/cglib/CglibProxyFactory.java?rev=966001&r1=966000&r2=966001&view=diff
==============================================================================
--- commons/proper/proxy/branches/version-2.0-work/cglib/src/main/java/org/apache/commons/proxy2/cglib/CglibProxyFactory.java
(original)
+++ commons/proper/proxy/branches/version-2.0-work/cglib/src/main/java/org/apache/commons/proxy2/cglib/CglibProxyFactory.java
Tue Jul 20 20:49:28 2010
@@ -33,8 +33,10 @@ import org.apache.commons.proxy2.impl.Ab
 
 import java.io.Serializable;
 import java.lang.reflect.Method;
-import java.util.ServiceLoader;
 
+/**
+ * Cglib-based {@link ProxyFactory} implementation.
+ */
 public class CglibProxyFactory extends AbstractSubclassingProxyFactory
 {
 //**********************************************************************************************************************
@@ -43,12 +45,16 @@ public class CglibProxyFactory extends A
 
     private static CallbackFilter callbackFilter = new CglibProxyFactoryCallbackFilter();
 
-//**********************************************************************************************************************
-// ProxyFactory Implementation
-//**********************************************************************************************************************
-
-    public Object createDelegatorProxy(ClassLoader classLoader, ObjectProvider targetProvider,
-                                       Class... proxyClasses)
+  //**********************************************************************************************************************
+ // ProxyFactory Implementation
+ //**********************************************************************************************************************
+
+    /**
+     * {@inheritDoc}
+     */
+    @SuppressWarnings("unchecked")
+    public <T> T createDelegatorProxy(ClassLoader classLoader, ObjectProvider<?>
targetProvider,
+                                       Class<?>... proxyClasses)
     {
         final Enhancer enhancer = new Enhancer();
         enhancer.setClassLoader(classLoader);
@@ -56,11 +62,15 @@ public class CglibProxyFactory extends A
         enhancer.setSuperclass(getSuperclass(proxyClasses));
         enhancer.setCallbackFilter(callbackFilter);
         enhancer.setCallbacks(new Callback[]{new ObjectProviderDispatcher(targetProvider),
new EqualsHandler(), new HashCodeHandler()});
-        return enhancer.create();
+        return (T) enhancer.create();
     }
 
-    public Object createInterceptorProxy(ClassLoader classLoader, Object target, Interceptor
interceptor,
-                                         Class... proxyClasses)
+    /**
+     * {@inheritDoc}
+     */
+    @SuppressWarnings("unchecked")
+    public <T> T createInterceptorProxy(ClassLoader classLoader, Object target, Interceptor
interceptor,
+                                         Class<?>... proxyClasses)
     {
         final Enhancer enhancer = new Enhancer();
         enhancer.setClassLoader(classLoader);
@@ -68,11 +78,15 @@ public class CglibProxyFactory extends A
         enhancer.setSuperclass(getSuperclass(proxyClasses));
         enhancer.setCallbackFilter(callbackFilter);
         enhancer.setCallbacks(new Callback[]{new InterceptorBridge(target, interceptor),
new EqualsHandler(), new HashCodeHandler()});
-        return enhancer.create();
+        return (T) enhancer.create();
     }
 
-    public Object createInvokerProxy(ClassLoader classLoader, Invoker invoker,
-                                     Class... proxyClasses)
+    /**
+     * {@inheritDoc}
+     */
+    @SuppressWarnings("unchecked")
+    public <T> T createInvokerProxy(ClassLoader classLoader, Invoker invoker,
+                                     Class<?>... proxyClasses)
     {
         final Enhancer enhancer = new Enhancer();
         enhancer.setClassLoader(classLoader);
@@ -80,7 +94,7 @@ public class CglibProxyFactory extends A
         enhancer.setSuperclass(getSuperclass(proxyClasses));
         enhancer.setCallbackFilter(callbackFilter);
         enhancer.setCallbacks(new Callback[]{new InvokerBridge(invoker), new EqualsHandler(),
new HashCodeHandler()});
-        return enhancer.create();
+        return (T) enhancer.create();
     }
 
 //**********************************************************************************************************************
@@ -108,6 +122,9 @@ public class CglibProxyFactory extends A
 
     private static class EqualsHandler implements MethodInterceptor, Serializable
     {
+        /** Serialization version */
+        private static final long serialVersionUID = 1L;
+
         public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy)
throws Throwable
         {
             return o == objects[0];
@@ -116,6 +133,9 @@ public class CglibProxyFactory extends A
 
     private static class HashCodeHandler implements MethodInterceptor, Serializable
     {
+        /** Serialization version */
+        private static final long serialVersionUID = 1L;
+
         public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy)
throws Throwable
         {
             return System.identityHashCode(o);
@@ -124,6 +144,9 @@ public class CglibProxyFactory extends A
 
     private static class InterceptorBridge implements net.sf.cglib.proxy.MethodInterceptor,
Serializable
     {
+        /** Serialization version */
+        private static final long serialVersionUID = 1L;
+
         private final Interceptor inner;
         private final Object target;
 
@@ -141,6 +164,9 @@ public class CglibProxyFactory extends A
 
     private static class InvokerBridge implements net.sf.cglib.proxy.InvocationHandler, Serializable
     {
+        /** Serialization version */
+        private static final long serialVersionUID = 1L;
+
         private final Invoker original;
 
         public InvokerBridge(Invoker original)
@@ -156,6 +182,9 @@ public class CglibProxyFactory extends A
 
     private static class MethodProxyInvocation implements Invocation, Serializable
     {
+        /** Serialization version */
+        private static final long serialVersionUID = 1L;
+
         private final MethodProxy methodProxy;
         private final Method method;
         private final Object[] args;
@@ -192,9 +221,12 @@ public class CglibProxyFactory extends A
 
     private static class ObjectProviderDispatcher implements Dispatcher, Serializable
     {
-        private final ObjectProvider delegateProvider;
+        /** Serialization version */
+        private static final long serialVersionUID = 1L;
+
+        private final ObjectProvider<?> delegateProvider;
 
-        public ObjectProviderDispatcher(ObjectProvider delegateProvider)
+        public ObjectProviderDispatcher(ObjectProvider<?> delegateProvider)
         {
             this.delegateProvider = delegateProvider;
         }

Modified: commons/proper/proxy/branches/version-2.0-work/javassist/src/main/java/org/apache/commons/proxy2/javassist/JavassistInvocation.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/branches/version-2.0-work/javassist/src/main/java/org/apache/commons/proxy2/javassist/JavassistInvocation.java?rev=966001&r1=966000&r2=966001&view=diff
==============================================================================
--- commons/proper/proxy/branches/version-2.0-work/javassist/src/main/java/org/apache/commons/proxy2/javassist/JavassistInvocation.java
(original)
+++ commons/proper/proxy/branches/version-2.0-work/javassist/src/main/java/org/apache/commons/proxy2/javassist/JavassistInvocation.java
Tue Jul 20 20:49:28 2010
@@ -44,16 +44,22 @@ public abstract class JavassistInvocatio
 // Fields
 //**********************************************************************************************************************
 
-    private static WeakHashMap loaderToClassCache = new WeakHashMap();
+    private static WeakHashMap<ClassLoader, Map<String, WeakReference<Class<?>>>>
loaderToClassCache = new WeakHashMap<ClassLoader, Map<String,WeakReference<Class<?>>>>();
+
+    /** The invoked method */
     protected final Method method;
+
+    /** The target object */
     protected final Object target;
+
+    /** The method arguments */
     protected final Object[] arguments;
 
 //**********************************************************************************************************************
 // Static Methods
 //**********************************************************************************************************************
 
-    private static String createCastExpression( Class type, String objectToCast )
+    private static String createCastExpression( Class<?> type, String objectToCast
)
     {
         if( !type.isPrimitive() )
         {
@@ -66,10 +72,10 @@ public abstract class JavassistInvocatio
         }
     }
 
-    private static Class createInvocationClass( ClassLoader classLoader, Method interfaceMethod
)
+    private static Class<?> createInvocationClass( ClassLoader classLoader, Method
interfaceMethod )
             throws CannotCompileException
     {
-        Class invocationClass;
+        Class<?> invocationClass;
         final CtClass ctClass = JavassistUtils.createClass(
                 getSimpleName(interfaceMethod.getDeclaringClass()) + "_" + interfaceMethod.getName()
+
                         "_invocation",
@@ -81,7 +87,7 @@ public abstract class JavassistInvocatio
         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 Class<?>[] argumentTypes = interfaceMethod.getParameterTypes();
         final StringBuffer proceedBody = new StringBuffer("{\n");
         if( !Void.TYPE.equals(interfaceMethod.getReturnType()) )
         {
@@ -104,7 +110,7 @@ public abstract class JavassistInvocatio
         proceedBody.append("(");
         for( int i = 0; i < argumentTypes.length; ++i )
         {
-            final Class argumentType = argumentTypes[i];
+            final Class<?> argumentType = argumentTypes[i];
             proceedBody.append(createCastExpression(argumentType, "arguments[" + i + "]"));
             if( i != argumentTypes.length - 1 )
             {
@@ -131,12 +137,12 @@ public abstract class JavassistInvocatio
         return invocationClass;
     }
 
-    private static Map getClassCache( ClassLoader classLoader )
+    private static Map<String, WeakReference<Class<?>>> getClassCache(
ClassLoader classLoader )
     {
-        Map cache = ( Map ) loaderToClassCache.get(classLoader);
+        Map<String, WeakReference<Class<?>>> cache = loaderToClassCache.get(classLoader);
         if( cache == null )
         {
-            cache = new HashMap();
+            cache = new HashMap<String, WeakReference<Class<?>>>();
             loaderToClassCache.put(classLoader, cache);
         }
         return cache;
@@ -150,35 +156,35 @@ public abstract class JavassistInvocatio
      * @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,
+    synchronized static Class<?> getMethodInvocationClass( ClassLoader classLoader,
                                                         Method interfaceMethod )
             throws CannotCompileException
     {
-        final Map classCache = getClassCache(classLoader);
+        final Map<String, WeakReference<Class<?>>> classCache = getClassCache(classLoader);
         final String key = toClassCacheKey(interfaceMethod);
-        final WeakReference invocationClassRef = ( WeakReference ) classCache.get(key);
-        Class invocationClass;
+        final WeakReference<Class<?>> invocationClassRef = classCache.get(key);
+        Class<?> invocationClass;
         if( invocationClassRef == null )
         {
             invocationClass = createInvocationClass(classLoader, interfaceMethod);
-            classCache.put(key, new WeakReference(invocationClass));
+            classCache.put(key, new WeakReference<Class<?>>(invocationClass));
         }
         else
         {
             synchronized( invocationClassRef )
             {
-                invocationClass = ( Class ) invocationClassRef.get();
+                invocationClass = invocationClassRef.get();
                 if( invocationClass == null )
                 {
                     invocationClass = createInvocationClass(classLoader, interfaceMethod);
-                    classCache.put(key, new WeakReference(invocationClass));
+                    classCache.put(key, new WeakReference<Class<?>>(invocationClass));
                 }
             }
         }
         return invocationClass;
     }
 
-    private static String getSimpleName( Class c )
+    private static String getSimpleName( Class<?> c )
     {
         final String name = c.getName();
         final int ndx = name.lastIndexOf('.');

Modified: commons/proper/proxy/branches/version-2.0-work/javassist/src/main/java/org/apache/commons/proxy2/javassist/JavassistProxyFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/branches/version-2.0-work/javassist/src/main/java/org/apache/commons/proxy2/javassist/JavassistProxyFactory.java?rev=966001&r1=966000&r2=966001&view=diff
==============================================================================
--- commons/proper/proxy/branches/version-2.0-work/javassist/src/main/java/org/apache/commons/proxy2/javassist/JavassistProxyFactory.java
(original)
+++ commons/proper/proxy/branches/version-2.0-work/javassist/src/main/java/org/apache/commons/proxy2/javassist/JavassistProxyFactory.java
Tue Jul 20 20:49:28 2010
@@ -61,16 +61,20 @@ public class JavassistProxyFactory exten
         proxyClass.addMethod(method);
     }
 
-//**********************************************************************************************************************
-// Other Methods
-//**********************************************************************************************************************
-
-    public Object createDelegatorProxy(ClassLoader classLoader, ObjectProvider targetProvider,
-                                       Class... proxyClasses)
+    //**********************************************************************************************************************
+    // ProxyFactory Implementation
+    //**********************************************************************************************************************
+
+    /**
+     * {@inheritDoc}
+     */
+    @SuppressWarnings("unchecked")
+    public <T> T createDelegatorProxy(ClassLoader classLoader, ObjectProvider<?>
targetProvider,
+                                       Class<?>... proxyClasses)
     {
         try
         {
-            final Class clazz = delegatingProxyClassCache.getProxyClass(classLoader, proxyClasses);
+            final Class<? extends T> clazz = (Class<? extends T>) delegatingProxyClassCache.getProxyClass(classLoader,
proxyClasses);
             return clazz.getConstructor(ObjectProvider.class)
                     .newInstance(targetProvider);
         }
@@ -80,12 +84,16 @@ public class JavassistProxyFactory exten
         }
     }
 
-    public Object createInterceptorProxy(ClassLoader classLoader, Object target, Interceptor
interceptor,
-                                         Class... proxyClasses)
+    /**
+     * {@inheritDoc}
+     */
+    @SuppressWarnings("unchecked")
+    public <T> T createInterceptorProxy(ClassLoader classLoader, Object target, Interceptor
interceptor,
+                                         Class<?>... proxyClasses)
     {
         try
         {
-            final Class clazz = interceptorProxyClassCache.getProxyClass(classLoader, proxyClasses);
+            final Class<? extends T> clazz = (Class<? extends T>) interceptorProxyClassCache.getProxyClass(classLoader,
proxyClasses);
             return clazz.getConstructor(Object.class, Interceptor.class)
                     .newInstance(target, interceptor);
         }
@@ -95,12 +103,16 @@ public class JavassistProxyFactory exten
         }
     }
 
-    public Object createInvokerProxy(ClassLoader classLoader, Invoker invoker,
-                                     Class... proxyClasses)
+    /**
+     * {@inheritDoc}
+     */
+    @SuppressWarnings("unchecked")
+    public <T> T createInvokerProxy(ClassLoader classLoader, Invoker invoker,
+                                     Class<?>... proxyClasses)
     {
         try
         {
-            final Class clazz = invocationHandlerProxyClassCache.getProxyClass(classLoader,
proxyClasses);
+            final Class<? extends T> clazz = (Class<? extends T>) invocationHandlerProxyClassCache.getProxyClass(classLoader,
proxyClasses);
             return clazz.getConstructor(Invoker.class)
                     .newInstance(invoker);
         }
@@ -116,7 +128,7 @@ public class JavassistProxyFactory exten
 
     private static class DelegatingProxyClassGenerator extends AbstractProxyClassGenerator
     {
-        public Class generateProxyClass(ClassLoader classLoader, Class[] proxyClasses)
+        public Class<?> generateProxyClass(ClassLoader classLoader, Class<?>[]
proxyClasses)
         {
             try
             {
@@ -158,7 +170,7 @@ public class JavassistProxyFactory exten
 
     private static class InterceptorProxyClassGenerator extends AbstractProxyClassGenerator
     {
-        public Class generateProxyClass(ClassLoader classLoader, Class[] proxyClasses)
+        public Class<?> generateProxyClass(ClassLoader classLoader, Class<?>[]
proxyClasses)
         {
             try
             {
@@ -186,7 +198,7 @@ public class JavassistProxyFactory exten
                                 methods[i].getName(),
                                 JavassistUtils.resolve(methods[i].getParameterTypes()),
                                 proxyClass);
-                        final Class invocationClass = JavassistInvocation
+                        final Class<?> invocationClass = JavassistInvocation
                                 .getMethodInvocationClass(classLoader, methods[i]);
 
                         final String body = "{\n\t return ( $r ) interceptor.intercept( new
" + invocationClass.getName() +
@@ -229,7 +241,7 @@ public class JavassistProxyFactory exten
 
     private static class InvokerProxyClassGenerator extends AbstractProxyClassGenerator
     {
-        public Class generateProxyClass(ClassLoader classLoader, Class[] proxyClasses)
+        public Class<?> generateProxyClass(ClassLoader classLoader, Class<?>[]
proxyClasses)
         {
             try
             {

Modified: commons/proper/proxy/branches/version-2.0-work/javassist/src/main/java/org/apache/commons/proxy2/javassist/JavassistUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/branches/version-2.0-work/javassist/src/main/java/org/apache/commons/proxy2/javassist/JavassistUtils.java?rev=966001&r1=966000&r2=966001&view=diff
==============================================================================
--- commons/proper/proxy/branches/version-2.0-work/javassist/src/main/java/org/apache/commons/proxy2/javassist/JavassistUtils.java
(original)
+++ commons/proper/proxy/branches/version-2.0-work/javassist/src/main/java/org/apache/commons/proxy2/javassist/JavassistUtils.java
Tue Jul 20 20:49:28 2010
@@ -45,7 +45,7 @@ class JavassistUtils
     private static int classNumber = 0;
     private static final ClassPool classPool = new ClassPool();
 
-    private static final Set classLoaders = new HashSet();
+    private static final Set<ClassLoader> classLoaders = new HashSet<ClassLoader>();
 
 //**********************************************************************************************************************
 // Static Methods
@@ -64,7 +64,7 @@ class JavassistUtils
      * @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
)
+    public static void addField( Class<?> fieldType, String fieldName, CtClass enclosingClass
)
             throws CannotCompileException
     {
         enclosingClass.addField(new CtField(resolve(fieldType), fieldName, enclosingClass));
@@ -76,11 +76,11 @@ class JavassistUtils
      * @param ctClass      the {@link CtClass}
      * @param proxyClasses the interfaces
      */
-    public static void addInterfaces( CtClass ctClass, Class[] proxyClasses )
+    public static void addInterfaces( CtClass ctClass, Class<?>[] proxyClasses )
     {
         for( int i = 0; i < proxyClasses.length; i++ )
         {
-            Class proxyInterface = proxyClasses[i];
+            Class<?> proxyInterface = proxyClasses[i];
             ctClass.addInterface(resolve(proxyInterface));
         }
     }
@@ -91,7 +91,7 @@ class JavassistUtils
      * @param superclass the superclass
      * @return the new derived {@link CtClass}
      */
-    public static CtClass createClass( Class superclass )
+    public static CtClass createClass( Class<?> superclass )
     {
         return createClass(DEFAULT_BASE_NAME, superclass);
     }
@@ -103,7 +103,7 @@ class JavassistUtils
      * @param superclass the superclass
      * @return the new derived {@link CtClass}
      */
-    public synchronized static CtClass createClass( String baseName, Class superclass )
+    public synchronized static CtClass createClass( String baseName, Class<?> superclass
)
     {
         return classPool.makeClass(baseName + "_" + classNumber++, resolve(superclass));
     }
@@ -114,7 +114,7 @@ class JavassistUtils
      * @param clazz the Java {@link Class}
      * @return the {@link CtClass}
      */
-    public static CtClass resolve( Class clazz )
+    public static CtClass resolve( Class<?> clazz )
     {
         synchronized( classLoaders )
         {
@@ -142,7 +142,7 @@ class JavassistUtils
      * @param classes the Java {@link Class}es
      * @return the corresponding {@link CtClass}es
      */
-    public static CtClass[] resolve( Class[] classes )
+    public static CtClass[] resolve( Class<?>[] classes )
     {
         final CtClass[] ctClasses = new CtClass[classes.length];
         for( int i = 0; i < ctClasses.length; ++i )

Modified: commons/proper/proxy/branches/version-2.0-work/jdk/src/main/java/org/apache/commons/proxy2/jdk/JdkProxyFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/proxy/branches/version-2.0-work/jdk/src/main/java/org/apache/commons/proxy2/jdk/JdkProxyFactory.java?rev=966001&r1=966000&r2=966001&view=diff
==============================================================================
--- commons/proper/proxy/branches/version-2.0-work/jdk/src/main/java/org/apache/commons/proxy2/jdk/JdkProxyFactory.java
(original)
+++ commons/proper/proxy/branches/version-2.0-work/jdk/src/main/java/org/apache/commons/proxy2/jdk/JdkProxyFactory.java
Tue Jul 20 20:49:28 2010
@@ -21,6 +21,7 @@ import org.apache.commons.proxy2.Interce
 import org.apache.commons.proxy2.Invocation;
 import org.apache.commons.proxy2.Invoker;
 import org.apache.commons.proxy2.ObjectProvider;
+import org.apache.commons.proxy2.ProxyFactory;
 import org.apache.commons.proxy2.ProxyUtils;
 import org.apache.commons.proxy2.impl.AbstractProxyFactory;
 
@@ -30,13 +31,15 @@ import java.lang.reflect.InvocationTarge
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 
+/**
+ * {@link ProxyFactory} implementation that uses {@link java.lang.reflect.Proxy} proxies.
+ */
 public class JdkProxyFactory extends AbstractProxyFactory
 {
 //**********************************************************************************************************************
 // ProxyFactory Implementation
 //**********************************************************************************************************************
 
-
     /**
      * Creates a proxy2 which delegates to the object provided by <code>delegateProvider</code>.
      *
@@ -45,10 +48,11 @@ public class JdkProxyFactory extends Abs
      * @param proxyClasses     the interfaces that the proxy2 should implement
      * @return a proxy2 which delegates to the object provided by the target <code>delegateProvider>
      */
-    public Object createDelegatorProxy( ClassLoader classLoader, ObjectProvider delegateProvider,
-                                        Class... proxyClasses )
+    @SuppressWarnings("unchecked")
+    public <T> T createDelegatorProxy( ClassLoader classLoader, ObjectProvider<?>
delegateProvider,
+                                        Class<?>... proxyClasses )
     {
-        return Proxy.newProxyInstance(classLoader, proxyClasses,
+        return (T) Proxy.newProxyInstance(classLoader, proxyClasses,
                                       new DelegatorInvocationHandler(delegateProvider));
     }
 
@@ -63,10 +67,11 @@ public class JdkProxyFactory extends Abs
      * @return a proxy2 which passes through a {@link Interceptor interceptor} before eventually
reaching the
      *         <code>target</code> object.
      */
-    public Object createInterceptorProxy( ClassLoader classLoader, Object target, Interceptor
interceptor,
-                                          Class... proxyClasses )
+    @SuppressWarnings("unchecked")
+    public <T> T createInterceptorProxy( ClassLoader classLoader, Object target, Interceptor
interceptor,
+                                          Class<?>... proxyClasses )
     {
-        return Proxy
+        return (T) Proxy
                 .newProxyInstance(classLoader, proxyClasses, new InterceptorInvocationHandler(target,
interceptor));
     }
 
@@ -78,10 +83,11 @@ public class JdkProxyFactory extends Abs
      * @param proxyClasses the interfaces that the proxy2 should implement
      * @return a proxy2 which uses the provided {@link Invoker} to handle all method invocations
      */
-    public Object createInvokerProxy( ClassLoader classLoader, Invoker invoker,
-                                      Class... proxyClasses )
+    @SuppressWarnings("unchecked")
+    public <T> T createInvokerProxy( ClassLoader classLoader, Invoker invoker,
+                                      Class<?>... proxyClasses )
     {
-        return Proxy.newProxyInstance(classLoader, proxyClasses, new InvokerInvocationHandler(invoker));
+        return (T) Proxy.newProxyInstance(classLoader, proxyClasses, new InvokerInvocationHandler(invoker));
     }
 
 //**********************************************************************************************************************
@@ -90,6 +96,9 @@ public class JdkProxyFactory extends Abs
 
     private abstract static class AbstractInvocationHandler implements InvocationHandler,
Serializable
     {
+        /** Serialization version */
+        private static final long serialVersionUID = 1L;
+
         public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable
         {
             if( ProxyUtils.isHashCode(method) )
@@ -111,9 +120,12 @@ public class JdkProxyFactory extends Abs
 
     private static class DelegatorInvocationHandler extends AbstractInvocationHandler
     {
-        private final ObjectProvider delegateProvider;
+        /** Serialization version */
+        private static final long serialVersionUID = 1L;
+
+        private final ObjectProvider<?> delegateProvider;
 
-        protected DelegatorInvocationHandler( ObjectProvider delegateProvider )
+        protected DelegatorInvocationHandler( ObjectProvider<?> delegateProvider )
         {
             this.delegateProvider = delegateProvider;
         }
@@ -133,6 +145,9 @@ public class JdkProxyFactory extends Abs
 
     private static class InterceptorInvocationHandler extends AbstractInvocationHandler
     {
+        /** Serialization version */
+        private static final long serialVersionUID = 1L;
+
         private final Object target;
         private final Interceptor methodInterceptor;
 
@@ -151,6 +166,9 @@ public class JdkProxyFactory extends Abs
 
     private static class InvokerInvocationHandler extends AbstractInvocationHandler
     {
+        /** Serialization version */
+        private static final long serialVersionUID = 1L;
+
         private final Invoker invoker;
 
         public InvokerInvocationHandler( Invoker invoker )
@@ -166,6 +184,9 @@ public class JdkProxyFactory extends Abs
 
     private static class ReflectionInvocation implements Invocation, Serializable
     {
+        /** Serialization version */
+        private static final long serialVersionUID = 1L;
+
         private final Method method;
         private final Object[] arguments;
         private final Object target;



Mime
View raw message