Top Description Constructors Methods
org.springframework.aop.framework

public Class ProxyFactory

extends ProxyCreatorSupport
Class Inheritance
Annotations
@SuppressWarnings:serial
Imports
org.aopalliance.intercept.Interceptor, org.springframework.aop.TargetSource, org.springframework.lang.Nullable, org.springframework.util.ClassUtils

Factory for AOP proxies for programmatic use, rather than via declarative setup in a bean factory. This class provides a simple way of obtaining and configuring AOP proxy instances in custom user code.
Authors
Rod Johnson, Juergen Hoeller, Rob Harrop
Since
14.03.2003

Constructor Summary

AccessConstructor and Description
public
ProxyFactory()

Create a new ProxyFactory.

public
ProxyFactory(Object
the target object to be proxied
target
)

Create a new ProxyFactory.

public
ProxyFactory(Class<?>...
the interfaces that the proxy should implement
proxyInterfaces
)

Create a new ProxyFactory.

public
ProxyFactory(Class<?>
the interface that the proxy should implement
proxyInterface
,
Interceptor
the interceptor that the proxy should invoke
interceptor
)

Create a new ProxyFactory for the given interface and interceptor.

public
ProxyFactory(Class<?>
the interface that the proxy should implement
proxyInterface
,
TargetSource
the TargetSource that the proxy should invoke
targetSource
)

Create a ProxyFactory for the specified TargetSource, making the proxy implement the specified interface.

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

the proxy object
getProxy
()

Create a new proxy according to the settings in this factory.

public Object

Returns:

the proxy object
getProxy
(ClassLoader
the class loader to create the proxy with (or null for the low-level proxy facility's default)
classLoader
)

Create a new proxy according to the settings in this factory.

public static <T> T

Returns:

the proxy object
getProxy
(Class<T>
the interface that the proxy should implement
proxyInterface
,
Interceptor
the interceptor that the proxy should invoke
interceptor
)

Create a new proxy for the given interface and interceptor.

public static <T> T

Returns:

the proxy object
getProxy
(Class<T>
the interface that the proxy should implement
proxyInterface
,
TargetSource
the TargetSource that the proxy should invoke
targetSource
)

Create a proxy for the specified TargetSource, implementing the specified interface.

public static Object

Returns:

the proxy object
getProxy
(TargetSource
the TargetSource that the proxy should invoke
targetSource
)

Create a proxy for the specified TargetSource that extends the target class of the TargetSource.

public Class<?>

Returns:

the proxy class
getProxyClass
(ClassLoader
the class loader to create the proxy class with (or null for the low-level proxy facility's default)
classLoader
)

Determine the proxy class according to the settings in this factory.

Inherited from org.springframework.aop.framework.ProxyCreatorSupport:
addListeneradviceChangedcreateAopProxygetAopProxyFactoryisActiveremoveListenersetAopProxyFactory

Constructor Detail

ProxyFactoryback to summary
public ProxyFactory()

Create a new ProxyFactory.

ProxyFactoryback to summary
public ProxyFactory(Object target)

Create a new ProxyFactory.

Will proxy all interfaces that the given target implements.

Parameters
target:Object

the target object to be proxied

ProxyFactoryback to summary
public ProxyFactory(Class<?>... proxyInterfaces)

Create a new ProxyFactory.

No target, only interfaces. Must add interceptors.

Parameters
proxyInterfaces:Class<?>[]

the interfaces that the proxy should implement

ProxyFactoryback to summary
public ProxyFactory(Class<?> proxyInterface, Interceptor interceptor)

Create a new ProxyFactory for the given interface and interceptor.

Convenience method for creating a proxy for a single interceptor, assuming that the interceptor handles all calls itself rather than delegating to a target, like in the case of remoting proxies.

Parameters
proxyInterface:Class<?>

the interface that the proxy should implement

interceptor:Interceptor

the interceptor that the proxy should invoke

ProxyFactoryback to summary
public ProxyFactory(Class<?> proxyInterface, TargetSource targetSource)

Create a ProxyFactory for the specified TargetSource, making the proxy implement the specified interface.

Parameters
proxyInterface:Class<?>

the interface that the proxy should implement

targetSource:TargetSource

the TargetSource that the proxy should invoke

Method Detail

getProxyback to summary
public Object getProxy()

Create a new proxy according to the settings in this factory.

Can be called repeatedly. Effect will vary if we've added or removed interfaces. Can add and remove interceptors.

Uses a default class loader: Usually, the thread context class loader (if necessary for proxy creation).

Returns:Object

the proxy object

getProxyback to summary
public Object getProxy(ClassLoader classLoader)

Create a new proxy according to the settings in this factory.

Can be called repeatedly. Effect will vary if we've added or removed interfaces. Can add and remove interceptors.

Uses the given class loader (if necessary for proxy creation).

Parameters
classLoader:ClassLoader

the class loader to create the proxy with (or null for the low-level proxy facility's default)

Returns:Object

the proxy object

getProxyback to summary
public static <T> T getProxy(Class<T> proxyInterface, Interceptor interceptor)

Create a new proxy for the given interface and interceptor.

Convenience method for creating a proxy for a single interceptor, assuming that the interceptor handles all calls itself rather than delegating to a target, like in the case of remoting proxies.

Parameters
proxyInterface:Class<T>

the interface that the proxy should implement

interceptor:Interceptor

the interceptor that the proxy should invoke

Returns:T

the proxy object

Annotations
@SuppressWarnings:unchecked
See Also
ProxyFactory(Class, org.aopalliance.intercept.Interceptor)
getProxyback to summary
public static <T> T getProxy(Class<T> proxyInterface, TargetSource targetSource)

Create a proxy for the specified TargetSource, implementing the specified interface.

Parameters
proxyInterface:Class<T>

the interface that the proxy should implement

targetSource:TargetSource

the TargetSource that the proxy should invoke

Returns:T

the proxy object

Annotations
@SuppressWarnings:unchecked
See Also
ProxyFactory(Class, org.springframework.aop.TargetSource)
getProxyback to summary
public static Object getProxy(TargetSource targetSource)

Create a proxy for the specified TargetSource that extends the target class of the TargetSource.

Parameters
targetSource:TargetSource

the TargetSource that the proxy should invoke

Returns:Object

the proxy object

getProxyClassback to summary
public Class<?> getProxyClass(ClassLoader classLoader)

Determine the proxy class according to the settings in this factory.

Parameters
classLoader:ClassLoader

the class loader to create the proxy class with (or null for the low-level proxy facility's default)

Returns:Class<?>

the proxy class

Since
6.0