Search in sources :

Example 1 with Startup

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;
}
Also used : File(java.io.File) Startup(org.apache.synapse.Startup) DeploymentException(org.apache.axis2.deployment.DeploymentException)

Example 2 with Startup

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);
    }
}
Also used : Startup(org.apache.synapse.Startup) DeploymentException(org.apache.axis2.deployment.DeploymentException)

Example 3 with Startup

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));
}
Also used : OMElement(org.apache.axiom.om.OMElement) Properties(java.util.Properties) Startup(org.apache.synapse.Startup)

Example 4 with Startup

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));
}
Also used : OMElement(org.apache.axiom.om.OMElement) Properties(java.util.Properties) Startup(org.apache.synapse.Startup)

Example 5 with Startup

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);
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) StartUpController(org.apache.synapse.startup.quartz.StartUpController) AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) Endpoint(org.apache.synapse.endpoints.Endpoint) InboundEndpoint(org.apache.synapse.inbound.InboundEndpoint) TemplateMediator(org.apache.synapse.mediators.template.TemplateMediator) SynapseEventSource(org.apache.synapse.eventing.SynapseEventSource) ProxyService(org.apache.synapse.core.axis2.ProxyService) SequenceMediator(org.apache.synapse.mediators.base.SequenceMediator) PriorityExecutor(org.apache.synapse.commons.executors.PriorityExecutor) Startup(org.apache.synapse.Startup)

Aggregations

Startup (org.apache.synapse.Startup)11 OMElement (org.apache.axiom.om.OMElement)5 DeploymentException (org.apache.axis2.deployment.DeploymentException)4 File (java.io.File)2 Properties (java.util.Properties)2 PriorityExecutor (org.apache.synapse.commons.executors.PriorityExecutor)2 ProxyService (org.apache.synapse.core.axis2.ProxyService)2 SynapseEventSource (org.apache.synapse.eventing.SynapseEventSource)2 InboundEndpoint (org.apache.synapse.inbound.InboundEndpoint)2 SequenceMediator (org.apache.synapse.mediators.base.SequenceMediator)2 TemplateMediator (org.apache.synapse.mediators.template.TemplateMediator)2 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 OMFactory (org.apache.axiom.om.OMFactory)1 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)1 SynapseException (org.apache.synapse.SynapseException)1 Entry (org.apache.synapse.config.Entry)1 TemplateSerializer (org.apache.synapse.config.xml.endpoints.TemplateSerializer)1 AbstractEndpoint (org.apache.synapse.endpoints.AbstractEndpoint)1