Search in sources :

Example 16 with Evaluator

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

the class OrFactory method create.

public Evaluator create(OMElement e) throws EvaluatorException {
    OrEvaluator o = new OrEvaluator();
    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 Or");
        return null;
    }
    return o;
}
Also used : OrEvaluator(org.apache.synapse.commons.evaluators.OrEvaluator) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) OMElement(org.apache.axiom.om.OMElement) OrEvaluator(org.apache.synapse.commons.evaluators.OrEvaluator) Evaluator(org.apache.synapse.commons.evaluators.Evaluator)

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