Package org.proxy4j.core.javassist
Class JavassistProxyFactory
- java.lang.Object
-
- org.proxy4j.core.BaseProxyFactory
-
- org.proxy4j.core.javassist.JavassistProxyFactory
-
- All Implemented Interfaces:
ProxyFactory
public class JavassistProxyFactory extends BaseProxyFactory
ProxyFactoryimplementation using Javassist.- Author:
- Brennan Spies
-
-
Constructor Summary
Constructors Constructor Description JavassistProxyFactory()JavassistProxyFactory(ClassLoader loader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> InterceptorBuilder<T>buildInterceptor(Class<T> proxyClass)Creates a new builder for constructing an interceptor or "protection" proxy.ObjectcreateProxy(Class<?>[] proxyInterfaces, ProxyHandler<?> handler)Creates a proxy that implements multiple interfaces where invocations on that proxy are passed to a singleinvokemethod on theProxyHandler.<T> TcreateProxy(Class<T> proxyType, javax.inject.Provider<T> provider)Creates a "virtual" proxy where method invocations on the proxy are delegated to the provided instance.<T> TcreateProxy(Class<T> proxyType, ProxyHandler<T> handler)Creates a proxy where method invocations on the proxy are passed to a singleinvokemethod on theProxyHandler.-
Methods inherited from class org.proxy4j.core.BaseProxyFactory
assertClassVisible, assertInterfaces, createProxy, getNamingStrategy, getPreferredClassLoader, getProxyClassLoader, setNamingStrategy
-
-
-
-
Constructor Detail
-
JavassistProxyFactory
public JavassistProxyFactory()
-
JavassistProxyFactory
@Inject public JavassistProxyFactory(ClassLoader loader)
-
-
Method Detail
-
createProxy
public <T> T createProxy(Class<T> proxyType, javax.inject.Provider<T> provider) throws GenerationException
Description copied from interface:ProxyFactoryCreates a "virtual" proxy where method invocations on the proxy are delegated to the provided instance.- Type Parameters:
T- The proxy type- Parameters:
proxyType- The proxied classprovider- The provider of the proxied object- Returns:
- The proxy
- Throws:
GenerationException- If an error occurs creating the proxy- See Also:
ProxyFactory.createProxy(Class, javax.inject.Provider)
-
createProxy
public <T> T createProxy(Class<T> proxyType, ProxyHandler<T> handler) throws GenerationException
Description copied from interface:ProxyFactoryCreates a proxy where method invocations on the proxy are passed to a singleinvokemethod on theProxyHandler.- Type Parameters:
T- The proxy type- Parameters:
proxyType- The proxied interface classhandler- The handler for the method invocation- Returns:
- The proxy
- Throws:
GenerationException- If an error occurs creating the proxy- See Also:
ProxyFactory.createProxy(Class, org.proxy4j.core.ProxyHandler)
-
createProxy
public Object createProxy(Class<?>[] proxyInterfaces, ProxyHandler<?> handler) throws GenerationException
Description copied from interface:ProxyFactoryCreates a proxy that implements multiple interfaces where invocations on that proxy are passed to a singleinvokemethod on theProxyHandler. Equivalent to the traditional JDK proxy creation method:Proxy.newProxyInstance(ClassLoader, Class[], java.lang.reflect.InvocationHandler).- Parameters:
proxyInterfaces- The interfaces that the proxy class must implementhandler- The handler for the method invocation- Returns:
- The proxy
- Throws:
GenerationException- If an error occurs creating the proxy- See Also:
ProxyFactory.createProxy(Class[], org.proxy4j.core.ProxyHandler)
-
buildInterceptor
public <T> InterceptorBuilder<T> buildInterceptor(Class<T> proxyClass)
Description copied from interface:ProxyFactoryCreates a new builder for constructing an interceptor or "protection" proxy. The builder allows fine-grained customization of how the target's methods are intercepted.- Type Parameters:
T- The proxy type- Parameters:
proxyClass- The class of the proxy (and target)- Returns:
- The builder
- See Also:
ProxyFactory.buildInterceptor(Class)
-
-