Package org.proxy4j.core.jdk
Class JdkProxyFactory
- java.lang.Object
-
- org.proxy4j.core.BaseProxyFactory
-
- org.proxy4j.core.jdk.JdkProxyFactory
-
- All Implemented Interfaces:
ProxyFactory
public class JdkProxyFactory extends BaseProxyFactory
The proxy factory implementation using the JDK proxy implementation.- Since:
- 1.0
- Author:
- Brennan Spies
-
-
Constructor Summary
Constructors Constructor Description JdkProxyFactory()JdkProxyFactory(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> proxyInterface, javax.inject.Provider<T> provider)The proxy class (first argument) must be an interface, or anIllegalArgumentExceptionwill be thrown.<T> TcreateProxy(Class<T> proxyInterface, ProxyHandler<T> handler)The proxy class (first argument) must be an interface, or anIllegalArgumentExceptionwill be thrown.-
Methods inherited from class org.proxy4j.core.BaseProxyFactory
assertClassVisible, assertInterfaces, createProxy, getNamingStrategy, getPreferredClassLoader, getProxyClassLoader, setNamingStrategy
-
-
-
-
Constructor Detail
-
JdkProxyFactory
public JdkProxyFactory()
-
JdkProxyFactory
@Inject public JdkProxyFactory(ClassLoader loader)
-
-
Method Detail
-
createProxy
public <T> T createProxy(Class<T> proxyInterface, javax.inject.Provider<T> provider) throws GenerationException
The proxy class (first argument) must be an interface, or anIllegalArgumentExceptionwill be thrown.- Type Parameters:
T- The proxy type- Parameters:
proxyInterface- 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> proxyInterface, ProxyHandler<T> handler) throws GenerationException
The proxy class (first argument) must be an interface, or anIllegalArgumentExceptionwill be thrown.- Type Parameters:
T- The proxy type- Parameters:
proxyInterface- 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)
-
-