use of org.apache.synapse.Mediator in project wso2-synapse by wso2.
the class RespondMediatorFactory method createSpecificMediator.
@Override
protected Mediator createSpecificMediator(OMElement elem, Properties properties) {
Mediator responseMediator = new RespondMediator();
processAuditStatus(responseMediator, elem);
return responseMediator;
}
use of org.apache.synapse.Mediator in project wso2-synapse by wso2.
the class DropMediatorFactory method createSpecificMediator.
public Mediator createSpecificMediator(OMElement el, Properties properties) {
Mediator dropMediator = new DropMediator();
// after successfully creating the mediator
// set its common attributes such as tracing etc
processAuditStatus(dropMediator, el);
return dropMediator;
}
use of org.apache.synapse.Mediator in project wso2-synapse by wso2.
the class CloneMediator method mediate.
public boolean mediate(MessageContext synCtx, ContinuationState continuationState) {
SynapseLog synLog = getLog(synCtx);
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug("Clone mediator : Mediating from ContinuationState");
}
boolean result;
int subBranch = ((ReliantContinuationState) continuationState).getSubBranch();
SequenceMediator branchSequence = targets.get(subBranch).getSequence();
boolean isStatisticsEnabled = RuntimeStatisticCollector.isStatisticsEnabled();
if (!continuationState.hasChild()) {
result = branchSequence.mediate(synCtx, continuationState.getPosition() + 1);
} else {
FlowContinuableMediator mediator = (FlowContinuableMediator) branchSequence.getChild(continuationState.getPosition());
result = mediator.mediate(synCtx, continuationState.getChildContState());
if (isStatisticsEnabled) {
((Mediator) mediator).reportCloseStatistics(synCtx, null);
}
}
if (isStatisticsEnabled) {
branchSequence.reportCloseStatistics(synCtx, null);
}
return result;
}
use of org.apache.synapse.Mediator in project wso2-synapse by wso2.
the class IterateMediator method mediate.
public boolean mediate(MessageContext synCtx, ContinuationState continuationState) {
SynapseLog synLog = getLog(synCtx);
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug("Iterate mediator : Mediating from ContinuationState");
}
boolean result;
SequenceMediator branchSequence = target.getSequence();
boolean isStatisticsEnabled = RuntimeStatisticCollector.isStatisticsEnabled();
if (!continuationState.hasChild()) {
result = branchSequence.mediate(synCtx, continuationState.getPosition() + 1);
} else {
FlowContinuableMediator mediator = (FlowContinuableMediator) branchSequence.getChild(continuationState.getPosition());
result = mediator.mediate(synCtx, continuationState.getChildContState());
if (isStatisticsEnabled) {
((Mediator) mediator).reportCloseStatistics(synCtx, null);
}
}
if (isStatisticsEnabled) {
branchSequence.reportCloseStatistics(synCtx, null);
}
return result;
}
use of org.apache.synapse.Mediator in project wso2-synapse by wso2.
the class FilterMediator method mediate.
/**
* Executes the list of sub/child mediators, if the filter condition is satisfied
*
* @param synCtx the current message
* @return true if filter condition fails. else returns as per List mediator semantics
*/
public boolean mediate(MessageContext synCtx) {
if (synCtx.getEnvironment().isDebuggerEnabled()) {
if (super.divertMediationRoute(synCtx)) {
return true;
}
}
SynapseLog synLog = getLog(synCtx);
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug("Start : Filter mediator");
if (synLog.isTraceTraceEnabled()) {
synLog.traceTrace("Message : " + synCtx.getEnvelope());
}
}
boolean result = false;
if (test(synCtx)) {
if (thenKey != null) {
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug((xpath == null ? "Source : " + source + " against : " + regex.pattern() + " matches" : "XPath expression : " + xpath + " evaluates to true") + " - executing then sequence with key : " + thenKey);
}
ContinuationStackManager.updateSeqContinuationState(synCtx, getMediatorPosition());
Mediator seq = synCtx.getSequence(thenKey);
if (seq != null) {
result = seq.mediate(synCtx);
} else {
handleException("Couldn't find the referred then sequence with key : " + thenKey, synCtx);
}
} else {
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug((xpath == null ? "Source : " + source + " against : " + regex.pattern() + " matches" : "XPath expression : " + xpath + " evaluates to true") + " - executing child mediators");
}
ContinuationStackManager.addReliantContinuationState(synCtx, 0, getMediatorPosition());
result = super.mediate(synCtx);
if (result) {
ContinuationStackManager.removeReliantContinuationState(synCtx);
}
}
} else {
if (elseKey != null) {
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug((xpath == null ? "Source : " + source + " against : " + regex.pattern() + " does not match" : "XPath expression : " + xpath + " evaluates to false") + " - executing the else sequence with key : " + elseKey);
}
ContinuationStackManager.updateSeqContinuationState(synCtx, getMediatorPosition());
Mediator elseSeq = synCtx.getSequence(elseKey);
if (elseSeq != null) {
result = elseSeq.mediate(synCtx);
} else {
handleException("Couldn't find the referred else sequence with key : " + elseKey, synCtx);
}
} else if (elseMediator != null) {
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug((xpath == null ? "Source : " + source + " against : " + regex.pattern() + " does not match" : "XPath expression : " + xpath + " evaluates to false") + " - executing the else path child mediators");
}
ContinuationStackManager.addReliantContinuationState(synCtx, 1, getMediatorPosition());
result = elseMediator.mediate(synCtx);
if (result) {
ContinuationStackManager.removeReliantContinuationState(synCtx);
}
} else {
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug((xpath == null ? "Source : " + source + " against : " + regex.pattern() + " does not match" : "XPath expression : " + xpath + " evaluates to false and no else path") + " - skipping child mediators");
}
result = true;
}
}
synLog.traceOrDebug("End : Filter mediator ");
return result;
}
Aggregations