Search in sources :

Example 11 with FlowContinuableMediator

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;
}
Also used : ReliantContinuationState(org.apache.synapse.continuation.ReliantContinuationState) FlowContinuableMediator(org.apache.synapse.mediators.FlowContinuableMediator) FlowContinuableMediator(org.apache.synapse.mediators.FlowContinuableMediator) AbstractMediator(org.apache.synapse.mediators.AbstractMediator) SequenceMediator(org.apache.synapse.mediators.base.SequenceMediator)

Aggregations

FlowContinuableMediator (org.apache.synapse.mediators.FlowContinuableMediator)11 Mediator (org.apache.synapse.Mediator)10 SynapseLog (org.apache.synapse.SynapseLog)10 AbstractMediator (org.apache.synapse.mediators.AbstractMediator)6 ReliantContinuationState (org.apache.synapse.continuation.ReliantContinuationState)5 AbstractListMediator (org.apache.synapse.mediators.AbstractListMediator)5 SequenceMediator (org.apache.synapse.mediators.base.SequenceMediator)5 Stack (java.util.Stack)1 ContinuationState (org.apache.synapse.ContinuationState)1 AnonymousListMediator (org.apache.synapse.config.xml.AnonymousListMediator)1 SeqContinuationState (org.apache.synapse.continuation.SeqContinuationState)1 Endpoint (org.apache.synapse.endpoints.Endpoint)1 ListMediator (org.apache.synapse.mediators.ListMediator)1 MediatorFaultHandler (org.apache.synapse.mediators.MediatorFaultHandler)1