use of org.apache.synapse.continuation.ReliantContinuationState in project wso2-synapse by wso2.
the class FilterMediator method mediate.
public boolean mediate(MessageContext synCtx, ContinuationState continuationState) {
SynapseLog synLog = getLog(synCtx);
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug("Filter mediator : Mediating from ContinuationState");
}
boolean result;
int subBranch = ((ReliantContinuationState) continuationState).getSubBranch();
boolean isStatisticsEnabled = RuntimeStatisticCollector.isStatisticsEnabled();
if (subBranch == 0) {
if (!continuationState.hasChild()) {
result = super.mediate(synCtx, continuationState.getPosition() + 1);
} else {
FlowContinuableMediator mediator = (FlowContinuableMediator) getChild(continuationState.getPosition());
result = mediator.mediate(synCtx, continuationState.getChildContState());
if (isStatisticsEnabled) {
((Mediator) mediator).reportCloseStatistics(synCtx, null);
}
}
} else {
if (!continuationState.hasChild()) {
result = elseMediator.mediate(synCtx, continuationState.getPosition() + 1);
} else {
FlowContinuableMediator mediator = (FlowContinuableMediator) elseMediator.getChild(continuationState.getPosition());
result = mediator.mediate(synCtx, continuationState.getChildContState());
if (isStatisticsEnabled) {
((Mediator) mediator).reportCloseStatistics(synCtx, null);
}
}
if (isStatisticsEnabled) {
elseMediator.reportCloseStatistics(synCtx, null);
}
}
return result;
}
use of org.apache.synapse.continuation.ReliantContinuationState in project wso2-synapse by wso2.
the class SwitchMediator method mediate.
public boolean mediate(MessageContext synCtx, ContinuationState continuationState) {
SynapseLog synLog = getLog(synCtx);
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug("Switch mediator : Mediating from ContinuationState");
}
boolean result;
int subBranch = ((ReliantContinuationState) continuationState).getSubBranch();
if (subBranch == 0) {
if (!continuationState.hasChild()) {
result = defaultCase.getCaseMediator().mediate(synCtx, continuationState.getPosition() + 1);
} else {
FlowContinuableMediator mediator = (FlowContinuableMediator) defaultCase.getCaseMediator().getChild(continuationState.getPosition());
result = mediator.mediate(synCtx, continuationState.getChildContState());
if (RuntimeStatisticCollector.isStatisticsEnabled()) {
((Mediator) mediator).reportCloseStatistics(synCtx, null);
}
}
} else {
if (!continuationState.hasChild()) {
result = cases.get(subBranch - 1).getCaseMediator().mediate(synCtx, continuationState.getPosition() + 1);
} else {
FlowContinuableMediator mediator = (FlowContinuableMediator) cases.get(subBranch - 1).getCaseMediator().getChild(continuationState.getPosition());
result = mediator.mediate(synCtx, continuationState.getChildContState());
if (RuntimeStatisticCollector.isStatisticsEnabled()) {
((Mediator) mediator).reportCloseStatistics(synCtx, null);
}
}
}
return result;
}
use of org.apache.synapse.continuation.ReliantContinuationState in project wso2-synapse by wso2.
the class InvokeMediator method mediate.
public boolean mediate(MessageContext synCtx, ContinuationState continuationState) {
SynapseLog synLog = getLog(synCtx);
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug("Invoke mediator : Mediating from ContinuationState");
}
boolean result;
int subBranch = ((ReliantContinuationState) continuationState).getSubBranch();
boolean isStatisticsEnabled = RuntimeStatisticCollector.isStatisticsEnabled();
if (subBranch == 0) {
// Default flow
TemplateMediator templateMediator = (TemplateMediator) synCtx.getSequenceTemplate(targetTemplate);
if (!continuationState.hasChild()) {
result = templateMediator.mediate(synCtx, continuationState.getPosition() + 1);
if (result) {
templateMediator.popFuncContextFrom(synCtx);
}
} else {
FlowContinuableMediator mediator = (FlowContinuableMediator) templateMediator.getChild(continuationState.getPosition());
result = mediator.mediate(synCtx, continuationState.getChildContState());
if (isStatisticsEnabled) {
((Mediator) mediator).reportCloseStatistics(synCtx, null);
}
}
if (isStatisticsEnabled) {
templateMediator.reportCloseStatistics(synCtx, null);
}
} else {
// Pre fetching invoke mediator flow
String prefetchInvokeKey = key.evaluateValue(synCtx);
InvokeMediator prefetchInvoke = (InvokeMediator) synCtx.getDefaultConfiguration(prefetchInvokeKey);
ContinuationState childContinuationState = continuationState.getChildContState();
result = prefetchInvoke.mediate(synCtx, childContinuationState);
if (result && !childContinuationState.hasChild()) {
// Pre fetching invoke mediator flow completed.
// Remove ContinuationState represent the prefetchInvoke mediator and
// flip the subbranch to default flow
continuationState.removeLeafChild();
((ReliantContinuationState) continuationState).setSubBranch(0);
// after prefetch invoke mediator flow, execute default flow
result = mediate(synCtx, false);
}
if (isStatisticsEnabled) {
prefetchInvoke.reportCloseStatistics(synCtx, null);
}
}
return result;
}
use of org.apache.synapse.continuation.ReliantContinuationState 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.continuation.ReliantContinuationState 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