public class ProxyFactory extends Object
A lightweight proxy factory for instantiating intercepted instances of interface implementations.
If you need special sets of interceptors and multiple implementing interfaces, use
getProxy()
for creating proxies.
For most cases it is sufficient to use getTypedProxy(Object, Class)
,
which allows you to use a singleton ProxyFactory
for generating multiple proxies.
Constructor and Description |
---|
ProxyFactory() |
Modifier and Type | Method and Description |
---|---|
ClassLoader |
getClassLoader() |
Pattern |
getExcludeMethods() |
Pattern |
getIncludeMethods() |
Class[] |
getInterceptedInterfaces() |
org.aopalliance.intercept.MethodInterceptor[] |
getInterceptors() |
Class[] |
getInterfaces() |
Object |
getMultiTypedProxy(Object _target,
Class[] ifaces)
This method facilitates the use of a proxy singleton to generate more proxies for
different targets with a changing set of interfaces but with the same set of interceptors.
|
Object |
getMultiTypedProxy(Object _target,
Class[] ifaces,
Class[] interceptedInterfaces)
This method facilitates the use of a proxy singleton to generate more proxies for
different targets with a changing set of interfaces but with the same set of interceptors.
|
Object |
getProxy() |
Object |
getTarget() |
<T> T |
getTypedProxy(Object _target,
Class<T> iface)
This method facilitates the use of a proxy singleton to generate more proxies for
different targets with changing interfaces but with the same set of interceptors.
|
void |
setClassLoader(ClassLoader classLoader) |
void |
setExcludeMethods(Pattern excludeMethods) |
void |
setIncludeMethods(Pattern includeMethods) |
void |
setInterceptedInterfaces(Class[] interceptedInterfaces) |
void |
setInterceptor(org.aopalliance.intercept.MethodInterceptor interceptor)
Convenience setter, which sets the invoked interceptors to a single instance.
|
void |
setInterceptors(org.aopalliance.intercept.MethodInterceptor[] interceptors) |
void |
setInterface(Class iface)
Convenience setter, which sets the proxy-implemented interfaces to a single interface.
|
void |
setInterfaces(Class[] interfaces) |
void |
setTarget(Object target) |
public <T> T getTypedProxy(Object _target, Class<T> iface)
This method facilitates the use of a proxy singleton to generate more proxies for
different targets with changing interfaces but with the same set of interceptors.
If your interceptors are different
for each target, use separate ProxyFactory
instances with different bean
configurations.
This method ignores the target
and interfaces
bean properties.
_target
- The target to wrap.iface
- The interface of the returned proxy.public Object getProxy()
public Object getMultiTypedProxy(Object _target, Class[] ifaces)
This method facilitates the use of a proxy singleton to generate more proxies for
different targets with a changing set of interfaces but with the same set of interceptors.
If your interceptors are different
for each target, use separate ProxyFactory
instances with different bean
configurations.
This method ignores the target
, interfaces
and
interceptedInterfaces
bean properties.
_target
- The target to wrap.ifaces
- The list of interface to be implemented by the returned proxy.public Object getMultiTypedProxy(Object _target, Class[] ifaces, Class[] interceptedInterfaces)
This method facilitates the use of a proxy singleton to generate more proxies for
different targets with a changing set of interfaces but with the same set of interceptors.
If your interceptors are different
for each target, use separate ProxyFactory
instances with different bean
configurations.
This method ignores the target
, interfaces
and
interceptedInterfaces
bean properties.
_target
- The target to wrap.ifaces
- The list of interface to be implemented by the returned proxy.interceptedInterfaces
- The optional list of interfaces actually being
intercepted. If set to null
, all implemented interfaces
are being intercepted.public Object getTarget()
public void setTarget(Object target)
target
- the target to set.
There's no need to call this method, if you use
getTypedProxy(Object, Class)
, getMultiTypedProxy(Object, Class[])
or getMultiTypedProxy(Object, Class[], Class[])
.public ClassLoader getClassLoader()
null
, the class loader of
the target object should be used.public void setClassLoader(ClassLoader classLoader)
classLoader
- the classLoader to setpublic Class[] getInterfaces()
public void setInterfaces(Class[] interfaces)
interfaces
- the interfaces, which are implemented by the generated proxy to set.
There's no need to call this method, if you use
getTypedProxy(Object, Class)
, getMultiTypedProxy(Object, Class[])
or getMultiTypedProxy(Object, Class[], Class[])
.public void setInterceptedInterfaces(Class[] interceptedInterfaces)
interceptedInterfaces
- the optional list of interfaces, which are
actually intercepted the generated proxy returned by getProxy()
.
If set to null
all interfaces provided by setInterfaces(Class[])
are subject to the provided interceptors.
There's no need to call this method, if you use
getTypedProxy(Object, Class)
, getMultiTypedProxy(Object, Class[])
or getMultiTypedProxy(Object, Class[], Class[])
.public Class[] getInterceptedInterfaces()
getProxy()
.public void setInterface(Class iface)
getTypedProxy(Object, Class)
, getMultiTypedProxy(Object, Class[])
or getMultiTypedProxy(Object, Class[], Class[])
.iface
- the interface to setpublic org.aopalliance.intercept.MethodInterceptor[] getInterceptors()
public void setInterceptors(org.aopalliance.intercept.MethodInterceptor[] interceptors)
interceptors
- the interceptors to setpublic void setInterceptor(org.aopalliance.intercept.MethodInterceptor interceptor)
interceptor
- the interceptor to setpublic Pattern getIncludeMethods()
null
, all interface methods are included.public void setIncludeMethods(Pattern includeMethods)
includeMethods
- the includeMethods to setpublic Pattern getExcludeMethods()
null
, no interface method is omitted.public void setExcludeMethods(Pattern excludeMethods)
excludeMethods
- the excludeMethods to setCopyright © 2016 Clazzes.org. All rights reserved.