Class SwitchMediator
- java.lang.Object
-
- org.apache.synapse.mediators.AbstractMediator
-
- org.apache.synapse.mediators.filters.SwitchMediator
-
- All Implemented Interfaces:
AspectConfigurable
,ManagedLifecycle
,Mediator
,FlowContinuableMediator
,SynapseArtifact
public class SwitchMediator extends AbstractMediator implements ManagedLifecycle, FlowContinuableMediator
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
Constructors Constructor Description SwitchMediator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCase(SwitchCase m)
Adds the given mediator (Should be a SwitchCaseMediator) to the list of cases of this Switch mediatorvoid
destroy()
This method should implement the destroying of the implemented parts of the configuration.List<SwitchCase>
getCases()
Get the list of casesSwitchCase
getDefaultCase()
Get default caseSynapsePath
getSource()
Return the source Path expression setvoid
init(SynapseEnvironment se)
This method should implement the initialization of the implemented parts of the configuration.boolean
isContentAware()
boolean
mediate(MessageContext synCtx)
Iterate over switch cases and find match and execute selected sequenceboolean
mediate(MessageContext synCtx, ContinuationState continuationState)
Mediate the message using a ContinuationState.void
setComponentStatisticsId(ArtifactHolder holder)
void
setDefaultCase(SwitchCase defaultCase)
setting the default case ...which contains mediators to invoke when no case condition satisfyvoid
setSource(SynapsePath source)
Sets the source Path expression-
Methods inherited from class org.apache.synapse.mediators.AbstractMediator
auditLog, auditWarn, configure, disableStatistics, disableTracing, divertMediationRoute, enableStatistics, enableTracing, getAspectConfiguration, getCommentsList, getDescription, getInputType, getLastSequenceFaultHandler, getLog, getMediatorName, getMediatorPosition, getOutputType, getRegisteredMediationFlowPoint, getShortDescription, getTraceState, getType, handleException, handleException, isBreakPoint, isContentAltering, isSkipEnabled, isStatisticsEnable, isTraceOn, isTraceOrDebugOn, isTracingEnabled, registerMediationFlowPoint, reportCloseStatistics, reportOpenStatistics, setBreakPoint, setCommentsList, setDescription, setEffectiveTraceState, setMediatorPosition, setShortDescription, setSkipEnabled, setTraceState, shouldCaptureTracing, shouldTrace, shouldTrace, traceOrDebug, traceOrDebugWarn, unregisterMediationFlowPoint
-
-
-
-
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 interfaceManagedLifecycle
- 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 interfaceManagedLifecycle
-
mediate
public boolean mediate(MessageContext synCtx)
Iterate over switch cases and find match and execute selected sequence
-
mediate
public boolean mediate(MessageContext synCtx, ContinuationState continuationState)
Description copied from interface:FlowContinuableMediator
Mediate the message using a ContinuationState. This is used when mediating the response message when service is invoked using a Call Mediator.- Specified by:
mediate
in interfaceFlowContinuableMediator
- Parameters:
synCtx
- MessageContextcontinuationState
- ContinuationState- Returns:
- whether mediation flow is completed
-
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 SynapsePath getSource()
Return the source Path expression set- Returns:
- thje source Path expression
-
setSource
public void setSource(SynapsePath source)
Sets the source Path expression- Parameters:
source
- the Path expression to be used as the source
-
getDefaultCase
public SwitchCase getDefaultCase()
Get default case- Returns:
- the default case
-
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
-
isContentAware
public boolean isContentAware()
- Specified by:
isContentAware
in interfaceMediator
- Overrides:
isContentAware
in classAbstractMediator
-
setComponentStatisticsId
public void setComponentStatisticsId(ArtifactHolder holder)
- Specified by:
setComponentStatisticsId
in interfaceMediator
- Overrides:
setComponentStatisticsId
in classAbstractMediator
-
-