use of org.apache.synapse.mediators.FlowContinuableMediator in project wso2-synapse by wso2.
the class ThrottleMediator method mediate.
public boolean mediate(MessageContext synCtx, ContinuationState continuationState) {
SynapseLog synLog = getLog(synCtx);
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug("Throttle mediator : Mediating from ContinuationState");
}
boolean result;
boolean isStatisticsEnabled = RuntimeStatisticCollector.isStatisticsEnabled();
int subBranch = ((ReliantContinuationState) continuationState).getSubBranch();
if (subBranch == 0) {
if (!continuationState.hasChild()) {
result = ((SequenceMediator) onAcceptMediator).mediate(synCtx, continuationState.getPosition() + 1);
} else {
FlowContinuableMediator mediator = (FlowContinuableMediator) ((SequenceMediator) onAcceptMediator).getChild(continuationState.getPosition());
result = mediator.mediate(synCtx, continuationState.getChildContState());
if (isStatisticsEnabled) {
((Mediator) mediator).reportCloseStatistics(synCtx, null);
}
}
if (isStatisticsEnabled) {
onAcceptMediator.reportCloseStatistics(synCtx, null);
}
} else {
if (!continuationState.hasChild()) {
result = ((SequenceMediator) onRejectMediator).mediate(synCtx, continuationState.getPosition() + 1);
} else {
FlowContinuableMediator mediator = (FlowContinuableMediator) ((SequenceMediator) onRejectMediator).getChild(continuationState.getPosition());
result = mediator.mediate(synCtx, continuationState.getChildContState());
if (isStatisticsEnabled) {
((Mediator) mediator).reportCloseStatistics(synCtx, null);
}
}
if (isStatisticsEnabled) {
onRejectMediator.reportCloseStatistics(synCtx, null);
}
}
return result;
}
Aggregations