servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r429381 - /incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/ContentBasedRouter.java
Date Mon, 07 Aug 2006 16:20:55 GMT
Author: gnodet
Date: Mon Aug  7 09:20:54 2006
New Revision: 429381

URL: http://svn.apache.org/viewvc?rev=429381&view=rev
Log:
Refactor the ContentBasedRouter.java with an abstract class, so that it is easier to extend.

Modified:
    incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/ContentBasedRouter.java

Modified: incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/ContentBasedRouter.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/ContentBasedRouter.java?rev=429381&r1=429380&r2=429381&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/ContentBasedRouter.java
(original)
+++ incubator/servicemix/trunk/servicemix-eip/src/main/java/org/apache/servicemix/eip/patterns/ContentBasedRouter.java
Mon Aug  7 09:20:54 2006
@@ -17,15 +17,11 @@
 package org.apache.servicemix.eip.patterns;
 
 import javax.jbi.management.DeploymentException;
-import javax.jbi.messaging.ExchangeStatus;
-import javax.jbi.messaging.Fault;
 import javax.jbi.messaging.MessageExchange;
 import javax.jbi.messaging.MessagingException;
-import javax.jbi.messaging.NormalizedMessage;
 
 import org.apache.servicemix.eip.support.AbstractContentBasedRouter;
 import org.apache.servicemix.eip.support.ExchangeTarget;
-import org.apache.servicemix.eip.support.MessageUtil;
 import org.apache.servicemix.eip.support.RoutingRule;
 
 /**
@@ -68,43 +64,6 @@
         // Check rules
         if (rules == null || rules.length == 0) {
             throw new IllegalArgumentException("rules should contain at least one RoutingRule");
-        }
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.servicemix.eip.EIPEndpoint#processSync(javax.jbi.messaging.MessageExchange)
-     */
-    protected void processSync(MessageExchange exchange) throws Exception {
-        // Create exchange for target
-        MessageExchange tme = exchangeFactory.createExchange(exchange.getPattern());
-        // Now copy input to new exchange
-        // We need to read the message once for finding routing target
-        // so ensure we have a re-readable source
-        NormalizedMessage in = MessageUtil.copyIn(exchange);
-        MessageUtil.transferToIn(in, tme); 
-        // Retrieve target
-        ExchangeTarget target = getDestination(tme);
-        target.configureTarget(tme, getContext());
-        // Send in to target
-        sendSync(tme);
-        // Send back the result
-        if (tme.getStatus() == ExchangeStatus.DONE) {
-            done(exchange);
-        } else if (tme.getStatus() == ExchangeStatus.ERROR) {
-            fail(exchange, tme.getError());
-        } else if (tme.getFault() != null) {
-            Fault fault = MessageUtil.copyFault(tme);
-            done(tme);
-            MessageUtil.transferToFault(fault, exchange);
-            sendSync(exchange);
-        } else if (tme.getMessage("out") != null) {
-            NormalizedMessage out = MessageUtil.copyOut(tme);
-            done(tme);
-            MessageUtil.transferToOut(out, exchange);
-            sendSync(exchange);
-        } else {
-            done(tme);
-            throw new IllegalStateException("Exchange status is " + ExchangeStatus.ACTIVE
+ " but has no Out nor Fault message");
         }
     }
 



Mime
View raw message