use of org.apache.synapse.mediators.template.TemplateMediator in project wso2-synapse by wso2.
the class SynapseConfiguration method destroy.
public synchronized void destroy(boolean preserverState) {
if (log.isDebugEnabled()) {
log.debug("Destroying the Synapse Configuration");
}
// clear the timer tasks of Synapse
synapseTimer.cancel();
synapseTimer = null;
// stop and shutdown all the proxy services
for (ProxyService p : getProxyServices()) {
if (p.getTargetInLineInSequence() != null) {
p.getTargetInLineInSequence().destroy();
}
if (p.getTargetInLineOutSequence() != null) {
p.getTargetInLineOutSequence().destroy();
}
}
// destroy the managed mediators
for (ManagedLifecycle seq : getDefinedSequences().values()) {
seq.destroy();
}
// destroy sequence templates
for (TemplateMediator seqTemplate : getSequenceTemplates().values()) {
seqTemplate.destroy();
}
// destroy inbound endpoint
for (InboundEndpoint endpoint : getInboundEndpoints()) {
// This path trigger from server shutdown hook. So we don't want to remove scheduled inbound tasks
// from registry. Only un-deployment should remove task from registry. Ref product-ei#1206
endpoint.destroy(false);
}
// destroy the managed endpoints
for (Endpoint endpoint : getDefinedEndpoints().values()) {
endpoint.destroy();
}
// destroy the startups
for (ManagedLifecycle stp : startups.values()) {
stp.destroy();
}
// clear session information used for SA load balancing
try {
SALSessions.getInstance().reset();
DataSourceRepositoryHolder.getInstance().getDataSourceRepositoryManager().clear();
} catch (Throwable ignored) {
}
// destroy the priority executors.
for (PriorityExecutor pe : executors.values()) {
pe.destroy();
}
// destroy the Message Stores
for (MessageStore ms : messageStores.values()) {
if (ms instanceof AbstractMessageProcessor) {
((AbstractMessageProcessor) ms).destroy(preserverState);
} else {
ms.destroy();
}
}
// destroy the Message processors
for (MessageProcessor mp : messageProcessors.values()) {
mp.destroy();
}
for (API api : apiTable.values()) {
api.destroy();
}
}
use of org.apache.synapse.mediators.template.TemplateMediator in project wso2-synapse by wso2.
the class LibraryArtifact method loadComponentsInto.
public void loadComponentsInto(SynapseLibrary library) {
for (String artifactName : subArtifacts.keySet()) {
LibraryArtifact artifact = subArtifacts.get(artifactName);
if (artifact.isLeafArtifact()) {
delegateClassLoading(artifact, library);
// this is where actual artifact is constructed to it's ture form
Object template = artifact.file.build();
if (artifact.file instanceof TemplateArtifactFile) {
if (template instanceof TemplateMediator) {
TemplateMediator templateMediator = (TemplateMediator) template;
// make template dynamic as it is not directly available to synapse environment
templateMediator.setDynamic(true);
String templateName = templateMediator.getName();
library.addComponent(getQualifiedName(library.getPackage(), templateName, library.getQName().getLocalPart()), template);
} else if (template instanceof Template) {
String templateName = ((Template) template).getName();
library.addComponent(getQualifiedName(library.getPackage(), templateName, library.getQName().getLocalPart()), template);
} else if (template != null) {
library.addComponent(getQualifiedName(library.getPackage(), artifact.getName(), library.getQName().getLocalPart()), template);
} else {
throw new SynapseArtifactDeploymentException("Cannot load components into " + "Synapse Library. Component " + "cannot be built for " + artifactName);
}
}
} else {
artifact.loadComponentsInto(library);
}
}
}
use of org.apache.synapse.mediators.template.TemplateMediator in project wso2-synapse by wso2.
the class DebugManagerTest method testDebugManagerProcessCommandClearBreakPointTemplate.
public void testDebugManagerProcessCommandClearBreakPointTemplate() throws Exception {
TestMediator t1 = new TestMediator();
TestMediator t2 = new TestMediator();
TestMediator t3 = new TestMediator();
TemplateMediator temp = new TemplateMediator();
temp.addChild(t1);
temp.addChild(t2);
temp.addChild(t3);
temp.setName("test_sequence_template_2");
synConfig.addSequenceTemplate(temp.getName(), temp);
String debug_command = "{\"command\":\"set\",\"command-argument\":\"breakpoint\"," + "\"mediation-component\":\"template\",\"template\":{\"template-key\":\"test_sequence_template_2\"," + "\"mediator-position\": \"0\"}}";
dm.processDebugCommand(debug_command);
debug_command = "{\"command\":\"clear\",\"command-argument\":\"breakpoint\"," + "\"mediation-component\":\"template\",\"template\":{\"template-key\":\"test_sequence_template_2\"," + "\"mediator-position\": \"0\"}}";
dm.processDebugCommand(debug_command);
assertTrue(!((AbstractMediator) temp.getChild(0)).isBreakPoint());
}
use of org.apache.synapse.mediators.template.TemplateMediator in project wso2-synapse by wso2.
the class DebugManagerTest method testSkipTemplate.
public void testSkipTemplate() throws Exception {
TestMediator t1 = new TestMediator();
t1.setHandler(new TestMediateHandler() {
public void handle(MessageContext synCtx) {
result.append("T1.");
}
});
TestMediator t2 = new TestMediator();
t2.setHandler(new TestMediateHandler() {
public void handle(MessageContext synCtx) {
result.append("T2.");
}
});
TestMediator t3 = new TestMediator();
t3.setHandler(new TestMediateHandler() {
public void handle(MessageContext synCtx) {
result.append("T3");
}
});
TemplateMediator temp = new TemplateMediator();
temp.addChild(t1);
temp.addChild(t2);
temp.addChild(t3);
temp.setName("test_sequence_template_5");
temp.setParameters(new HashSet<String>());
synConfig.addSequenceTemplate(temp.getName(), temp);
String debug_command = "{\"command\":\"set\",\"command-argument\":\"skip\",\"mediation-component\":\"template\"," + "\"template\":{\"template-key\":\"test_sequence_template_5\",\"mediator-position\": \"0\"}}";
dm.processDebugCommand(debug_command);
debug_command = "{\"command\":\"set\",\"command-argument\":\"skip\",\"mediation-component\":\"template\"," + "\"template\":{\"template-key\":\"test_sequence_template_5\",\"mediator-position\": \"1\"}}";
dm.processDebugCommand(debug_command);
synEnv.setDebugEnabled(true);
MessageContextCreatorForAxis2.setSynConfig(synConfig);
MessageContextCreatorForAxis2.setSynEnv(synEnv);
org.apache.axis2.context.MessageContext mc = new org.apache.axis2.context.MessageContext();
AxisConfiguration axisConfig = synConfig.getAxisConfiguration();
if (axisConfig == null) {
axisConfig = new AxisConfiguration();
synConfig.setAxisConfiguration(axisConfig);
}
ConfigurationContext cfgCtx = new ConfigurationContext(axisConfig);
mc.setConfigurationContext(cfgCtx);
mc.setEnvelope(TestUtils.getTestContext("<empty/>").getEnvelope());
MessageContext synCtx = MessageContextCreatorForAxis2.getSynapseMessageContext(mc);
temp.mediate(synCtx);
assertTrue("T3".equals(result.toString()));
synEnv.setDebugEnabled(false);
}
Aggregations