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 voidaddCase(SwitchCase m)Adds the given mediator (Should be a SwitchCaseMediator) to the list of cases of this Switch mediatorvoiddestroy()This method should implement the destroying of the implemented parts of the configuration.List<SwitchCase>getCases()Get the list of casesSwitchCasegetDefaultCase()Get default caseSynapsePathgetSource()Return the source Path expression setvoidinit(SynapseEnvironment se)This method should implement the initialization of the implemented parts of the configuration.booleanisContentAware()booleanmediate(MessageContext synCtx)Iterate over switch cases and find match and execute selected sequencebooleanmediate(MessageContext synCtx, ContinuationState continuationState)Mediate the message using a ContinuationState.voidsetComponentStatisticsId(ArtifactHolder holder)voidsetDefaultCase(SwitchCase defaultCase)setting the default case ...which contains mediators to invoke when no case condition satisfyvoidsetSource(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:ManagedLifecycleThis method should implement the initialization of the implemented parts of the configuration.- Specified by:
initin interfaceManagedLifecycle- Parameters:
se- SynapseEnvironment to be used for initialization
-
destroy
public void destroy()
Description copied from interface:ManagedLifecycleThis method should implement the destroying of the implemented parts of the configuration.- Specified by:
destroyin 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:FlowContinuableMediatorMediate the message using a ContinuationState. This is used when mediating the response message when service is invoked using a Call Mediator.- Specified by:
mediatein 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:
isContentAwarein interfaceMediator- Overrides:
isContentAwarein classAbstractMediator
-
setComponentStatisticsId
public void setComponentStatisticsId(ArtifactHolder holder)
- Specified by:
setComponentStatisticsIdin interfaceMediator- Overrides:
setComponentStatisticsIdin classAbstractMediator
-
-