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.
|
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 |
---|---|
Object |
create(Class[] paramTypes,
Object[] args)
Creates a proxy class and returns an instance of that class.
|
Object |
create(Class[] paramTypes,
Object[] args,
MethodHandler mh)
Creates a proxy class and returns an instance of that class.
|
Class<?> |
createClass()
Generates a proxy class.
|
protected ClassLoader |
getClassLoader() |
protected ClassLoader |
getClassLoader0() |
protected ProtectionDomain |
getDomain() |
Class<?>[] |
getInterfaces()
Obtains the interfaces set by
setInterfaces . |
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(Class[] ifs)
Sets the interfaces of a proxy class.
|
void |
setSuperclass(Class clazz)
Sets the super class of a proxy class.
|
public 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(Class clazz)
public Class<?> getSuperclass()
setSuperclass()
.public void setInterfaces(Class[] ifs)
public Class<?>[] getInterfaces()
setInterfaces
.public void setFilter(MethodFilter mf)
public Class<?> createClass()
protected ClassLoader getClassLoader()
protected ClassLoader getClassLoader0()
protected ProtectionDomain getDomain()
public Object create(Class[] paramTypes, Object[] args, MethodHandler mh) throws NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
paramTypes
- parameter types for a constructor.args
- arguments passed to a constructor.mh
- the method handler for the proxy class.NoSuchMethodException
IllegalArgumentException
InstantiationException
IllegalAccessException
InvocationTargetException
public Object create(Class[] paramTypes, Object[] args) throws NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
paramTypes
- parameter types for a constructor.args
- arguments passed to a constructor.NoSuchMethodException
IllegalArgumentException
InstantiationException
IllegalAccessException
InvocationTargetException
public void setHandler(MethodHandler mi)