Author: supun
Date: Wed May 12 10:46:32 2010
New Revision: 943441

URL: http://svn.apache.org/viewvc?rev=943441&view=rev
Log:
improving code

Modified:
    
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ConditionalRouterMediatorFactory.java

Modified: 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ConditionalRouterMediatorFactory.java
URL: 
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ConditionalRouterMediatorFactory.java?rev=943441&r1=943440&r2=943441&view=diff
==============================================================================
--- 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ConditionalRouterMediatorFactory.java
 (original)
+++ 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ConditionalRouterMediatorFactory.java
 Wed May 12 10:46:32 2010
@@ -80,48 +80,48 @@ public class ConditionalRouterMediatorFa
 
         Iterator itr = elem.getChildrenWithName(ROUTE_Q);
         while (itr.hasNext()) {
-
             OMElement routeElem = (OMElement) itr.next();
-            if (ROUTE_Q.equals(routeElem.getQName())) {
-
-                Route route = new Route();
+            Route route = new Route();
 
-                if (routeElem.getAttribute(BREAK_ROUTE_ATTR) != null) {
-                    if 
(JavaUtils.isTrueExplicitly(routeElem.getAttributeValue(BREAK_ROUTE_ATTR).trim()))
 {
-                        route.setBreakRoute(true);
-                    } else if 
(JavaUtils.isFalseExplicitly(routeElem.getAttributeValue(BREAK_ROUTE_ATTR).trim()))
 {
-                        route.setBreakRoute(false);
-                    } else {
-                        handleException("breakRoute attribute value of the 
route element must " +
-                                "be either 'true' or 'false', the value found 
is : "
-                                + 
routeElem.getAttributeValue(BREAK_ROUTE_ATTR).trim());
-                    }
-                }
+            if (routeElem.getAttribute(BREAK_ROUTE_ATTR) != null) {
+                if (JavaUtils.isTrueExplicitly(
+                        routeElem.getAttributeValue(BREAK_ROUTE_ATTR).trim())) 
{
 
-                OMElement conditionElem = 
routeElem.getFirstChildWithName(CONDITION_Q);
-                
-                if (conditionElem == null) {
-                    handleException("Couldn't find the condition of the 
conditional router");
-                    return null;
-                }
+                    route.setBreakRoute(true);
+                } else if (JavaUtils.isFalseExplicitly(
+                        routeElem.getAttributeValue(BREAK_ROUTE_ATTR).trim())) 
{
 
-                try {
-                    Evaluator evaluator = 
EvaluatorFactoryFinder.getInstance().getEvaluator(
-                            conditionElem.getFirstElement());
-                    route.setEvaluator(evaluator);
-                } catch (EvaluatorException ee) {                    
-                    handleException("Couldn't build the condition of the 
conditional router", ee);
-                }
-                OMElement targetElem = 
routeElem.getFirstChildWithName(TARGET_Q);
-                Target target = TargetFactory.createTarget(targetElem);
-                if 
(JavaUtils.isTrueExplicitly(routeElem.getAttributeValue(ASYNCHRONOUS_ATTR))) {
-                    target.setAsynchronous(true);
+                    route.setBreakRoute(false);
                 } else {
-                    target.setAsynchronous(false);
+                    handleException("breakRoute attribute value of the route 
element must " +
+                            "be either 'true' or 'false', the value found is : 
"
+                            + 
routeElem.getAttributeValue(BREAK_ROUTE_ATTR).trim());
                 }
-                route.setTarget(target);
-                conditionalRouterMediator.addRoute(route);
             }
+
+            OMElement conditionElem = 
routeElem.getFirstChildWithName(CONDITION_Q);
+            if (conditionElem == null) {
+                handleException("Couldn't find the condition of the 
conditional router");
+                return null;
+            }
+
+            try {
+                Evaluator evaluator = 
EvaluatorFactoryFinder.getInstance().getEvaluator(
+                        conditionElem.getFirstElement());
+                route.setEvaluator(evaluator);
+            } catch (EvaluatorException ee) {
+                handleException("Couldn't build the condition of the 
conditional router", ee);
+            }
+
+            OMElement targetElem = routeElem.getFirstChildWithName(TARGET_Q);
+            Target target = TargetFactory.createTarget(targetElem);
+            if 
(JavaUtils.isTrueExplicitly(routeElem.getAttributeValue(ASYNCHRONOUS_ATTR))) {
+                target.setAsynchronous(true);
+            } else {
+                target.setAsynchronous(false);
+            }
+            route.setTarget(target);
+            conditionalRouterMediator.addRoute(route);
         }
         return conditionalRouterMediator;
     }


Reply via email to