Package org.apache.synapse.mediators.base

Examples of org.apache.synapse.mediators.base.SequenceMediator


        Endpoint endpoint2 = createEndpoint("endpoint2");
        initEndpoint(endpoint2, null);
        synapseConfig.addEndpoint(endpoint2.getName(), endpoint2);

        SequenceMediator seq1 = createSequence("seq1", null);
        SendMediator send = new SendMediator();
        IndirectEndpoint endpointRef = new IndirectEndpoint();
        endpointRef.setKey(endpoint.getName());
        send.setEndpoint(endpointRef);
        seq1.addChild(send);
        synapseConfig.addSequence(seq1.getName(), seq1);

        assertDependency(ConfigurationObject.TYPE_ENDPOINT, endpoint.getName(), seq1.getName());
        synapseConfig.removeSequence(seq1.getName());
        seq1.removeChild(0);
        send = new SendMediator();
        endpointRef = new IndirectEndpoint();
        endpointRef.setKey(endpoint2.getName());
        send.setEndpoint(endpointRef);
        seq1.addChild(send);
        synapseConfig.addSequence(seq1.getName(), seq1);
        assertNoDependency(ConfigurationObject.TYPE_ENDPOINT, endpoint.getName());
        assertDependency(ConfigurationObject.TYPE_ENDPOINT, endpoint2.getName(), seq1.getName());

        SequenceMediator seq2 = createSequence("seq2", null);
        synapseConfig.addSequence(seq2.getName(), seq2);

        ProxyService proxy = createProxy("proxy", seq1.getName(), null, null);
        synapseConfig.addProxyService(proxy.getName(), proxy);

        assertDependency(ConfigurationObject.TYPE_SEQUENCE, seq1.getName(), proxy.getName());
        synapseConfig.removeProxyService(proxy.getName());
        proxy = createProxy("proxy", null, seq2.getName(), null);
        synapseConfig.addProxyService(proxy.getName(), proxy);
        assertNoDependency(ConfigurationObject.TYPE_SEQUENCE, seq1.getName());
        assertDependency(ConfigurationObject.TYPE_SEQUENCE, seq2.getName(), proxy.getName());       

        System.out.println("All tests were successful...");
    }
View Full Code Here


        Endpoint endpoint = createEndpoint("endpoint");
        initEndpoint(endpoint, null);
        synapseConfig.addEndpoint(endpoint.getName(), endpoint);

        SequenceMediator sequence = createSequence("sequence", null);
        SendMediator send = new SendMediator();
        IndirectEndpoint target = new IndirectEndpoint();
        target.setKey(endpoint.getName());
        send.setEndpoint(target);
        sequence.addChild(send);
        synapseConfig.addSequence(sequence.getName(), sequence);
        assertDependency(ConfigurationObject.TYPE_ENDPOINT, endpoint.getName(), sequence.getName());

        SequenceMediator sequence2 = createSequence("sequence2", sequence.getName());
        synapseConfig.addSequence(sequence2.getName(), sequence2);
        assertDependency(ConfigurationObject.TYPE_SEQUENCE, sequence.getName(), sequence2.getName());

        synapseConfig.removeSequence(sequence.getName());
        assertDependency(ConfigurationObject.TYPE_ENDPOINT, endpoint.getName(), sequence.getName());
        assertNoActiveDependency(ConfigurationObject.TYPE_ENDPOINT, endpoint.getName());
    }
View Full Code Here

        }
        return proxy;
    }

    protected SequenceMediator createSequence(String key, String seqRef) {
        SequenceMediator seq = new SequenceMediator();
        seq.setName(key);
        if (seqRef != null) {
            SequenceMediator ref = new SequenceMediator();
            //Create keyValue from static key(seqRef)
            Value seqRefValue = new Value(seqRef);
            ref.setKey(seqRefValue);
            seq.addChild(ref);
        }
        return seq;
    }
View Full Code Here

public class ProxyDependencyTrackingTest extends DependencyMgtTestCase {

    public void testProxySequenceDependencyMgt() {
        SynapseConfiguration synapseConfig = createSynapseConfig();

        SequenceMediator inSeq = createSequence("in", null);
        SequenceMediator outSeq = createSequence("out", null);
        synapseConfig.addSequence(inSeq.getName(), inSeq);
        synapseConfig.addSequence(outSeq.getName(), outSeq);

        ProxyService proxy1 = createProxy("proxy1", inSeq.getName(), null, null);
        ProxyService proxy2 = createProxy("proxy2", null, outSeq.getName(), null);
        ProxyService proxy3 = createProxy("proxy3", inSeq.getName(), outSeq.getName(), null);
        synapseConfig.addProxyService(proxy1.getName(), proxy1);
        synapseConfig.addProxyService(proxy2.getName(), proxy2);
        synapseConfig.addProxyService(proxy3.getName(), proxy3);

        assertDependency(ConfigurationObject.TYPE_SEQUENCE, inSeq.getName(), proxy1.getName());
        assertNoDependency(ConfigurationObject.TYPE_SEQUENCE, inSeq.getName(), proxy2.getName());
        assertDependency(ConfigurationObject.TYPE_SEQUENCE, inSeq.getName(), proxy3.getName());
        assertNoDependency(ConfigurationObject.TYPE_SEQUENCE, outSeq.getName(), proxy1.getName());
        assertDependency(ConfigurationObject.TYPE_SEQUENCE, outSeq.getName(), proxy2.getName());
        assertDependency(ConfigurationObject.TYPE_SEQUENCE, outSeq.getName(), proxy3.getName());
    }
View Full Code Here

    }

    public void testProxyWithAnonSequence() {
        SynapseConfiguration synapseConfig = createSynapseConfig();

        SequenceMediator inSeq = createSequence("in", null);
        synapseConfig.addSequence(inSeq.getName(), inSeq);

        ProxyService proxy1 = createProxy("proxy1", inSeq.getName(), null, null);
        SequenceMediator anon = new SequenceMediator();
        anon.addChild(new LogMediator());
        proxy1.setTargetInLineOutSequence(anon);
        synapseConfig.addProxyService(proxy1.getName(), proxy1);

        assertDependency(ConfigurationObject.TYPE_SEQUENCE, inSeq.getName(), proxy1.getName());
    }
View Full Code Here

     * a simple sequence with a <send/>
     *
     * @param config the configuration to be updated
     */
    public static void setDefaultMainSequence(SynapseConfiguration config) {
        SequenceMediator main = new SequenceMediator();
        main.setName(SynapseConstants.MAIN_SEQUENCE_KEY);
        main.addChild(new LogMediator());
        main.addChild(new DropMediator());
        config.addSequence(SynapseConstants.MAIN_SEQUENCE_KEY, main);
        // set the aspect configuration
        AspectConfiguration configuration = new AspectConfiguration(main.getName());
        main.configure(configuration);
    }
View Full Code Here

     * <drop/>
     *
     * @param config the configuration to be updated
     */
    public static void setDefaultFaultSequence(SynapseConfiguration config) {
        SequenceMediator fault = new SequenceMediator();
        fault.setName(org.apache.synapse.SynapseConstants.FAULT_SEQUENCE_KEY);
        LogMediator log = new LogMediator();
        log.setLogLevel(LogMediator.FULL);

        MediatorProperty mp = new MediatorProperty();
        mp.setName("MESSAGE");
        mp.setValue("Executing default \"fault\" sequence");
        log.addProperty(mp);

        mp = new MediatorProperty();
        mp.setName("ERROR_CODE");
        try {
            mp.setExpression(new SynapseXPath("get-property('ERROR_CODE')"));
        } catch (JaxenException ignore) {}
        log.addProperty(mp);

        mp = new MediatorProperty();
        mp.setName("ERROR_MESSAGE");
        try {
            mp.setExpression(new SynapseXPath("get-property('ERROR_MESSAGE')"));
        } catch (JaxenException ignore) {}
        log.addProperty(mp);

        fault.addChild(log);
        fault.addChild(new DropMediator());

        // set aspect configuration
        AspectConfiguration configuration = new AspectConfiguration(fault.getName());
        fault.configure(configuration);

        config.addSequence(org.apache.synapse.SynapseConstants.FAULT_SEQUENCE_KEY, fault);
    }
View Full Code Here

        if(!executorsDir.mkdir()) {
            log.warn("Could not create " + executorsDir);
        }

        SynapseConfiguration initialSynCfg = SynapseConfigurationBuilder.getDefaultConfiguration();
        SequenceMediator mainSequence = (SequenceMediator) initialSynCfg.getMainSequence();
        SequenceMediator faultSequence = (SequenceMediator) initialSynCfg.getFaultSequence();
        mainSequence.setFileName(SynapseConstants.MAIN_SEQUENCE_KEY + ".xml");
        faultSequence.setFileName(SynapseConstants.FAULT_SEQUENCE_KEY + ".xml");
        Registry registry = new WSO2Registry();
        initialSynCfg.setRegistry(registry);

        MultiXMLConfigurationSerializer serializer
                = new MultiXMLConfigurationSerializer(synapseConfigDir.getAbsolutePath());
View Full Code Here

            SynapseEnvironment synapseEnv = synEnvService.getSynapseEnvironment();

            /* Registering Tenant Aware Load Balance Endpoint */

            // get the main sequence mediator
            SequenceMediator mainSequence =
                                            (SequenceMediator) synapseEnv.getSynapseConfiguration()
                                                                         .getSequence("main");

            boolean successfullyRegistered = false;
           
            // iterate through its child mediators
            for (Mediator child : mainSequence.getList()) {

                // find the InMediator
                if (child instanceof InMediator) {
                   
                    for(Mediator inChild : ((InMediator)child).getList()){
View Full Code Here

        LoadBalancerConfiguration lbConfig = AutoscalerTaskDSHolder.getInstance().getWholeLoadBalancerConfig();
        // check whether autoscaling is enabled
        if (lbConfig.getLoadBalancerConfig().isAutoscaleEnabled()) {

            // get the main sequence mediator
            SequenceMediator mainSequence =
                    (SequenceMediator) synapseEnv.getSynapseConfiguration().getSequence("main");

            // iterate through its child mediators
            for (Mediator child : mainSequence.getList()) {

                // find the InMediator
                if (child instanceof InMediator) {
                    InMediator inSequence = (InMediator) child;
View Full Code Here

TOP

Related Classes of org.apache.synapse.mediators.base.SequenceMediator

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.