Apache CXF API

org.apache.cxf.clustering
Class FailoverTargetSelector

java.lang.Object
  extended by org.apache.cxf.endpoint.AbstractConduitSelector
      extended by org.apache.cxf.clustering.FailoverTargetSelector
All Implemented Interfaces:
Closeable, ConduitSelector
Direct Known Subclasses:
LoadDistributorTargetSelector

public class FailoverTargetSelector
extends AbstractConduitSelector

Implements a target selection strategy based on failover to an alternate target endpoint when a transport level failure is encountered. Note that this feature changes the conduit on the fly and thus makes the Client not thread safe.


Nested Class Summary
protected  class FailoverTargetSelector.InvocationContext
          Records the context of an invocation.
protected static class FailoverTargetSelector.InvocationKey
          Used to wrap an Exchange for usage as a Map key.
 
Field Summary
protected  FailoverStrategy failoverStrategy
           
protected  Map<FailoverTargetSelector.InvocationKey,FailoverTargetSelector.InvocationContext> inProgress
           
 
Fields inherited from class org.apache.cxf.endpoint.AbstractConduitSelector
endpoint, KEEP_CONDUIT_ALIVE, selectedConduit
 
Constructor Summary
FailoverTargetSelector()
          Normal constructor.
FailoverTargetSelector(Conduit c)
          Constructor, allowing a specific conduit to override normal selection.
 
Method Summary
 void complete(Exchange exchange)
          Called on completion of the MEP for which the Conduit was required.
protected  long getDelayBetweenRetries()
          Returns delay (in milliseconds) between retries
protected  Endpoint getFailoverTarget(Exchange exchange, FailoverTargetSelector.InvocationContext invocation)
          Get the failover target endpoint, if a suitable one is available.
protected  Logger getLogger()
           
 FailoverStrategy getStrategy()
           
protected  void overrideAddressProperty(Map<String,Object> context)
          Override the ENDPOINT_ADDRESS property in the request context
 void prepare(Message message)
          Called prior to the interceptor chain being traversed.
protected  boolean requiresFailover(Exchange exchange)
          Check if the exchange is suitable for a failover.
 Conduit selectConduit(Message message)
          Called when a Conduit is actually required.
 void setStrategy(FailoverStrategy strategy)
           
 
Methods inherited from class org.apache.cxf.endpoint.AbstractConduitSelector
close, getEndpoint, getSelectedConduit, replaceEndpointAddressPropertyIfNeeded, setEndpoint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inProgress

protected Map<FailoverTargetSelector.InvocationKey,FailoverTargetSelector.InvocationContext> inProgress

failoverStrategy

protected FailoverStrategy failoverStrategy
Constructor Detail

FailoverTargetSelector

public FailoverTargetSelector()
Normal constructor.


FailoverTargetSelector

public FailoverTargetSelector(Conduit c)
Constructor, allowing a specific conduit to override normal selection.

Parameters:
c - specific conduit
Method Detail

prepare

public void prepare(Message message)
Called prior to the interceptor chain being traversed.

Parameters:
message - the current Message

selectConduit

public Conduit selectConduit(Message message)
Called when a Conduit is actually required.

Parameters:
message -
Returns:
the Conduit to use for mediation of the message

complete

public void complete(Exchange exchange)
Called on completion of the MEP for which the Conduit was required.

Specified by:
complete in interface ConduitSelector
Overrides:
complete in class AbstractConduitSelector
Parameters:
exchange - represents the completed MEP

setStrategy

public void setStrategy(FailoverStrategy strategy)
Parameters:
strategy - the FailoverStrategy to use

getStrategy

public FailoverStrategy getStrategy()
Returns:
strategy the FailoverStrategy to use

getLogger

protected Logger getLogger()
Specified by:
getLogger in class AbstractConduitSelector
Returns:
the logger to use

getDelayBetweenRetries

protected long getDelayBetweenRetries()
Returns delay (in milliseconds) between retries

Returns:
delay, 0 means no delay

requiresFailover

protected boolean requiresFailover(Exchange exchange)
Check if the exchange is suitable for a failover.

Parameters:
exchange - the current Exchange
Returns:
boolean true if a failover should be attempted

getFailoverTarget

protected Endpoint getFailoverTarget(Exchange exchange,
                                     FailoverTargetSelector.InvocationContext invocation)
Get the failover target endpoint, if a suitable one is available.

Parameters:
exchange - the current Exchange
invocation - the current InvocationContext
Returns:
a failover endpoint if one is available

overrideAddressProperty

protected void overrideAddressProperty(Map<String,Object> context)
Override the ENDPOINT_ADDRESS property in the request context

Parameters:
context - the request context

Apache CXF API

Apache CXF