Class ForwardingHandler<T>
- java.lang.Object
-
- org.perfectable.introspection.proxy.ForwardingHandler<T>
-
- Type Parameters:
T
- type of objects handled
- All Implemented Interfaces:
InvocationHandler<MethodInvocation<T>>
public final class ForwardingHandler<T> extends Object implements InvocationHandler<MethodInvocation<T>>
Invocation handler that delegates all calls to actual object.This class is mutable, the target can be swapped while proxies are used.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
handle(MethodInvocation<T> invocation)
Catches invocation executed on proxy and returns result that should be passed to the client.static <T> ForwardingHandler<T>
of(T target)
Creates handler with specified object as a delegate.void
swap(T newTarget)
Changes target to provided one.
-
-
-
Method Detail
-
of
public static <T> ForwardingHandler<T> of(T target)
Creates handler with specified object as a delegate.- Type Parameters:
T
- type of proxy/target- Parameters:
target
- delegate target- Returns:
- handler that forwards to
target
-
swap
public void swap(T newTarget)
Changes target to provided one.- Parameters:
newTarget
- new delegation target
-
handle
@Nullable public Object handle(MethodInvocation<T> invocation) throws Throwable
Description copied from interface:InvocationHandler
Catches invocation executed on proxy and returns result that should be passed to the client.- Specified by:
handle
in interfaceInvocationHandler<T>
- Parameters:
invocation
- invocation captured- Returns:
- successful result of invocation processing
- Throws:
Throwable
- exception that will be thrown on the call site
-
-