|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.thoughtworks.proxy.toys.delegate.DelegatingInvoker<T>
public class DelegatingInvoker<T>
Invoker that delegates method calls to an object.
This forms the basis of many other proxy toys. The delegation behavior was factored out of HotSwappingInvoker.
HotSwappingInvoker
,
Serialized FormConstructor Summary | |
---|---|
DelegatingInvoker(ProxyFactory proxyFactory,
ObjectReference<T> delegateReference,
DelegationMode delegationMode)
Construct a DelegatingInvoker. |
|
DelegatingInvoker(T delegate)
Construct a DelegatingInvoker with a StandardProxyFactory and DelegationMode.SIGNATURE . |
Method Summary | |
---|---|
protected T |
delegate()
Retrieve the delegated object in derived classes. |
boolean |
equals(Object obj)
Compares a DelegatingInvoker with another one for equality. |
protected ObjectReference<T> |
getDelegateReference()
Retrieve the ObjectReference of the delegate. |
protected Method |
getMethodToInvoke(Method method,
Object[] args)
Lookup a matching method. |
protected ProxyFactory |
getProxyFactory()
Retrieve the ProxyFactory to use. |
int |
hashCode()
|
Object |
invoke(Object proxy,
Method method,
Object[] args)
Invocation of a method of the proxied object. |
protected Object |
invokeOnDelegate(Method method,
Object[] args)
Invoke the given method on the delegate. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DelegatingInvoker(ProxyFactory proxyFactory, ObjectReference<T> delegateReference, DelegationMode delegationMode)
proxyFactory
- the ProxyFactory
to usedelegateReference
- the ObjectReference
of the delegatedelegationMode
- one of the delegation modes
IllegalArgumentException
- if the delegationMode is not one of the predefined constants of
Delegating
public DelegatingInvoker(T delegate)
StandardProxyFactory
and DelegationMode.SIGNATURE
.
delegate
- the delegated objectMethod Detail |
---|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
Invoker
invoke
in interface Invoker
proxy
- the proxy instance.method
- the method to invoke.args
- the arguments of the method.
Throwable
- if the invoked method has thrown.protected T delegate()
protected Method getMethodToInvoke(Method method, Object[] args)
method
- the invoked method on the proxyargs
- the arguments for the invocation
DelegationException
- if no matching method can be foundprotected Object invokeOnDelegate(Method method, Object[] args) throws InvocationTargetException
method
- the method to invokeargs
- the arguments for the invocation
InvocationTargetException
- if the invoked method throws any exceptionprotected ObjectReference<T> getDelegateReference()
ObjectReference
of the delegate.
protected ProxyFactory getProxyFactory()
ProxyFactory
to use.
public boolean equals(Object obj)
equals
in class Object
Object.equals(java.lang.Object)
public int hashCode()
hashCode
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |