com.thoughtworks.proxy.toys.failover
Class FailoverInvoker
java.lang.Object
com.thoughtworks.proxy.toys.delegate.DelegatingInvoker
com.thoughtworks.proxy.toys.hotswap.HotSwappingInvoker
com.thoughtworks.proxy.toys.failover.FailoverInvoker
- All Implemented Interfaces:
- Invoker, Serializable
public class FailoverInvoker
- extends HotSwappingInvoker
Invoker
that implements a failover strategy by using different delegates in
case of an exception. The implemented strategy is a simple round-robin algorithm to change the delegate in case of a
relevant exception.
- Since:
- 0.1
- Author:
- Dan North, Aslak Hellesøy, Jörg Schaible
- See Also:
- Serialized Form
FailoverInvoker
public FailoverInvoker(Class[] types,
ProxyFactory proxyFactory,
Object[] delegates,
Class exceptionClass)
- Construct a FailoverInvoker.
- Parameters:
types
- the types of the proxyproxyFactory
- the ProxyFactory
to usedelegates
- the delegates to useexceptionClass
- the type of the exception
- Throws:
IllegalArgumentException
- if exceptionClass is not a Throwable
- Since:
- 0.1
invokeOnDelegate
protected Object invokeOnDelegate(Method method,
Object[] args)
throws InvocationTargetException
- Description copied from class:
DelegatingInvoker
- Invoke the given method on the delegate.
- Overrides:
invokeOnDelegate
in class DelegatingInvoker
- Parameters:
method
- the method to invokeargs
- the arguments for the invocation
- Returns:
- the method's result
- Throws:
InvocationTargetException
- if the invoked method throws any exception