Search in sources :

Example 6 with ManagedLifecycle

use of org.apache.synapse.ManagedLifecycle in project wso2-synapse by wso2.

the class LoadbalanceEndpoint method init.

@Override
public void init(SynapseEnvironment synapseEnvironment) {
    ConfigurationContext cc = ((Axis2SynapseEnvironment) synapseEnvironment).getAxis2ConfigurationContext();
    if (!initialized) {
        super.init(synapseEnvironment);
        if (algorithmContext == null) {
            algorithmContext = new AlgorithmContext(isClusteringEnabled, cc, getName());
        }
        // initlize the algorithm
        if (algorithm != null && algorithm instanceof ManagedLifecycle) {
            ManagedLifecycle lifecycle = (ManagedLifecycle) algorithm;
            lifecycle.init(synapseEnvironment);
        }
        loadBalanceEPInitialized = true;
        buildMessage = Boolean.parseBoolean(SynapsePropertiesLoader.getPropertyValue(SynapseConstants.BUILD_MESSAGE_ON_FAILOVER, "false"));
    }
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) AlgorithmContext(org.apache.synapse.endpoints.algorithms.AlgorithmContext) ManagedLifecycle(org.apache.synapse.ManagedLifecycle)

Example 7 with ManagedLifecycle

use of org.apache.synapse.ManagedLifecycle in project wso2-synapse by wso2.

the class ClassMediatorTest method testInitializationAndMedition.

public void testInitializationAndMedition() throws Exception {
    Mediator cm = MediatorFactoryFinder.getInstance().getMediator(createOMElement("<class name='org.apache.synapse.mediators.ext.ClassMediatorTestMediator' " + "xmlns='http://ws.apache.org/ns/synapse'/>"), new Properties());
    ((ManagedLifecycle) cm).init(new Axis2SynapseEnvironment(new SynapseConfiguration()));
    assertTrue(ClassMediatorTestMediator.initialized);
    TestMessageContext msgContext = new TestMessageContext();
    msgContext.setEnvironment(new Axis2SynapseEnvironment(new SynapseConfiguration()));
    cm.mediate(msgContext);
    assertTrue(ClassMediatorTestMediator.invoked);
}
Also used : Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) TestMessageContext(org.apache.synapse.TestMessageContext) Mediator(org.apache.synapse.Mediator) Properties(java.util.Properties) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) ManagedLifecycle(org.apache.synapse.ManagedLifecycle)

Example 8 with ManagedLifecycle

use of org.apache.synapse.ManagedLifecycle 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 9 with ManagedLifecycle

use of org.apache.synapse.ManagedLifecycle 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 10 with ManagedLifecycle

use of org.apache.synapse.ManagedLifecycle 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)

Aggregations

ManagedLifecycle (org.apache.synapse.ManagedLifecycle)14 Endpoint (org.apache.synapse.endpoints.Endpoint)6 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)4 SequenceMediator (org.apache.synapse.mediators.base.SequenceMediator)4 Mediator (org.apache.synapse.Mediator)3 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)3 SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)3 Properties (java.util.Properties)2 OMElement (org.apache.axiom.om.OMElement)2 TestMessageContext (org.apache.synapse.TestMessageContext)2 PriorityExecutor (org.apache.synapse.commons.executors.PriorityExecutor)2 ProxyService (org.apache.synapse.core.axis2.ProxyService)2 InboundEndpoint (org.apache.synapse.inbound.InboundEndpoint)2 Target (org.apache.synapse.mediators.eip.Target)2 TemplateMediator (org.apache.synapse.mediators.template.TemplateMediator)2 MessageProcessor (org.apache.synapse.message.processor.MessageProcessor)2 AbstractMessageProcessor (org.apache.synapse.message.processor.impl.AbstractMessageProcessor)2 MessageStore (org.apache.synapse.message.store.MessageStore)2 API (org.apache.synapse.rest.API)2 Task (org.apache.synapse.task.Task)2