Search in sources :

Example 11 with Evaluator

use of org.apache.synapse.commons.evaluators.Evaluator in project wso2-synapse by wso2.

the class MatchSerializerTest method testParameterMatchSerializer.

public void testParameterMatchSerializer() {
    String input = "<match xmlns=\"http://ws.apache.org/ns/synapse\" type=\"param\" source=\"foo\" regex=\"bar\"/>";
    try {
        Evaluator eval = fac.create(AXIOMUtil.stringToOM(input));
        OMElement output = serializer.serialize(null, eval);
        assertXMLEqual(input, output.toString());
    } catch (Exception e) {
        fail("Error while parsing the input XML");
    }
}
Also used : OMElement(org.apache.axiom.om.OMElement) Evaluator(org.apache.synapse.commons.evaluators.Evaluator)

Example 12 with Evaluator

use of org.apache.synapse.commons.evaluators.Evaluator in project wso2-synapse by wso2.

the class MatchSerializerTest method testURLMatchSerializer.

public void testURLMatchSerializer() {
    String input = "<match xmlns=\"http://ws.apache.org/ns/synapse\" type=\"url\" regex=\"http://foo.org\"/>";
    try {
        Evaluator eval = fac.create(AXIOMUtil.stringToOM(input));
        OMElement output = serializer.serialize(null, eval);
        assertXMLEqual(input, output.toString());
    } catch (Exception e) {
        fail("Error while parsing the input XML");
    }
}
Also used : OMElement(org.apache.axiom.om.OMElement) Evaluator(org.apache.synapse.commons.evaluators.Evaluator)

Example 13 with Evaluator

use of org.apache.synapse.commons.evaluators.Evaluator in project wso2-synapse by wso2.

the class AbstractEvaluatorSerializer method serializeChildren.

protected void serializeChildren(OMElement parent, Evaluator[] childEvaluators) throws EvaluatorException {
    for (Evaluator evaluator : childEvaluators) {
        String name = evaluator.getName();
        EvaluatorSerializer serializer = EvaluatorSerializerFinder.getInstance().getSerializer(name);
        if (serializer != null) {
            serializer.serialize(parent, evaluator);
        } else {
            String msg = "Couldn't find the serializer for evaliator: " + name;
            log.error(msg);
            throw new EvaluatorException(msg);
        }
    }
}
Also used : EvaluatorException(org.apache.synapse.commons.evaluators.EvaluatorException) Evaluator(org.apache.synapse.commons.evaluators.Evaluator)

Example 14 with Evaluator

use of org.apache.synapse.commons.evaluators.Evaluator in project wso2-synapse by wso2.

the class AndFactory method create.

public Evaluator create(OMElement e) throws EvaluatorException {
    AndEvaluator o = new AndEvaluator();
    Iterator it = e.getChildElements();
    List<Evaluator> evaluators = new ArrayList<Evaluator>();
    while (it.hasNext()) {
        OMElement evaluatorElement = (OMElement) it.next();
        EvaluatorFactory ef = EvaluatorFactoryFinder.getInstance().findEvaluatorFactory(evaluatorElement.getLocalName());
        if (ef == null) {
            handleException("Invalid configuration element: " + evaluatorElement.getLocalName());
            return null;
        }
        Evaluator evaluator = ef.create(evaluatorElement);
        evaluators.add(evaluator);
    }
    if (evaluators.size() > 1) {
        o.setEvaluators(evaluators.toArray(new Evaluator[evaluators.size()]));
    } else {
        handleException("Two or more expressions " + "should be provided under And");
        return null;
    }
    return o;
}
Also used : Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) OMElement(org.apache.axiom.om.OMElement) AndEvaluator(org.apache.synapse.commons.evaluators.AndEvaluator) Evaluator(org.apache.synapse.commons.evaluators.Evaluator) AndEvaluator(org.apache.synapse.commons.evaluators.AndEvaluator)

Example 15 with Evaluator

use of org.apache.synapse.commons.evaluators.Evaluator in project wso2-synapse by wso2.

the class NotFactory method create.

public Evaluator create(OMElement e) throws EvaluatorException {
    NotEvaluator not = new NotEvaluator();
    OMElement ce = e.getFirstElement();
    EvaluatorFactory ef = EvaluatorFactoryFinder.getInstance().findEvaluatorFactory(ce.getLocalName());
    if (ef == null) {
        handleException("Invalid configuration element: " + ce.getLocalName());
        return null;
    }
    Evaluator evaluator = ef.create(ce);
    not.setEvaluator(evaluator);
    return not;
}
Also used : NotEvaluator(org.apache.synapse.commons.evaluators.NotEvaluator) OMElement(org.apache.axiom.om.OMElement) Evaluator(org.apache.synapse.commons.evaluators.Evaluator) NotEvaluator(org.apache.synapse.commons.evaluators.NotEvaluator)

Aggregations

Evaluator (org.apache.synapse.commons.evaluators.Evaluator)16 OMElement (org.apache.axiom.om.OMElement)15 Iterator (java.util.Iterator)4 EvaluatorException (org.apache.synapse.commons.evaluators.EvaluatorException)3 ArrayList (java.util.ArrayList)2 QName (javax.xml.namespace.QName)1 OMAttribute (org.apache.axiom.om.OMAttribute)1 AndEvaluator (org.apache.synapse.commons.evaluators.AndEvaluator)1 Condition (org.apache.synapse.commons.evaluators.Condition)1 NotEvaluator (org.apache.synapse.commons.evaluators.NotEvaluator)1 OrEvaluator (org.apache.synapse.commons.evaluators.OrEvaluator)1 EvaluatorSerializer (org.apache.synapse.commons.evaluators.config.EvaluatorSerializer)1 Target (org.apache.synapse.mediators.eip.Target)1 ConditionalRoute (org.apache.synapse.mediators.filters.router.ConditionalRoute)1 ConditionalRouterMediator (org.apache.synapse.mediators.filters.router.ConditionalRouterMediator)1 RewriteAction (org.apache.synapse.mediators.transform.url.RewriteAction)1 RewriteRule (org.apache.synapse.mediators.transform.url.RewriteRule)1