use of org.apache.synapse.mediators.FlowContinuableMediator in project wso2-synapse by wso2.
the class SequenceMediator method mediate.
public boolean mediate(MessageContext synCtx, ContinuationState continuationState) {
SynapseLog synLog = getLog(synCtx);
if (sequenceType == SequenceType.NAMED) {
CustomLogSetter.getInstance().setLogAppender(artifactContainerName);
}
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug("Mediating using the SeqContinuationState type : " + ((SeqContinuationState) continuationState).getSeqType() + " name : " + ((SeqContinuationState) continuationState).getSeqName());
}
boolean result;
if (!continuationState.hasChild()) {
result = super.mediate(synCtx, continuationState.getPosition() + 1);
} else {
// if children exists first mediate from them starting from grandchild.
do {
FlowContinuableMediator mediator = (FlowContinuableMediator) getChild(continuationState.getPosition());
result = mediator.mediate(synCtx, continuationState.getChildContState());
if (RuntimeStatisticCollector.isStatisticsEnabled()) {
((Mediator) mediator).reportCloseStatistics(synCtx, null);
}
if (result) {
// if flow completed remove leaf child
continuationState.removeLeafChild();
}
} while (result && continuationState.hasChild());
if (result) {
// after mediating from children, mediate from current SeqContinuationState
result = super.mediate(synCtx, continuationState.getPosition() + 1);
}
}
if (result) {
// pop the Error handler belonging to current mediator
Stack faultStack = synCtx.getFaultStack();
if (faultStack != null && !faultStack.isEmpty()) {
Object o = faultStack.peek();
if (errorHandler != null) {
Mediator errorHandlerMediator = synCtx.getSequence(errorHandler);
if (o instanceof MediatorFaultHandler && errorHandlerMediator.equals(((MediatorFaultHandler) o).getFaultMediator())) {
faultStack.pop();
}
}
}
// if flow completed, remove top ContinuationState from stack
ContinuationStackManager.popContinuationStateStack(synCtx);
}
return result;
}
use of org.apache.synapse.mediators.FlowContinuableMediator in project wso2-synapse by wso2.
the class ValidateMediator method mediate.
public boolean mediate(MessageContext synCtx, ContinuationState continuationState) {
SynapseLog synLog = getLog(synCtx);
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug("Validate mediator : Mediating from ContinuationState");
}
boolean result;
if (!continuationState.hasChild()) {
result = super.mediate(synCtx, continuationState.getPosition() + 1);
} else {
FlowContinuableMediator mediator = (FlowContinuableMediator) getChild(continuationState.getPosition());
result = mediator.mediate(synCtx, continuationState.getChildContState());
if (RuntimeStatisticCollector.isStatisticsEnabled()) {
((Mediator) mediator).reportCloseStatistics(synCtx, null);
}
}
return result;
}
use of org.apache.synapse.mediators.FlowContinuableMediator in project wso2-synapse by wso2.
the class InMediator method mediate.
public boolean mediate(MessageContext synCtx, ContinuationState continuationState) {
SynapseLog synLog = getLog(synCtx);
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug("In mediator : Mediating from ContinuationState");
}
boolean result;
if (!continuationState.hasChild()) {
result = super.mediate(synCtx, continuationState.getPosition() + 1);
} else {
FlowContinuableMediator mediator = (FlowContinuableMediator) getChild(continuationState.getPosition());
result = mediator.mediate(synCtx, continuationState.getChildContState());
if (RuntimeStatisticCollector.isStatisticsEnabled()) {
((Mediator) mediator).reportCloseStatistics(synCtx, null);
}
}
return result;
}
use of org.apache.synapse.mediators.FlowContinuableMediator in project wso2-synapse by wso2.
the class AggregateMediator method mediate.
public boolean mediate(MessageContext synCtx, ContinuationState contState) {
SynapseLog synLog = getLog(synCtx);
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug("Aggregate mediator : Mediating from ContinuationState");
}
boolean result;
SequenceMediator onCompleteSequence = getOnCompleteSequence();
boolean isStatisticsEnabled = RuntimeStatisticCollector.isStatisticsEnabled();
if (!contState.hasChild()) {
result = onCompleteSequence.mediate(synCtx, contState.getPosition() + 1);
} else {
FlowContinuableMediator mediator = (FlowContinuableMediator) onCompleteSequence.getChild(contState.getPosition());
result = mediator.mediate(synCtx, contState.getChildContState());
if (isStatisticsEnabled) {
((Mediator) mediator).reportCloseStatistics(synCtx, null);
}
}
if (isStatisticsEnabled) {
onCompleteSequence.reportCloseStatistics(synCtx, null);
}
return result;
}
use of org.apache.synapse.mediators.FlowContinuableMediator 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;
}
Aggregations