Search in sources :

Example 51 with SequenceMediator

use of org.apache.synapse.mediators.base.SequenceMediator in project wso2-synapse by wso2.

the class SequenceMediatorFactory method createAnonymousSequence.

public SequenceMediator createAnonymousSequence(OMElement elem, Properties properties) {
    SequenceMediator seqMediator = new SequenceMediator();
    OMAttribute e = elem.getAttribute(ATT_ONERROR);
    if (e != null) {
        seqMediator.setErrorHandler(e.getAttributeValue());
    }
    processAuditStatus(seqMediator, elem);
    OMElement descElem = elem.getFirstChildWithName(DESCRIPTION_Q);
    if (descElem != null) {
        seqMediator.setDescription(descElem.getText());
    }
    addChildren(elem, seqMediator, properties);
    seqMediator.setSequenceType(SequenceType.ANON);
    return seqMediator;
}
Also used : OMElement(org.apache.axiom.om.OMElement) SequenceMediator(org.apache.synapse.mediators.base.SequenceMediator) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 52 with SequenceMediator

use of org.apache.synapse.mediators.base.SequenceMediator in project wso2-synapse by wso2.

the class SequenceMediatorSerializer method serializeSpecificMediator.

public OMElement serializeSpecificMediator(Mediator m) {
    if (!(m instanceof SequenceMediator)) {
        handleException("Unsupported mediator passed in for serialization : " + m.getType());
    }
    SequenceMediator mediator = (SequenceMediator) m;
    OMElement sequence = fac.createOMElement("sequence", synNS);
    // except make sure that we refer back to the registry key used when we loaded ourself
    if (mediator.isDynamic()) {
        sequence.addAttribute(fac.createOMAttribute("name", nullNS, mediator.getName()));
        sequence.addAttribute(fac.createOMAttribute("key", nullNS, mediator.getRegistryKey()));
    } else {
        if (mediator.getKey() != null) {
            // Serialize Value using ValueSerializer
            ValueSerializer keySerializer = new ValueSerializer();
            keySerializer.serializeValue(mediator.getKey(), XMLConfigConstants.KEY, sequence);
        } else if (mediator.getName() != null) {
            sequence.addAttribute(fac.createOMAttribute("name", nullNS, mediator.getName()));
            if (mediator.getErrorHandler() != null) {
                sequence.addAttribute(fac.createOMAttribute("onError", nullNS, mediator.getErrorHandler()));
            }
            saveTracingState(sequence, mediator);
            serializeChildren(sequence, mediator.getList());
        }
    }
    return sequence;
}
Also used : OMElement(org.apache.axiom.om.OMElement) SequenceMediator(org.apache.synapse.mediators.base.SequenceMediator)

Example 53 with SequenceMediator

use of org.apache.synapse.mediators.base.SequenceMediator in project wso2-synapse by wso2.

the class StatisticSynapseConfigurationObserverTest method testSequenceAdded.

/**
 * Test sequenceAdded method by hash generation.
 */
@Test
public void testSequenceAdded() {
    SequenceMediator mediator = new SequenceMediator();
    observer.sequenceAdded(mediator);
    Assert.assertNotNull("New hash must be set by the method", mediator.getAspectConfiguration().getHashCode());
}
Also used : SequenceMediator(org.apache.synapse.mediators.base.SequenceMediator) Test(org.junit.Test)

Example 54 with SequenceMediator

use of org.apache.synapse.mediators.base.SequenceMediator in project wso2-synapse by wso2.

the class MultiXMLConfigurationBuilderTest method testConfigurationBuilder.

public void testConfigurationBuilder() throws Exception {
    URL u = this.getClass().getClassLoader().getResource("synapse-config");
    String root = new File(u.toURI()).getAbsolutePath();
    System.out.println("Using SYNAPSE_CONFIG_HOME=" + root);
    SynapseConfiguration synapseConfig = MultiXMLConfigurationBuilder.getConfiguration(root, new Properties());
    assertNotNull(synapseConfig.getDefinedSequences().get("main"));
    assertNotNull(synapseConfig.getDefinedSequences().get("fault"));
    SequenceMediator foo = synapseConfig.getDefinedSequences().get("foo");
    SequenceMediator seq1 = synapseConfig.getDefinedSequences().get("synapse_xml_seq1");
    assertNotNull(foo);
    assertNotNull(seq1);
    assertEquals("foo.xml", foo.getFileName());
    assertNull(seq1.getFileName());
    assertNull(synapseConfig.getDefinedSequences().get("bar"));
    assertNotNull(synapseConfig.getDefinedEndpoints().get("epr1"));
    assertNotNull(synapseConfig.getDefinedEndpoints().get("synapse_xml_epr1"));
    assertNotNull(synapseConfig.getProxyService("proxy1"));
    assertNotNull(synapseConfig.getStartup("task1"));
    assertNotNull(synapseConfig.getRegistry());
    assertTrue(JavaUtils.isTrueExplicitly(synapseConfig.getProperty(MultiXMLConfigurationBuilder.SEPARATE_REGISTRY_DEFINITION)));
}
Also used : SequenceMediator(org.apache.synapse.mediators.base.SequenceMediator) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Properties(java.util.Properties) File(java.io.File) URL(java.net.URL)

Example 55 with SequenceMediator

use of org.apache.synapse.mediators.base.SequenceMediator in project wso2-synapse by wso2.

the class MultiXMLConfigurationSerializerTest method testSerializeSynapseXML4.

/**
 * Test serializeSynapseXML method with SequenceMediator added for SynapseConfiguration and
 * assert synapse.xml is created.
 */
@Test
public void testSerializeSynapseXML4() throws Exception {
    MultiXMLConfigurationSerializer serializer = new MultiXMLConfigurationSerializer(TEST_DIRECTORY_NAME);
    SynapseConfiguration configuration = new SynapseConfiguration();
    org.apache.synapse.mediators.TestMediator t1 = new org.apache.synapse.mediators.TestMediator();
    org.apache.synapse.mediators.TestMediator t2 = new org.apache.synapse.mediators.TestMediator();
    org.apache.synapse.mediators.TestMediator t3 = new org.apache.synapse.mediators.TestMediator();
    SequenceMediator seq = new SequenceMediator();
    seq.addChild(t1);
    seq.addChild(t2);
    seq.addChild(t3);
    configuration.addSequence("testSequence", seq);
    serializer.serializeSynapseXML(configuration);
    Assert.assertTrue("Error in serializing Synapse configuration.", new File(TEST_DIRECTORY_NAME + File.separator + SYNAPSE_XML).exists());
    removeTestFolder(TEST_DIRECTORY_NAME);
}
Also used : SequenceMediator(org.apache.synapse.mediators.base.SequenceMediator) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) File(java.io.File) Test(org.junit.Test)

Aggregations

SequenceMediator (org.apache.synapse.mediators.base.SequenceMediator)70 TestMediator (org.apache.synapse.mediators.TestMediator)18 OMElement (org.apache.axiom.om.OMElement)12 ProxyService (org.apache.synapse.core.axis2.ProxyService)12 Endpoint (org.apache.synapse.endpoints.Endpoint)12 Mediator (org.apache.synapse.Mediator)11 AbstractMediator (org.apache.synapse.mediators.AbstractMediator)11 MessageContext (org.apache.synapse.MessageContext)9 TemplateMediator (org.apache.synapse.mediators.template.TemplateMediator)8 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)7 InboundEndpoint (org.apache.synapse.inbound.InboundEndpoint)7 OMAttribute (org.apache.axiom.om.OMAttribute)6 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)6 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)6 File (java.io.File)4 ManagedLifecycle (org.apache.synapse.ManagedLifecycle)4 SynapseException (org.apache.synapse.SynapseException)4 SynapseLog (org.apache.synapse.SynapseLog)4 QName (javax.xml.namespace.QName)3 OMNode (org.apache.axiom.om.OMNode)3