org.ow2.cmi.lb.policy
Interface IPolicy<T extends LoadBalanceable>

Type Parameters:
T - The type of object that was load-balanced

public interface IPolicy<T extends LoadBalanceable>

Interface of the policies for load-balancing.

Author:
The new CMI team

Method Summary
 T choose(java.util.Collection<T> loadBalanceables)
          Chooses a load-balanceable among the list of load-balanceables.
 IStrategy<T> getStrategy()
          Return a strategy to modify the behavior of this policy.
<ReturnType>
DecisionManager<ReturnType>
onChoose(java.lang.reflect.Method method, java.lang.Object[] parameters, ReturnType chosenValue)
          Return a decision when a server is chosen and its delegate retrieved.
 DecisionManager<java.lang.Void> onInvokeException(java.lang.reflect.Method method, java.lang.Object[] parameters, T loadBalanceable, java.lang.Throwable thr)
          Returns a decision when an exception is thrown during an invocation for a given load-balanceable.
 DecisionManager<java.lang.Void> onLookupException(T loadBalanceable, java.lang.Throwable thr)
          Returns a decision when an exception is thrown during an access to a registry for a given load-balanceable.
<ReturnType>
DecisionManager<ReturnType>
onReturn(java.lang.reflect.Method method, java.lang.Object[] parameters, T loadBalanceable, ReturnType retVal)
          Returns a decision when the invocation of a remote method ends.
 void setStrategy(IStrategy<T> strategy)
          Sets a strategy to modify the behavior of this policy.
 

Method Detail

choose

T choose(java.util.Collection<T> loadBalanceables)
                                 throws NoLoadBalanceableException
Chooses a load-balanceable among the list of load-balanceables.

Parameters:
loadBalanceables - a list of load-balanceables
Returns:
the chosen load-balanceable
Throws:
NoLoadBalanceableException - if no server is available

getStrategy

IStrategy<T> getStrategy()
Return a strategy to modify the behavior of this policy.

Returns:
a strategy to modify the behavior of this policy

setStrategy

void setStrategy(IStrategy<T> strategy)
Sets a strategy to modify the behavior of this policy.

Parameters:
strategy - a strategy of load-balancing

onLookupException

DecisionManager<java.lang.Void> onLookupException(T loadBalanceable,
                                                  java.lang.Throwable thr)
Returns a decision when an exception is thrown during an access to a registry for a given load-balanceable.

Parameters:
loadBalanceable - the load-balanceable that have caused the exception
thr - the exception that is thrown
Returns:
the decision when an exception is thrown during an access to a registry for a given load-balanceable

onInvokeException

DecisionManager<java.lang.Void> onInvokeException(java.lang.reflect.Method method,
                                                  java.lang.Object[] parameters,
                                                  T loadBalanceable,
                                                  java.lang.Throwable thr)
Returns a decision when an exception is thrown during an invocation for a given load-balanceable.

Parameters:
method - the method that was invoked
parameters - the parameters of the method
loadBalanceable - the load-balanceable that have caused the exception
thr - the exception that is thrown
Returns:
the decision when an exception is thrown during an invocation for a given load-balanceable

onChoose

<ReturnType> DecisionManager<ReturnType> onChoose(java.lang.reflect.Method method,
                                                  java.lang.Object[] parameters,
                                                  ReturnType chosenValue)
Return a decision when a server is chosen and its delegate retrieved.

Type Parameters:
ReturnType - the type of delegate
Parameters:
method - the method that was invoked
parameters - the parameters of the method
chosenValue - the delegate of chosen server
Returns:
the decision when the server is chosen and its delegate retrieved

onReturn

<ReturnType> DecisionManager<ReturnType> onReturn(java.lang.reflect.Method method,
                                                  java.lang.Object[] parameters,
                                                  T loadBalanceable,
                                                  ReturnType retVal)
Returns a decision when the invocation of a remote method ends.

Type Parameters:
ReturnType - the type of the returned value
Parameters:
method - the method that was invoked
parameters - the parameters of the method
loadBalanceable - the load-balanceable used for the invocation
retVal - the returned value
Returns:
the decision when the invocation of a remote method ends


Copyright © 2009 OW2 Consortium. All Rights Reserved.