org.apache.commons.proxy
Class ProxyUtils

java.lang.Object
  extended by org.apache.commons.proxy.ProxyUtils

public class ProxyUtils
extends Object

Provides some helpful proxy utility methods.

Since:
1.0
Author:
James Carman

Field Summary
static Class[] EMPTY_ARGUMENT_TYPES
           
static Object[] EMPTY_ARGUMENTS
           
 
Constructor Summary
ProxyUtils()
           
 
Method Summary
static Object createNullObject(ProxyFactory proxyFactory, Class[] proxyClasses)
          Creates a "null object" which implements the proxyClasses.
static Object createNullObject(ProxyFactory proxyFactory, ClassLoader classLoader, Class[] proxyClasses)
          Creates a "null object" which implements the proxyClasses.
static Class[] getAllInterfaces(Class cls)
          Gets an array of Class objects representing all interfaces implemented by the given class and its superclasses.
static String getJavaClassName(Class clazz)
          Returns the class name as you would expect to see it in Java code.
static Class getWrapperClass(Class primitiveType)
          Returns the wrapper class for the given primitive type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ARGUMENTS

public static final Object[] EMPTY_ARGUMENTS

EMPTY_ARGUMENT_TYPES

public static final Class[] EMPTY_ARGUMENT_TYPES
Constructor Detail

ProxyUtils

public ProxyUtils()
Method Detail

createNullObject

public static Object createNullObject(ProxyFactory proxyFactory,
                                      Class[] proxyClasses)
Creates a "null object" which implements the proxyClasses.

Parameters:
proxyFactory - the proxy factory to be used to create the proxy object
proxyClasses - the proxy interfaces
Returns:
a "null object" which implements the proxyClasses.

createNullObject

public static Object createNullObject(ProxyFactory proxyFactory,
                                      ClassLoader classLoader,
                                      Class[] proxyClasses)
Creates a "null object" which implements the proxyClasses.

Parameters:
proxyFactory - the proxy factory to be used to create the proxy object
classLoader - the class loader to be used by the proxy factory to create the proxy object
proxyClasses - the proxy interfaces
Returns:
a "null object" which implements the proxyClasses.

getAllInterfaces

public static Class[] getAllInterfaces(Class cls)

Gets an array of Class objects representing all interfaces implemented by the given class and its superclasses.

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.

Note: Implementation of this method was "borrowed" from Apache Commons Lang to avoid a dependency.

Parameters:
cls - the class to look up, may be null
Returns:
an array of Class objects representing all interfaces implemented by the given class and its superclasses or null if input class is null.

getJavaClassName

public static String getJavaClassName(Class clazz)
Returns the class name as you would expect to see it in Java code.

Examples:


getWrapperClass

public static Class getWrapperClass(Class primitiveType)
Returns the wrapper class for the given primitive type.

Parameters:
primitiveType - the primitive type
Returns:
the wrapper class


Copyright © 2005-2008 The Apache Software Foundation. All Rights Reserved.