action1.setValue("localhost");
action1.setFragmentIndex(URIFragments.HOST);
RewriteRule rule1 = new RewriteRule();
rule1.addRewriteAction(action1);
EqualEvaluator eval1 = new EqualEvaluator();
URLTextRetriever txtRtvr1 = new URLTextRetriever();
txtRtvr1.setSource(EvaluatorConstants.URI_FRAGMENTS.host.name());
eval1.setTextRetriever(txtRtvr1);
eval1.setValue("myhost");
rule1.setCondition(eval1);
mediator.addRule(rule1);
RewriteAction action2 = new RewriteAction();
action2.setValue("/services/SimpleStockQuoteService");
action2.setFragmentIndex(URIFragments.PATH);
RewriteAction action3 = new RewriteAction();
action3.setXpath(new SynapseXPath("get-property('port')"));
action3.setFragmentIndex(URIFragments.PORT);
RewriteRule rule2 = new RewriteRule();
rule2.addRewriteAction(action2);
rule2.addRewriteAction(action3);
MatchEvaluator eval2 = new MatchEvaluator();
URLTextRetriever txtRtvr2 = new URLTextRetriever();
txtRtvr2.setSource(EvaluatorConstants.URI_FRAGMENTS.path.name());
eval2.setTextRetriever(txtRtvr2);
eval2.setRegex(Pattern.compile(".*/MyService"));
rule2.setCondition(eval2);
mediator.addRule(rule2);