Class FilterMediator
- java.lang.Object
-
- org.apache.synapse.mediators.AbstractMediator
-
- org.apache.synapse.mediators.AbstractListMediator
-
- org.apache.synapse.mediators.filters.FilterMediator
-
- All Implemented Interfaces:
AspectConfigurable
,ManagedLifecycle
,Mediator
,FilterMediator
,FlowContinuableMediator
,ListMediator
,SynapseArtifact
public class FilterMediator extends AbstractListMediator implements FilterMediator, FlowContinuableMediator
The filter mediator combines the regex and xpath filtering functionality. If an xpath is set, it is evaluated; else the given regex is evaluated against the source xpath.
-
-
Field Summary
-
Fields inherited from class org.apache.synapse.mediators.AbstractListMediator
mediators, msgBuildFailureExpattern
-
Fields inherited from class org.apache.synapse.mediators.AbstractMediator
log, trace, traceState
-
-
Constructor Summary
Constructors Constructor Description FilterMediator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
Destroy child mediators recursivelyString
getElseKey()
ListMediator
getElseMediator()
Pattern
getRegex()
SynapsePath
getSource()
String
getThenKey()
SynapsePath
getXpath()
void
init(SynapseEnvironment se)
Initialize child mediators recursivelyboolean
isContentAware()
boolean
isThenElementPresent()
boolean
mediate(MessageContext synCtx)
Executes the list of sub/child mediators, if the filter condition is satisfiedboolean
mediate(MessageContext synCtx, ContinuationState continuationState)
Mediate the message using a ContinuationState.void
setComponentStatisticsId(ArtifactHolder holder)
void
setElseKey(String elseKey)
void
setElseMediator(AnonymousListMediator elseMediator)
void
setRegex(Pattern regex)
void
setSource(SynapsePath source)
void
setThenElementPresent(boolean thenElementPresent)
void
setThenKey(String thenKey)
void
setXpath(SynapsePath xpath)
boolean
test(MessageContext synCtx)
Tests the supplied condition after evaluation against the given XPath or Regex (against a source XPath).-
Methods inherited from class org.apache.synapse.mediators.AbstractListMediator
addAll, addChild, addChild, getChild, getList, mediate, removeChild, removeChild, setStatisticIdForMediators
-
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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.synapse.mediators.ListMediator
addAll, addChild, getChild, getList, removeChild, removeChild
-
Methods inherited from interface org.apache.synapse.Mediator
getMediatorName, getMediatorPosition, getShortDescription, getTraceState, getType, isContentAltering, reportCloseStatistics, reportOpenStatistics, setMediatorPosition, setShortDescription, setTraceState
-
Methods inherited from interface org.apache.synapse.SynapseArtifact
getDescription, setDescription
-
-
-
-
Method Detail
-
init
public void init(SynapseEnvironment se)
Description copied from class:AbstractListMediator
Initialize child mediators recursively- Specified by:
init
in interfaceManagedLifecycle
- Overrides:
init
in classAbstractListMediator
- Parameters:
se
- synapse environment
-
destroy
public void destroy()
Description copied from class:AbstractListMediator
Destroy child mediators recursively- Specified by:
destroy
in interfaceManagedLifecycle
- Overrides:
destroy
in classAbstractListMediator
-
mediate
public boolean mediate(MessageContext synCtx)
Executes the list of sub/child mediators, if the filter condition is satisfied- Specified by:
mediate
in interfaceMediator
- Overrides:
mediate
in classAbstractListMediator
- Parameters:
synCtx
- the current message- Returns:
- true if filter condition fails. else returns as per List mediator semantics
-
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
-
test
public boolean test(MessageContext synCtx)
Tests the supplied condition after evaluation against the given XPath or Regex (against a source XPath). When a regular expression is supplied the source XPath is evaluated into a String value, and matched against the given regex- Specified by:
test
in interfaceFilterMediator
- Parameters:
synCtx
- the current message for evaluation of the test condition- Returns:
- true if evaluation of the XPath/Regex results in true
-
getSource
public SynapsePath getSource()
-
setSource
public void setSource(SynapsePath source)
-
getRegex
public Pattern getRegex()
-
setRegex
public void setRegex(Pattern regex)
-
getXpath
public SynapsePath getXpath()
-
setXpath
public void setXpath(SynapsePath xpath)
-
getElseMediator
public ListMediator getElseMediator()
-
setElseMediator
public void setElseMediator(AnonymousListMediator elseMediator)
-
isThenElementPresent
public boolean isThenElementPresent()
-
setThenElementPresent
public void setThenElementPresent(boolean thenElementPresent)
-
getThenKey
public String getThenKey()
-
setThenKey
public void setThenKey(String thenKey)
-
getElseKey
public String getElseKey()
-
setElseKey
public void setElseKey(String elseKey)
-
isContentAware
public boolean isContentAware()
- Specified by:
isContentAware
in interfaceMediator
- Overrides:
isContentAware
in classAbstractListMediator
-
setComponentStatisticsId
public void setComponentStatisticsId(ArtifactHolder holder)
- Specified by:
setComponentStatisticsId
in interfaceMediator
- Overrides:
setComponentStatisticsId
in classAbstractMediator
-
-