com.thoughtworks.proxy.toys.failover
Class FailoverInvoker<T>

java.lang.Object
  extended by com.thoughtworks.proxy.toys.delegate.DelegatingInvoker<Object>
      extended by com.thoughtworks.proxy.toys.hotswap.HotSwappingInvoker<T>
          extended by com.thoughtworks.proxy.toys.failover.FailoverInvoker<T>
All Implemented Interfaces:
Invoker, Serializable

public class FailoverInvoker<T>
extends HotSwappingInvoker<T>

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

Nested Class Summary
 
Nested classes/interfaces inherited from class com.thoughtworks.proxy.toys.hotswap.HotSwappingInvoker
HotSwappingInvoker.CycleCheck
 
Constructor Summary
FailoverInvoker(Class<?>[] types, ProxyFactory proxyFactory, T[] delegates, Class<? extends Throwable> exceptionClass)
          Construct a FailoverInvoker.
 
Method Summary
protected  Object invokeOnDelegate(Method method, Object[] args)
          Invoke the given method on the delegate.
 
Methods inherited from class com.thoughtworks.proxy.toys.hotswap.HotSwappingInvoker
delegate, hotswap, invoke, proxy
 
Methods inherited from class com.thoughtworks.proxy.toys.delegate.DelegatingInvoker
equals, getDelegateReference, getMethodToInvoke, getProxyFactory, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FailoverInvoker

public FailoverInvoker(Class<?>[] types,
                       ProxyFactory proxyFactory,
                       T[] delegates,
                       Class<? extends Throwable> exceptionClass)
Construct a FailoverInvoker.

Parameters:
types - the types of the proxy
proxyFactory - the ProxyFactory to use
delegates - the delegates to use
exceptionClass - the type of the exception
Since:
0.1
Method Detail

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<Object>
Parameters:
method - the method to invoke
args - the arguments for the invocation
Returns:
the method's result
Throws:
InvocationTargetException - if the invoked method throws any exception


Copyright © 2005-2010 Codehaus. All Rights Reserved.