org.apache.synapse.mediators.filters
Class SwitchMediator

java.lang.Object
  extended by org.apache.synapse.mediators.AbstractMediator
      extended by org.apache.synapse.mediators.filters.SwitchMediator
All Implemented Interfaces:
AspectConfigurable, ManagedLifecycle, Mediator, SynapseArtifact

public class SwitchMediator
extends AbstractMediator
implements ManagedLifecycle

The switch mediator implements the functionality of the "switch" construct. It first evaluates the given XPath expression into a String value, and performs a match against the given list of cases. This is actually a list of sequences, and depending on the selected case, the selected sequence gets executed.


Field Summary
 
Fields inherited from class org.apache.synapse.mediators.AbstractMediator
log, trace, traceState
 
Constructor Summary
SwitchMediator()
           
 
Method Summary
 void addCase(SwitchCase m)
          Adds the given mediator (Should be a SwitchCaseMediator) to the list of cases of this Switch mediator
 void destroy()
          This method should implement the destroying of the implemented parts of the configuration.
 List<SwitchCase> getCases()
          Get the list of cases
 SwitchCase getDefaultCase()
          Get default case
 SynapseXPath getSource()
          Return the source XPath expression set
 void init(SynapseEnvironment se)
          This method should implement the initialization of the implemented parts of the configuration.
 boolean mediate(MessageContext synCtx)
          Iterate over switch cases and find match and execute selected sequence
 void setDefaultCase(SwitchCase defaultCase)
          setting the default case ...which contains mediators to invoke when no case condition satisfy
 void setSource(SynapseXPath source)
          Sets the source XPath expression
 
Methods inherited from class org.apache.synapse.mediators.AbstractMediator
auditLog, auditWarn, configure, disableStatistics, enableStatistics, getAspectConfiguration, getDescription, getLog, getTraceState, getType, handleException, handleException, isStatisticsEnable, isTraceOn, isTraceOrDebugOn, setDescription, setEffectiveTraceState, setTraceState, shouldTrace, traceOrDebug, traceOrDebugWarn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwitchMediator

public SwitchMediator()
Method Detail

init

public void init(SynapseEnvironment se)
Description copied from interface: ManagedLifecycle
This method should implement the initialization of the implemented parts of the configuration.

Specified by:
init in interface ManagedLifecycle
Parameters:
se - SynapseEnvironment to be used for initialization

destroy

public void destroy()
Description copied from interface: ManagedLifecycle
This method should implement the destroying of the implemented parts of the configuration.

Specified by:
destroy in interface ManagedLifecycle

mediate

public boolean mediate(MessageContext synCtx)
Iterate over switch cases and find match and execute selected sequence

Specified by:
mediate in interface Mediator
Parameters:
synCtx - current context
Returns:
as per standard semantics

addCase

public void addCase(SwitchCase m)
Adds the given mediator (Should be a SwitchCaseMediator) to the list of cases of this Switch mediator

Parameters:
m - the SwitchCaseMediator instance to be added

getCases

public List<SwitchCase> getCases()
Get the list of cases

Returns:
the cases list

getSource

public SynapseXPath getSource()
Return the source XPath expression set

Returns:
thje source XPath expression

setSource

public void setSource(SynapseXPath source)
Sets the source XPath expression

Parameters:
source - the XPath expression to be used as the source

getDefaultCase

public SwitchCase getDefaultCase()
Get default case

Returns:
the default csae

setDefaultCase

public void setDefaultCase(SwitchCase defaultCase)
setting the default case ...which contains mediators to invoke when no case condition satisfy

Parameters:
defaultCase - A SwitchCase instance representing default case


Copyright © 2005-2012 Apache Software Foundation. All Rights Reserved.