public class ProxyFactory extends Object
ProxyFactory can be used to create three different "flavors" of proxy objects.
ObjectProviderInterceptorInvoker to handle all method invocationsOriginally, the ProxyFactory class was an interface. However, to allow for future changes to the class without breaking binary or semantic compatibility, it has been changed to a concrete class.
Note: This class uses Java reflection. For more efficient proxies, try using either
CglibProxyFactory or
JavassistProxyFactory instead.
| Constructor and Description |
|---|
ProxyFactory() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canProxy(Class[] proxyClasses)
Returns true if all
proxyClasses are interfaces. |
Object |
createDelegatorProxy(ClassLoader classLoader,
ObjectProvider delegateProvider,
Class[] proxyClasses)
Creates a proxy which delegates to the object provided by
delegateProvider. |
Object |
createDelegatorProxy(ObjectProvider delegateProvider,
Class[] proxyClasses)
Creates a proxy which delegates to the object provided by
delegateProvider. |
Object |
createInterceptorProxy(ClassLoader classLoader,
Object target,
Interceptor interceptor,
Class[] proxyClasses)
Creates a proxy which passes through a
interceptor before eventually reaching the
target object. |
Object |
createInterceptorProxy(Object target,
Interceptor interceptor,
Class[] proxyClasses)
Creates a proxy which passes through a
interceptor before eventually reaching the
target object. |
Object |
createInvokerProxy(ClassLoader classLoader,
Invoker invoker,
Class[] proxyClasses)
Creates a proxy which uses the provided
Invoker to handle all method invocations. |
Object |
createInvokerProxy(Invoker invoker,
Class[] proxyClasses)
Creates a proxy which uses the provided
Invoker to handle all method invocations. |
public boolean canProxy(Class[] proxyClasses)
proxyClasses are interfaces.proxyClasses - the proxy classesproxyClasses are interfacespublic Object createDelegatorProxy(ObjectProvider delegateProvider, Class[] proxyClasses)
delegateProvider. The proxy will be
generated using the current thread's "context class loader."delegateProvider - the delegate providerproxyClasses - the interfaces that the proxy should implementpublic Object createDelegatorProxy(ClassLoader classLoader, ObjectProvider delegateProvider, Class[] proxyClasses)
delegateProvider.classLoader - the class loader to use when generating the proxydelegateProvider - the delegate providerproxyClasses - the interfaces that the proxy should implementdelegateProvider>public Object createInterceptorProxy(Object target, Interceptor interceptor, Class[] proxyClasses)
interceptor before eventually reaching the
target object. The proxy will be generated using the current thread's "context class loader."target - the target objectinterceptor - the method interceptorproxyClasses - the interfaces that the proxy should implementinterceptor before eventually reaching the
target object.public Object createInterceptorProxy(ClassLoader classLoader, Object target, Interceptor interceptor, Class[] proxyClasses)
interceptor before eventually reaching the
target object.classLoader - the class loader to use when generating the proxytarget - the target objectinterceptor - the method interceptorproxyClasses - the interfaces that the proxy should implement.interceptor before eventually reaching the
target object.public Object createInvokerProxy(Invoker invoker, Class[] proxyClasses)
Invoker to handle all method invocations. The proxy will be
generated using the current thread's "context class loader."invoker - the invokerproxyClasses - the interfaces that the proxy should implementInvoker to handle all method invocationspublic Object createInvokerProxy(ClassLoader classLoader, Invoker invoker, Class[] proxyClasses)
Invoker to handle all method invocations.classLoader - the class loader to use when generating the proxyinvoker - the invokerproxyClasses - the interfaces that the proxy should implementInvoker to handle all method invocationsCopyright © 2005-2013 Apache Software Foundation. All Rights Reserved.