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"));
}
}
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);
}
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();
}
}
}
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());
}
}
}
}
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());
}
}
}
}
Aggregations