public class DelegatingInvoker extends java.lang.Object implements Invoker
This forms the basis of many other proxy toys. The delegation behaviour was factored out of HotSwappingInvoker.
HotSwappingInvoker,
Serialized Form| Constructor and Description |
|---|
DelegatingInvoker(java.lang.Object delegate)
Construct a DelegatingInvoker with a
StandardProxyFactory and Delegating.MODE_SIGNATURE. |
DelegatingInvoker(ProxyFactory proxyFactory,
ObjectReference delegateReference,
boolean staticTyping)
Deprecated.
since 0.2, use
DelegatingInvoker(ProxyFactory, ObjectReference, int) |
DelegatingInvoker(ProxyFactory proxyFactory,
ObjectReference delegateReference,
int delegationMode)
Construct a DelegatingInvoker.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.Object |
delegate()
Retrieve the delegated object in derived classes.
|
boolean |
equals(java.lang.Object obj)
Compares a DelegatingInvoker with another one for equality.
|
protected ObjectReference |
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.
|
public DelegatingInvoker(ProxyFactory proxyFactory, ObjectReference delegateReference, int 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(ProxyFactory proxyFactory, ObjectReference delegateReference, boolean staticTyping)
DelegatingInvoker(ProxyFactory, ObjectReference, int)proxyFactory - the ProxyFactory to usedelegateReference - the ObjectReference of the delegatestaticTyping - Delegating.STATIC_TYPING or Delegating.DYNAMIC_TYPINGpublic DelegatingInvoker(java.lang.Object delegate)
StandardProxyFactory and Delegating.MODE_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 java.lang.Object 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 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.Object