public class DelegatingInvoker<T> extends java.lang.Object implements Invoker
This forms the basis of many other proxy toys. The delegation behavior was factored out of HotSwappingInvoker.
HotSwappingInvoker,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
private ObjectReference<T> |
delegateReference |
private DelegationMode |
delegationMode |
private java.util.Map<java.lang.reflect.Method,java.lang.reflect.Method> |
methodCache |
private ProxyFactory |
proxyFactory |
private static long |
serialVersionUID |
| Constructor and Description |
|---|
DelegatingInvoker(ProxyFactory proxyFactory,
ObjectReference<T> delegateReference,
DelegationMode delegationMode)
Construct a DelegatingInvoker.
|
DelegatingInvoker(T delegate)
Construct a DelegatingInvoker with a
StandardProxyFactory and DelegationMode.SIGNATURE. |
| Modifier and Type | Method and Description |
|---|---|
protected T |
delegate()
Retrieve the delegated object in derived classes.
|
boolean |
equals(java.lang.Object obj)
Compares a DelegatingInvoker with another one for equality.
|
protected ObjectReference<T> |
getDelegateReference()
Retrieve the
ObjectReference of the delegate. |
protected java.lang.reflect.Method |
getMethodToInvoke(java.lang.reflect.Method method,
java.lang.Object[] args)
Lookup a matching method.
|
protected ProxyFactory |
getProxyFactory()
Retrieve the
ProxyFactory to use. |
int |
hashCode() |
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
Invocation of a method of the proxied object.
|
protected java.lang.Object |
invokeOnDelegate(java.lang.reflect.Method method,
java.lang.Object[] args)
Invoke the given method on the delegate.
|
private void |
readObject(java.io.ObjectInputStream in) |
private static final long serialVersionUID
private transient java.util.Map<java.lang.reflect.Method,java.lang.reflect.Method> methodCache
private ProxyFactory proxyFactory
private ObjectReference<T> delegateReference
private DelegationMode delegationMode
public DelegatingInvoker(ProxyFactory proxyFactory, ObjectReference<T> delegateReference, DelegationMode delegationMode)
proxyFactory - the ProxyFactory to usedelegateReference - the ObjectReference of the delegatedelegationMode - one of the delegation modesjava.lang.IllegalArgumentException - if the delegationMode is not one of the predefined constants of
Delegatingpublic DelegatingInvoker(T delegate)
StandardProxyFactory and DelegationMode.SIGNATURE.delegate - the delegated objectpublic java.lang.Object invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
throws java.lang.Throwable
Invokerprotected T delegate()
protected java.lang.reflect.Method getMethodToInvoke(java.lang.reflect.Method method,
java.lang.Object[] args)
method - the invoked method on the proxyargs - the arguments for the invocationDelegationException - if no matching method can be foundprotected java.lang.Object invokeOnDelegate(java.lang.reflect.Method method,
java.lang.Object[] args)
throws java.lang.reflect.InvocationTargetException
method - the method to invokeargs - the arguments for the invocationjava.lang.reflect.InvocationTargetException - if the invoked method throws any exceptionprotected ObjectReference<T> getDelegateReference()
ObjectReference of the delegate.protected ProxyFactory getProxyFactory()
ProxyFactory to use.public boolean equals(java.lang.Object obj)
equals in class java.lang.ObjectObject.equals(java.lang.Object)public int hashCode()
hashCode in class java.lang.Objectprivate void readObject(java.io.ObjectInputStream in)
throws java.io.IOException,
java.lang.ClassNotFoundException
java.io.IOExceptionjava.lang.ClassNotFoundException