use of org.apache.synapse.Startup in project wso2-synapse by wso2.
the class TaskDeployer method deploySynapseArtifact.
@Override
public String deploySynapseArtifact(OMElement artifactConfig, String fileName, Properties properties) {
if (log.isDebugEnabled()) {
log.debug("StartupTask Deployment from file : " + fileName + " : Started");
}
try {
Startup st = StartupFinder.getInstance().getStartup(artifactConfig, properties);
st.setFileName((new File(fileName)).getName());
/**
* Set the name of the artifact container from which the task deployed
*/
st.setArtifactContainerName(customLogContent);
if (log.isDebugEnabled()) {
log.debug("StartupTask named '" + st.getName() + "' has been built from the file " + fileName);
}
st.init(getSynapseEnvironment());
if (log.isDebugEnabled()) {
log.debug("Initialized the StartupTask : " + st.getName());
}
getSynapseConfiguration().addStartup(st);
if (log.isDebugEnabled()) {
log.debug("StartupTask Deployment from file : " + fileName + " : Completed");
}
log.info("StartupTask named '" + st.getName() + "' has been deployed from file : " + fileName);
return st.getName();
} catch (Exception e) {
handleSynapseArtifactDeploymentError("StartupTask Deployment from the file : " + fileName + " : Failed.", e);
}
return null;
}
use of org.apache.synapse.Startup in project wso2-synapse by wso2.
the class TaskDeployer method undeploySynapseArtifact.
@Override
public void undeploySynapseArtifact(String artifactName) {
if (log.isDebugEnabled()) {
log.debug("StartupTask Undeployment of the task named : " + artifactName + " : Started");
}
try {
Startup st = getSynapseConfiguration().getStartup(artifactName);
if (st != null) {
getSynapseConfiguration().removeStartup(artifactName);
if (log.isDebugEnabled()) {
log.debug("Destroying the StartupTask named : " + artifactName);
}
st.destroy();
if (log.isDebugEnabled()) {
log.debug("StartupTask Undeployment of the sequence named : " + artifactName + " : Completed");
}
log.info("StartupTask named '" + st.getName() + "' has been undeployed");
} else if (log.isDebugEnabled()) {
log.debug("Startup task " + artifactName + " has already been undeployed");
}
} catch (Exception e) {
handleSynapseArtifactDeploymentError("StartupTask Undeployement of task named : " + artifactName + " : Failed", e);
}
}
use of org.apache.synapse.Startup in project wso2-synapse by wso2.
the class StartupSerializationTest method testStartupSerializationSenarioTwo.
public void testStartupSerializationSenarioTwo() throws Exception {
String inputXml = "<task class=\"org.apache.synapse.util.TestTask\" group=\"org\" " + "name=\"TestTask\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "<description>Test description</description>" + "<property name=\"name\" value=\"foo\"/>" + "<trigger interval=\"5\"/></task>";
OMElement inputOM = createOMElement(inputXml);
Startup startup = StartupFinder.getInstance().getStartup(inputOM, new Properties());
OMElement resultOM = StartupFinder.getInstance().serializeStartup(null, startup);
assertTrue(compare(resultOM, inputOM));
}
use of org.apache.synapse.Startup in project wso2-synapse by wso2.
the class StartupSerializationTest method testStartupSerializationSenarioOne.
public void testStartupSerializationSenarioOne() throws Exception {
String inputXml = "<task class=\"org.apache.synapse.util.TestTask\" group=\"org\" " + "name=\"TestTask\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "<property name=\"name\" value=\"foo\"/>" + "<trigger interval=\"5\"/></task>";
OMElement inputOM = createOMElement(inputXml);
Startup startup = StartupFinder.getInstance().getStartup(inputOM, new Properties());
OMElement resultOM = StartupFinder.getInstance().serializeStartup(null, startup);
assertTrue(compare(resultOM, inputOM));
}
use of org.apache.synapse.Startup in project wso2-synapse by wso2.
the class SynapseObserverTest method testSimpleObserver.
public void testSimpleObserver() {
SynapseConfiguration synapseConfig = new SynapseConfiguration();
synapseConfig.setAxisConfiguration(new AxisConfiguration());
synapseConfig.registerObserver(observer);
Endpoint epr = new AddressEndpoint();
epr.setName("endpoint1");
synapseConfig.addEndpoint(epr.getName(), epr);
assertItemAdded(epr.getName(), ENDPOINT);
synapseConfig.removeEndpoint(epr.getName());
assertItemRemoved(epr.getName(), ENDPOINT);
SequenceMediator seq = new SequenceMediator();
seq.setName("sequence1");
synapseConfig.addSequence(seq.getName(), seq);
assertItemAdded(seq.getName(), SEQUENCE);
synapseConfig.removeSequence(seq.getName());
assertItemRemoved(seq.getName(), SEQUENCE);
TemplateMediator template = new TemplateMediator();
template.setName("template1");
synapseConfig.addSequenceTemplate(template.getName(), template);
assertItemAdded(template.getName(), SEQUENCE_TEMPLATE);
synapseConfig.removeSequenceTemplate(template.getName());
assertItemRemoved(template.getName(), SEQUENCE_TEMPLATE);
Entry entry = new Entry();
entry.setKey("entry1");
synapseConfig.addEntry(entry.getKey(), entry);
assertItemAdded(entry.getKey(), ENTRY);
synapseConfig.removeEntry(entry.getKey());
assertItemRemoved(entry.getKey(), ENTRY);
ProxyService proxy = new ProxyService("proxy1");
synapseConfig.addProxyService(proxy.getName(), proxy);
assertItemAdded(proxy.getName(), PROXY);
synapseConfig.removeProxyService(proxy.getName());
assertItemRemoved(proxy.getName(), PROXY);
Startup startup = new StartUpController();
startup.setName("startup1");
synapseConfig.addStartup(startup);
assertItemAdded(startup.getName(), STARTUP);
synapseConfig.removeStartup(startup.getName());
assertItemRemoved(startup.getName(), STARTUP);
SynapseEventSource eventSrc = new SynapseEventSource("eventSrc1");
synapseConfig.addEventSource(eventSrc.getName(), eventSrc);
assertItemAdded(eventSrc.getName(), EVENT_SRC);
synapseConfig.removeEventSource(eventSrc.getName());
assertItemRemoved(eventSrc.getName(), EVENT_SRC);
PriorityExecutor exec = new PriorityExecutor();
exec.setName("exec1");
synapseConfig.addPriorityExecutor(exec.getName(), exec);
assertItemAdded(exec.getName(), EXECUTOR);
synapseConfig.removeExecutor(exec.getName());
assertItemRemoved(exec.getName(), EXECUTOR);
}
Aggregations