Package org.apache.synapse.mediators.base

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


        if (o != null && o instanceof Mediator) {
            return (Mediator) o;
        } else {
            Mediator m = getConfiguration().getSequence(key);
            if (m instanceof SequenceMediator) {
                SequenceMediator seqMediator = (SequenceMediator) m;
                synchronized (m) {
                    if (!seqMediator.isInitialized()) {
                        seqMediator.init(synEnv);
                    }
                }
            }
            localEntries.put(key, m);
            return m;
View Full Code Here


    public QName getTagQName() {
        return SEQUENCE_Q;
    }

    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);
        return seqMediator;
    }
View Full Code Here

        return seqMediator;
    }
   
    public Mediator createSpecificMediator(OMElement elem, Properties properties) {

        SequenceMediator seqMediator = new SequenceMediator();

        OMAttribute n = elem.getAttribute(ATT_NAME);
        OMAttribute e = elem.getAttribute(ATT_ONERROR);
        if (n != null) {
            seqMediator.setName(n.getAttributeValue());
            if (e != null) {
                seqMediator.setErrorHandler(e.getAttributeValue());
            }
            processAuditStatus(seqMediator, elem);
            addChildren(elem, seqMediator, properties);

        } else {
            n = elem.getAttribute(ATT_KEY);
            if (n != null) {
                // ValueFactory for creating dynamic or static Value
                ValueFactory keyFac = new ValueFactory();
                // create dynamic or static key based on OMElement
                Value generatedKey = keyFac.createValue(XMLConfigConstants.KEY, elem);
                // setKey
                seqMediator.setKey(generatedKey);
                if (e != null) {
                    String msg = "A sequence mediator with a reference to another " +
                        "sequence can not have 'ErrorHandler'";
                    log.error(msg);
                    throw new SynapseException(msg);
View Full Code Here

    public void testFaultSequence() throws Exception {
        API api = new API("TestAPI", "/test");
        Resource resource = new Resource();
        resource.setDispatcherHelper(new URITemplateHelper("/~{user}"));
        SequenceMediator inSequence = getTestSequence("seq.in", "seq.in.value");
        ((PropertyMediator) inSequence.getChild(0)).setScope("axis2");
        XSLTMediator xsltMediator = new XSLTMediator();
        xsltMediator.setXsltKey(new Value("/bogus/key"));
        inSequence.addChild(xsltMediator);
        resource.setInSequence(inSequence);
        SequenceMediator faultSequence = getTestSequence("seq.fault", "seq.fault.value");
        ((PropertyMediator) faultSequence.getChild(0)).setScope("axis2");
        resource.setFaultSequence(faultSequence);
        api.addResource(resource);

        SynapseConfiguration synapseConfig = new SynapseConfiguration();
        synapseConfig.addAPI(api.getName(), api);
View Full Code Here

                XMLConfigConstants.SYNAPSE_NAMESPACE, "inSequence"));
        if (inSequenceKeyAtt != null && !"".equals(inSequenceKeyAtt.getAttributeValue())) {
            resource.setInSequenceKey(inSequenceKeyAtt.getAttributeValue());
        } else if (inSequenceElt != null) {
            SequenceMediatorFactory fac = new SequenceMediatorFactory();
            SequenceMediator sequence = fac.createAnonymousSequence(inSequenceElt, new Properties());
            resource.setInSequence(sequence);
        }

        OMAttribute outSequenceKeyAtt = resourceElt.getAttribute(new QName("outSequence"));
        OMElement outSequenceElt = resourceElt.getFirstChildWithName(new QName(
                XMLConfigConstants.SYNAPSE_NAMESPACE, "outSequence"));
        if (outSequenceKeyAtt != null && !"".equals(outSequenceKeyAtt.getAttributeValue())) {
            resource.setOutSequenceKey(outSequenceKeyAtt.getAttributeValue());
        } else if (outSequenceElt != null) {
            SequenceMediatorFactory fac = new SequenceMediatorFactory();
            SequenceMediator sequence = fac.createAnonymousSequence(outSequenceElt, new Properties());
            resource.setOutSequence(sequence);
        }

        OMAttribute faultSequenceKeyAtt = resourceElt.getAttribute(new QName("faultSequence"));
        OMElement faultSequenceElt = resourceElt.getFirstChildWithName(new QName(
                XMLConfigConstants.SYNAPSE_NAMESPACE, "faultSequence"));
        if (faultSequenceKeyAtt != null && !"".equals(faultSequenceKeyAtt.getAttributeValue())) {
            resource.setFaultSequenceKey(faultSequenceKeyAtt.getAttributeValue());
        } else if (faultSequenceElt != null) {
            SequenceMediatorFactory fac = new SequenceMediatorFactory();
            SequenceMediator sequence = fac.createAnonymousSequence(faultSequenceElt, new Properties());
            resource.setFaultSequence(sequence);
        }
    }
View Full Code Here

            msgCtx.setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, map);
        }
    }

    protected SequenceMediator getTestSequence(String name, String value) {
        SequenceMediator seq = new SequenceMediator();
        PropertyMediator prop = new PropertyMediator();
        prop.setName(name);
        prop.setValue(value);
        seq.addChild(prop);
        return seq;
    }
View Full Code Here

                mediator.setOnCompleteSequenceRef(onCompleteSequence.getAttributeValue());
            } else if (onComplete.getFirstElement() != null) {
                mediator.setOnCompleteSequence((new SequenceMediatorFactory())
                        .createAnonymousSequence(onComplete, properties));
            } else {
                SequenceMediator sequence = new SequenceMediator();
                sequence.addChild(new DropMediator());
                mediator.setOnCompleteSequence(sequence);
            }
        }
        return mediator;
    }
View Full Code Here

                if (template.getFileName() == null) {
                    MediatorSerializerFinder.getInstance().
                            getSerializer(template).serializeMediator(definitions, template);
                }
            } else if (o instanceof SequenceMediator) {
                SequenceMediator seq = (SequenceMediator) o;
                if (seq.getFileName() == null) {
                    MediatorSerializerFinder.getInstance().
                            getSerializer(seq).serializeMediator(definitions, seq);
                }
            } else if (o instanceof Template) {
                Template templEndpoint = (Template) o;
View Full Code Here

        if (!(m instanceof SequenceMediator)) {
            handleException("Unsupported mediator passed in for serialization : " + m.getType());
        }

        SequenceMediator mediator = (SequenceMediator) m;
        OMElement sequence = fac.createOMElement("sequence", synNS);

        // is this a dynamic sequence we loaded from a registry? if so we have no work to here
        // 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;
    }
View Full Code Here

        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"));
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.