Package org.apache.synapse

Examples of org.apache.synapse.Mediator


        return false;
    }

    protected boolean serialization(String inputXml, MediatorSerializer mediatorSerializer) {
        OMElement inputOM = createOMElement(inputXml);
        Mediator mediator = MediatorFactoryFinder.getInstance().getMediator(inputOM);
        OMElement resultOM = mediatorSerializer.serializeMediator(null, mediator);
        try {
            assertXMLEqual(resultOM.toString(), inputXml);
            return true;
        } catch (SAXException e) {
View Full Code Here


    private static void serializeSequences(OMElement definitions, Map sequences) {
        Iterator iter = sequences.keySet().iterator();
        while (iter.hasNext()) {
            String key = (String) iter.next();
            Mediator mediator = (Mediator) sequences.get(key);
            MediatorSerializerFinder.getInstance().getSerializer(mediator)
                    .serializeMediator(definitions, mediator);
        }
    }
View Full Code Here

* XPath parameters at runtime.
*/
public class POJOCommandMediatorTest extends AbstractMediatorTestCase {

    public void testPojoWithoutPropertiesNotCommandImpl() throws Exception {
        Mediator pcm = MediatorFactoryFinder.getInstance().getMediator(createOMElement(
                "<pojoCommand name='org.apache.synapse.mediators.ext.POJOCommandTestMediator' " +
                        "xmlns='http://ws.apache.org/ns/synapse'/>"));
        POJOCommandTestHelper.reset();
        pcm.mediate(new TestMessageContext());
        assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
    }
View Full Code Here

        pcm.mediate(new TestMessageContext());
        assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
    }

    public void testPojoWithPropertiesNotCommandImpl() throws Exception {
        Mediator pcm = MediatorFactoryFinder.getInstance().getMediator(createOMElement(
                "<pojoCommand name='org.apache.synapse.mediators.ext.POJOCommandTestMediator' " +
                        "xmlns='http://ws.apache.org/ns/synapse'><property name=\"testProp\" " +
                        "expression=\"fn:concat('XPATH ', 'FUNC')\"/></pojoCommand>"));
        POJOCommandTestHelper.reset();
        pcm.mediate(new TestMessageContext());
        assertEquals("XPATH FUNC", POJOCommandTestHelper.getInstance().getChangedProperty());
        assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
    }
View Full Code Here

        assertEquals("XPATH FUNC", POJOCommandTestHelper.getInstance().getChangedProperty());
        assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
    }

    public void testPojoWithoutPropertiesCommandImpl() throws Exception {
        Mediator pcm = MediatorFactoryFinder.getInstance().getMediator(createOMElement(
                "<pojoCommand name='org.apache.synapse.mediators.ext.POJOCommandTestImplementedMediator' " +
                        "xmlns='http://ws.apache.org/ns/synapse'/>"));
        POJOCommandTestHelper.reset();
        pcm.mediate(new TestMessageContext());
        assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
    }
View Full Code Here

        pcm.mediate(new TestMessageContext());
        assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
    }

    public void testPojoWithPropertiesCommandImpl() throws Exception {
        Mediator pcm = MediatorFactoryFinder.getInstance().getMediator(createOMElement(
                "<pojoCommand name='org.apache.synapse.mediators.ext.POJOCommandTestImplementedMediator' " +
                        "xmlns='http://ws.apache.org/ns/synapse'><property name=\"testProp\" " +
                        "expression=\"fn:concat('XPATH ', 'FUNC')\"/></pojoCommand>"));
        POJOCommandTestHelper.reset();
        pcm.mediate(new TestMessageContext());
        assertEquals("XPATH FUNC", POJOCommandTestHelper.getInstance().getChangedProperty());
        assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
    }
View Full Code Here

        assertEquals("XPATH FUNC", POJOCommandTestHelper.getInstance().getChangedProperty());
        assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
    }

    public void testPojoWithStaticPropertiesCommandImpl() throws Exception {
        Mediator pcm = MediatorFactoryFinder.getInstance().getMediator(createOMElement(
                "<pojoCommand name='org.apache.synapse.mediators.ext.POJOCommandTestImplementedMediator' " +
                        "xmlns='http://ws.apache.org/ns/synapse'><property name=\"testProp\" " +
                        "value=\"Test Property\"/></pojoCommand>"));
        POJOCommandTestHelper.reset();
        pcm.mediate(new TestMessageContext());
        assertEquals("Test Property", POJOCommandTestHelper.getInstance().getChangedProperty());
        assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
    }
View Full Code Here

            if (synCtx.getConfiguration().getProxyService((String) synCtx.getProperty(
                    SynapseConstants.PROXY_SERVICE)).getTargetOutSequence() != null) {

                String sequenceName = synCtx.getConfiguration().getProxyService((String) synCtx.
                        getProperty(SynapseConstants.PROXY_SERVICE)).getTargetOutSequence();
                Mediator outSequence = synCtx.getSequence(sequenceName);

                if (outSequence != null) {
                    if (log.isDebugEnabled()) {
                        log.debug("Using the sequence named " + sequenceName
                                + " for the outgoing message mediation of the proxy service "
                                + synCtx.getProperty(SynapseConstants.PROXY_SERVICE));
                    }
                    outSequence.mediate(synCtx);
                } else {
                    log.error("Unable to find the out-sequence " +
                            "specified by the name " + sequenceName);
                    throw new SynapseException("Unable to find the " +
                            "out-sequence specified by the name " + sequenceName);
View Full Code Here

                    final ExecutorService executor = messageContext.getEnvironment().
                            getExecutorService();
                    executor.submit(new Runnable() {
                        public void run() {
                            try {
                                Mediator processingSequence = messageContext.getSequence(sequence);
                                if (processingSequence != null) {
                                    processingSequence.mediate(messageContext);
                                }
                            } catch (Throwable t) {
                                log.error("Error occurred while executing the message", t);
                            }
                        }
View Full Code Here

        }

        String sequenceKey = synCtx.isResponse() ? outSequenceKey : inSequenceKey;
        if (sequenceKey != null) {
            registerFaultHandler(synCtx);
            Mediator referredSequence = synCtx.getSequence(sequenceKey);
            if (referredSequence != null) {
                referredSequence.mediate(synCtx);
            } else {
                throw new SynapseException("Specified sequence: " + sequenceKey + " cannot " +
                        "be found");
            }
            return;
View Full Code Here

TOP

Related Classes of org.apache.synapse.Mediator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.