public class Proxy extends Object implements Serializable
Proxy defines methods for creating dynamic proxy classes and instances.
A proxy class implements a declared set of interfaces and delegates method
invocations to an InvocationHandler.InvocationHandler,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected InvocationHandler |
h
The invocation handler on which the method calls are dispatched.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Proxy(InvocationHandler h)
Constructs a new
Proxy instance with the specified invocation
handler. |
| Modifier and Type | Method and Description |
|---|---|
static InvocationHandler |
getInvocationHandler(Object proxy)
Returns the invocation handler of the specified proxy instance.
|
static Class<?> |
getProxyClass(ClassLoader loader,
Class<?>... interfaces)
Returns the dynamically built
Class for the specified interfaces. |
static boolean |
isProxyClass(Class<?> cl)
Indicates whether or not the specified class is a dynamically generated
proxy class.
|
static Object |
newProxyInstance(ClassLoader loader,
Class<?>[] interfaces,
InvocationHandler invocationHandler)
Returns an instance of the dynamically built class for the specified
interfaces.
|
protected InvocationHandler h
protected Proxy(InvocationHandler h)
Proxy instance with the specified invocation
handler.h - the invocation handler for the newly created proxypublic static Class<?> getProxyClass(ClassLoader loader, Class<?>... interfaces) throws IllegalArgumentException
Class for the specified interfaces.
Creates a new Class when necessary. The order of the interfaces
is relevant. Invocations of this method with the same interfaces but
different order result in different generated classes. 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.loader - the class loader that will define the proxy classinterfaces - an array of Class objects, each one identifying an
interface that will be implemented by the returned proxy
classinterfacesIllegalArgumentException - if any of the interface restrictions are violatedNullPointerException - if either interfaces or any of its elements are
nullpublic static Object newProxyInstance(ClassLoader loader, Class<?>[] interfaces, InvocationHandler invocationHandler) throws IllegalArgumentException
loader - the class loader that will define the proxy classinterfaces - an array of Class objects, each one identifying an
interface that will be implemented by the returned proxy
objectinvocationHandler - the invocation handler that handles the dispatched method
invocationshIllegalArgumentException - if any of the interface restrictions are violatedNullPointerException - if the interfaces or any of its elements are nullpublic static boolean isProxyClass(Class<?> cl)
cl - the classtrue if the class is a proxy class, false
otherwiseNullPointerException - if the class is nullpublic static InvocationHandler getInvocationHandler(Object proxy) throws IllegalArgumentException
proxy - the proxy instanceIllegalArgumentException - if the supplied proxy is not a proxy object