public class J2PProxyFactory
extends ProxyFactory
Modifier and Type | Class and Description |
---|---|
static interface |
J2PProxyFactory.ClassLoaderProvider
A provider of class loaders.
|
Modifier and Type | Field and Description |
---|---|
J2PProxyFactory.ClassLoaderProvider |
classLoaderProvider
A provider used by
createClass() for obtaining a class loader. |
static boolean |
useCache
If true, a generated proxy class is cached and it will be reused
when generating the proxy class with the same properties is requested.
|
java.lang.String |
writeDirectory
If the value of this variable is not null, the class file of the generated proxy class is written under the directory specified by this variable.
|
Constructor and Description |
---|
J2PProxyFactory()
Constructs a factory of proxy class.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
create(java.lang.Class[] paramTypes,
java.lang.Object[] args)
Creates a proxy class and returns an instance of that class.
|
java.lang.Object |
create(java.lang.Class[] paramTypes,
java.lang.Object[] args,
MethodHandler mh)
Creates a proxy class and returns an instance of that class.
|
java.lang.Class<?> |
createClass()
Generates a proxy class.
|
protected java.lang.ClassLoader |
getClassLoader() |
protected java.lang.ClassLoader |
getClassLoader0() |
protected java.security.ProtectionDomain |
getDomain() |
java.lang.Class<?>[] |
getInterfaces()
Obtains the interfaces set by
setInterfaces . |
java.lang.Class<?> |
getSuperclass()
Obtains the super class set by
setSuperclass() . |
void |
setFilter(MethodFilter mf)
Sets a filter that selects the methods that will be controlled by a handler.
|
void |
setHandler(MethodHandler mi)
Sets the default invocation handler.
|
void |
setInterfaces(java.lang.Class[] ifs)
Sets the interfaces of a proxy class.
|
void |
setSuperclass(java.lang.Class clazz)
Sets the super class of a proxy class.
|
public java.lang.String writeDirectory
"."
, then the class file is written under the current directory. This method is for debugging. The default value is null.
public static boolean useCache
public J2PProxyFactory.ClassLoaderProvider classLoaderProvider
createClass()
for obtaining a class loader. get()
on this ClassLoaderProvider
object is called to obtain a class loader. The value of this field can be updated for changing the default implementation.
Example:
ProxyFactory.classLoaderProvider = new ProxyFactory.ClassLoaderProvider() { public ClassLoader get(ProxyFactory pf) { return Thread.currentThread().getContextClassLoader(); } };
public void setSuperclass(java.lang.Class clazz)
public java.lang.Class<?> getSuperclass()
setSuperclass()
.public void setInterfaces(java.lang.Class[] ifs)
public java.lang.Class<?>[] getInterfaces()
setInterfaces
.public void setFilter(MethodFilter mf)
public java.lang.Class<?> createClass()
protected java.lang.ClassLoader getClassLoader()
protected java.lang.ClassLoader getClassLoader0()
protected java.security.ProtectionDomain getDomain()
public java.lang.Object create(java.lang.Class[] paramTypes, java.lang.Object[] args, MethodHandler mh) throws java.lang.NoSuchMethodException, java.lang.IllegalArgumentException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
paramTypes
- parameter types for a constructor.args
- arguments passed to a constructor.mh
- the method handler for the proxy class.java.lang.NoSuchMethodException
java.lang.IllegalArgumentException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public java.lang.Object create(java.lang.Class[] paramTypes, java.lang.Object[] args) throws java.lang.NoSuchMethodException, java.lang.IllegalArgumentException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
paramTypes
- parameter types for a constructor.args
- arguments passed to a constructor.java.lang.NoSuchMethodException
java.lang.IllegalArgumentException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public void setHandler(MethodHandler mi)