use of org.apache.synapse.commons.evaluators.config.EvaluatorSerializer in project wso2-synapse by wso2.
the class URLRewriteMediatorSerializer method serializeRule.
private OMElement serializeRule(RewriteRule r) throws EvaluatorException {
OMElement rule = fac.createOMElement("rewriterule", synNS);
Evaluator condition = r.getCondition();
if (condition != null) {
OMElement conditionElt = fac.createOMElement("condition", synNS);
EvaluatorSerializer serializer = EvaluatorSerializerFinder.getInstance().getSerializer(condition.getName());
serializer.serialize(conditionElt, condition);
rule.addChild(conditionElt);
}
List<RewriteAction> actions = r.getActions();
for (RewriteAction a : actions) {
OMElement action = serializeAction(a);
rule.addChild(action);
}
return rule;
}
use of org.apache.synapse.commons.evaluators.config.EvaluatorSerializer in project wso2-synapse by wso2.
the class ConditionalRouterMediatorSerializer method serializeSpecificMediator.
public OMElement serializeSpecificMediator(Mediator m) {
OMElement conditionalRouterElem = fac.createOMElement("conditionalRouter", synNS);
saveTracingState(conditionalRouterElem, m);
ConditionalRouterMediator conditionalRouterMediator = (ConditionalRouterMediator) m;
if (conditionalRouterMediator.isContinueAfterExplicitlySet()) {
conditionalRouterElem.addAttribute("continueAfter", Boolean.toString(conditionalRouterMediator.isContinueAfter()), nullNS);
}
for (ConditionalRoute conditionalRoute : conditionalRouterMediator.getConditionalRoutes()) {
OMElement routeElem = fac.createOMElement("conditionalRoute", synNS);
if (conditionalRoute.isBreakRouteExplicitlySet()) {
routeElem.addAttribute("breakRoute", Boolean.toString(conditionalRoute.isBreakRoute()), nullNS);
}
if (conditionalRoute.getEvaluator() != null) {
EvaluatorSerializer evaluatorSerializer = EvaluatorSerializerFinder.getInstance().getSerializer(conditionalRoute.getEvaluator().getName());
if (evaluatorSerializer != null) {
OMElement conditionElement = fac.createOMElement("condition", synNS);
try {
evaluatorSerializer.serialize(conditionElement, conditionalRoute.getEvaluator());
} catch (EvaluatorException e) {
handleException("Cannot serialize the Evaluator", e);
}
routeElem.addChild(conditionElement);
}
}
if (conditionalRoute.getTarget() != null) {
routeElem.addChild(TargetSerializer.serializeTarget(conditionalRoute.getTarget()));
} else {
handleException("ConditionalRoute in a conditional router has to have a target");
}
if (conditionalRoute.getTarget().isAsynchronous()) {
routeElem.addAttribute(fac.createOMAttribute("asynchronous", nullNS, "true"));
}
conditionalRouterElem.addChild(routeElem);
}
return conditionalRouterElem;
}
Aggregations