use of org.apache.synapse.mediators.base.SequenceMediator in project wso2-synapse by wso2.
the class CloneMediator method destroy.
public void destroy() {
for (Target target : targets) {
ManagedLifecycle seq = target.getSequence();
if (seq != null) {
seq.destroy();
} else if (target.getSequenceRef() != null) {
SequenceMediator targetSequence = (SequenceMediator) synapseEnv.getSynapseConfiguration().getSequence(target.getSequenceRef());
if (targetSequence == null || targetSequence.isDynamic()) {
synapseEnv.removeUnavailableArtifactRef(target.getSequenceRef());
}
}
Endpoint endpoint = target.getEndpoint();
if (endpoint != null) {
endpoint.destroy();
}
}
}
use of org.apache.synapse.mediators.base.SequenceMediator 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.mediators.base.SequenceMediator in project wso2-synapse by wso2.
the class IterateMediator method init.
public void init(SynapseEnvironment se) {
synapseEnv = se;
if (target != null) {
Endpoint endpoint = target.getEndpoint();
if (endpoint != null) {
endpoint.init(se);
}
ManagedLifecycle seq = target.getSequence();
if (seq != null) {
seq.init(se);
} else if (target.getSequenceRef() != null) {
SequenceMediator targetSequence = (SequenceMediator) se.getSynapseConfiguration().getSequence(target.getSequenceRef());
if (targetSequence == null || targetSequence.isDynamic()) {
se.addUnavailableArtifactRef(target.getSequenceRef());
}
}
}
}
use of org.apache.synapse.mediators.base.SequenceMediator in project wso2-synapse by wso2.
the class IterateMediator method destroy.
public void destroy() {
if (target != null) {
Endpoint endpoint = target.getEndpoint();
if (endpoint != null && endpoint.isInitialized()) {
endpoint.destroy();
}
ManagedLifecycle seq = target.getSequence();
if (seq != null) {
seq.destroy();
} else if (target.getSequenceRef() != null) {
SequenceMediator targetSequence = (SequenceMediator) synapseEnv.getSynapseConfiguration().getSequence(target.getSequenceRef());
if (targetSequence == null || targetSequence.isDynamic()) {
synapseEnv.removeUnavailableArtifactRef(target.getSequenceRef());
}
}
}
}
use of org.apache.synapse.mediators.base.SequenceMediator 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;
}
Aggregations