Search in sources :

Example 36 with SequenceMediator

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();
        }
    }
}
Also used : Target(org.apache.synapse.mediators.eip.Target) Endpoint(org.apache.synapse.endpoints.Endpoint) SequenceMediator(org.apache.synapse.mediators.base.SequenceMediator) ManagedLifecycle(org.apache.synapse.ManagedLifecycle)

Example 37 with SequenceMediator

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

Example 38 with SequenceMediator

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());
            }
        }
    }
}
Also used : Endpoint(org.apache.synapse.endpoints.Endpoint) SequenceMediator(org.apache.synapse.mediators.base.SequenceMediator) ManagedLifecycle(org.apache.synapse.ManagedLifecycle)

Example 39 with SequenceMediator

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());
            }
        }
    }
}
Also used : Endpoint(org.apache.synapse.endpoints.Endpoint) SequenceMediator(org.apache.synapse.mediators.base.SequenceMediator) ManagedLifecycle(org.apache.synapse.ManagedLifecycle)

Example 40 with SequenceMediator

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

Aggregations

SequenceMediator (org.apache.synapse.mediators.base.SequenceMediator)70 TestMediator (org.apache.synapse.mediators.TestMediator)18 OMElement (org.apache.axiom.om.OMElement)12 ProxyService (org.apache.synapse.core.axis2.ProxyService)12 Endpoint (org.apache.synapse.endpoints.Endpoint)12 Mediator (org.apache.synapse.Mediator)11 AbstractMediator (org.apache.synapse.mediators.AbstractMediator)11 MessageContext (org.apache.synapse.MessageContext)9 TemplateMediator (org.apache.synapse.mediators.template.TemplateMediator)8 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)7 InboundEndpoint (org.apache.synapse.inbound.InboundEndpoint)7 OMAttribute (org.apache.axiom.om.OMAttribute)6 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)6 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)6 File (java.io.File)4 ManagedLifecycle (org.apache.synapse.ManagedLifecycle)4 SynapseException (org.apache.synapse.SynapseException)4 SynapseLog (org.apache.synapse.SynapseLog)4 QName (javax.xml.namespace.QName)3 OMNode (org.apache.axiom.om.OMNode)3