Build 1.0_r1(from source)

java.lang.reflect
Class Proxy

java.lang.Object
  extended by java.lang.reflect.Proxy
All Implemented Interfaces:
Serializable

public class Proxy
extends Object
implements Serializable

This class provides methods to creating dynamic proxy classes and instances.

Since:
1.3
See Also:
InvocationHandler, Serialized Form

Field Summary
protected  InvocationHandler h
           
 
Constructor Summary
protected Proxy(InvocationHandler h)
           
 
Method Summary
static InvocationHandler getInvocationHandler(Object proxy)
          Return the proxy instance's invocation handler.
static Class<?> getProxyClass(ClassLoader loader, Class<?>... interfaces)
          Return the dynamically build class for the given interfaces, build a new one when necessary.
static boolean isProxyClass(Class<?> cl)
          Return whether the supplied class is a dynamically generated proxy class.
static Object newProxyInstance(ClassLoader loader, Class<?>[] interfaces, InvocationHandler h)
          Return an instance of the dynamically build class for the given interfaces that forwards methods to the specified invocation handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

h

protected InvocationHandler h
Constructor Detail

Proxy

protected Proxy(InvocationHandler h)
Method Detail

getProxyClass

public static Class<?> getProxyClass(ClassLoader loader,
                                     Class<?>... interfaces)
                              throws IllegalArgumentException
Return the dynamically build class for the given interfaces, build a new one when necessary. The order of the interfaces is important. The interfaces must be visible from the supplied class loader; no duplicates are permitted. All non-public interfaces must be defined in the same package.

Parameters:
loader - the class loader that will define the proxy class.
interfaces - an array of Class objects, each one identifying an interface that the new proxy must implement
Returns:
a proxy class that implements all of the interfaces referred to in the contents of interfaces.
Throws:
IllegalArgumentException
NullPointerException - if either interfaces or any of its elements are null.

newProxyInstance

public static Object newProxyInstance(ClassLoader loader,
                                      Class<?>[] interfaces,
                                      InvocationHandler h)
                               throws IllegalArgumentException
Return an instance of the dynamically build class for the given interfaces that forwards methods to the specified invocation handler. The interfaces must be visible from the supplied class loader; no duplicates are permitted. All non-public interfaces must be defined in the same package.

Parameters:
loader - the class loader that will define the proxy class.
interfaces - the list of interfaces to implement.
h - the invocation handler for the forwarded methods.
Returns:
a new proxy object that delegates to the handler h
Throws:
IllegalArgumentException
NullPointerException - if the interfaces or any of its elements are null.

isProxyClass

public static boolean isProxyClass(Class<?> cl)
Return whether the supplied class is a dynamically generated proxy class.

Parameters:
cl - the class.
Returns:
true if the class is a proxy class and false otherwise.
Throws:
NullPointerException - if the class is null.

getInvocationHandler

public static InvocationHandler getInvocationHandler(Object proxy)
                                              throws IllegalArgumentException
Return the proxy instance's invocation handler.

Parameters:
proxy - the proxy instance.
Returns:
the proxy's invocation handler object
Throws:
IllegalArgumentException - if the supplied proxy is not a proxy object.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature