Class JdkProxyService
- java.lang.Object
-
- org.perfectable.introspection.proxy.JdkProxyService
-
- All Implemented Interfaces:
ProxyService
@Immutable @AutoService(ProxyService.class) public final class JdkProxyService extends Object implements ProxyService
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.perfectable.introspection.proxy.ProxyService
ProxyService.Container, ProxyService.Feature, ProxyService.UnsupportedFeatureException
-
-
Field Summary
-
Fields inherited from interface org.perfectable.introspection.proxy.ProxyService
INSTANCES
-
-
Constructor Summary
Constructors Constructor Description JdkProxyService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <I> I
instantiate(ClassLoader classLoader, Class<?> baseClass, List<? extends Class<?>> interfaces, InvocationHandler<? super MethodInvocation<I>> handler)
Creates proxy instance.boolean
supportsFeature(ProxyService.Feature feature)
If the concrete service supports specified feature.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.perfectable.introspection.proxy.ProxyService
supportsAllFeatures
-
-
-
-
Method Detail
-
supportsFeature
public boolean supportsFeature(ProxyService.Feature feature)
Description copied from interface:ProxyService
If the concrete service supports specified feature.- Specified by:
supportsFeature
in interfaceProxyService
- Parameters:
feature
- feature to test- Returns:
- if service supports feature
-
instantiate
public <I> I instantiate(ClassLoader classLoader, Class<?> baseClass, List<? extends Class<?>> interfaces, InvocationHandler<? super MethodInvocation<I>> handler) throws ProxyService.UnsupportedFeatureException
Description copied from interface:ProxyService
Creates proxy instance.This method either creates new proxy class, or reuses one that matches. This proxy class extends
baseClass
and implementsinterfaces
, and is created inclassLoader
. After creating this class, its object is instantiated. The object will delegate every call that it receives to specifiedInvocationHandler
. The only exception isObject.finalize()
, which must be ignored.This method assumes that the arguments were correctly prepared:
baseClass
is not finalbaseClass
is actually a class (not an interface)baseClass
and each element ofinterfaces
has classloader exactlyclassLoader
- Each element in
interfaces
is an interface (not a class)
- Specified by:
instantiate
in interfaceProxyService
- Type Parameters:
I
- type of proxy- Parameters:
classLoader
- classloader used to create proxy classbaseClass
- proxy superclass, cannot be final, must be a classinterfaces
- additional interfaces that proxy class should implementhandler
- invocation handler to pass method execution for this proxy instance- Returns:
- proxy instance
- Throws:
ProxyService.UnsupportedFeatureException
- when this service cannot create proxy with requested parameters, because it doesn't support some feature required to do so
-
-