Return-Path: X-Original-To: apmail-streams-commits-archive@minotaur.apache.org Delivered-To: apmail-streams-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EF207E0CC for ; Tue, 15 Jan 2013 16:46:30 +0000 (UTC) Received: (qmail 27317 invoked by uid 500); 15 Jan 2013 16:46:30 -0000 Delivered-To: apmail-streams-commits-archive@streams.apache.org Received: (qmail 27254 invoked by uid 500); 15 Jan 2013 16:46:29 -0000 Mailing-List: contact commits-help@streams.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@streams.incubator.apache.org Delivered-To: mailing list commits@streams.incubator.apache.org Received: (qmail 27205 invoked by uid 99); 15 Jan 2013 16:46:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Jan 2013 16:46:27 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Jan 2013 16:46:25 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 7F32C2388C2A; Tue, 15 Jan 2013 16:46:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1433510 - in /incubator/streams/trunk/streams-eip-routes: ./ src/main/java/org/apache/streams/messaging/routers/ src/main/java/org/apache/streams/messaging/routers/impl/ src/main/java/org/apache/streams/messaging/rules/impl/ src/main/resou... Date: Tue, 15 Jan 2013 16:46:06 -0000 To: commits@streams.incubator.apache.org From: letourneau@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130115164606.7F32C2388C2A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: letourneau Date: Tue Jan 15 16:46:05 2013 New Revision: 1433510 URL: http://svn.apache.org/viewvc?rev=1433510&view=rev Log: dynamic routing with slip working Modified: incubator/streams/trunk/streams-eip-routes/pom.xml incubator/streams/trunk/streams-eip-routes/src/main/java/org/apache/streams/messaging/routers/ActivityRouter.java incubator/streams/trunk/streams-eip-routes/src/main/java/org/apache/streams/messaging/routers/impl/ActivityRouterImpl.java incubator/streams/trunk/streams-eip-routes/src/main/java/org/apache/streams/messaging/rules/impl/SimpleRoutingRule.java incubator/streams/trunk/streams-eip-routes/src/main/resources/META-INF/spring/camelContext.xml incubator/streams/trunk/streams-eip-routes/src/main/resources/META-INF/spring/osgi-component-import.xml Modified: incubator/streams/trunk/streams-eip-routes/pom.xml URL: http://svn.apache.org/viewvc/incubator/streams/trunk/streams-eip-routes/pom.xml?rev=1433510&r1=1433509&r2=1433510&view=diff ============================================================================== --- incubator/streams/trunk/streams-eip-routes/pom.xml (original) +++ incubator/streams/trunk/streams-eip-routes/pom.xml Tue Jan 15 16:46:05 2013 @@ -69,9 +69,9 @@ ${bundle.symbolicName} ${pom.version} - ${bundle.namespace};version="${pom.version}" + ${bundle.namespace};version="${pom.version}",org.apache.streams.messaging.routers,org.apache.streams.messaging.rules ${bundle.namespace}.messaging.routers.impl.*,${bundle.namespace}.messaging.rules.impl.* - org.apache.camel,org.springframework,org.apache.commons.logging,org.apache.streams.messaging.routers, org.apache.streams.messaging.rules,org.apache.streams.osgi-components + org.apache.camel.*;version="2.8.5",org.springframework.core;version="3.0.6.RELEASE",org.springframework.context;version="3.0.6.RELEASE",org.apache.commons.logging,org.apache.streams.messaging.routers, org.apache.streams.messaging.rules,org.apache.streams.osgi.components src/main/resources @@ -83,13 +83,13 @@ org.apache.camel camel-core - 2.10.3 + 2.8.5 org.springframework spring-core - 3.0.5.RELEASE + 3.0.6.RELEASE @@ -115,7 +115,7 @@ - org.apache.streams.osgi-components + org.apache.streams.osgi.components activity-publisher-registration ${pom.version} Modified: incubator/streams/trunk/streams-eip-routes/src/main/java/org/apache/streams/messaging/routers/ActivityRouter.java URL: http://svn.apache.org/viewvc/incubator/streams/trunk/streams-eip-routes/src/main/java/org/apache/streams/messaging/routers/ActivityRouter.java?rev=1433510&r1=1433509&r2=1433510&view=diff ============================================================================== --- incubator/streams/trunk/streams-eip-routes/src/main/java/org/apache/streams/messaging/routers/ActivityRouter.java (original) +++ incubator/streams/trunk/streams-eip-routes/src/main/java/org/apache/streams/messaging/routers/ActivityRouter.java Tue Jan 15 16:46:05 2013 @@ -2,9 +2,13 @@ package org.apache.streams.messaging.rou import java.lang.Object; import java.lang.String; +import java.util.ArrayList; import java.util.Map; -import org.apache.camel.Properties; +import org.apache.camel.Exchange; +import org.apache.camel.Header; +import org.apache.camel.Properties; +import org.apache.streams.messaging.rules.RoutingRule; public interface ActivityRouter { @@ -15,7 +19,7 @@ public interface ActivityRouter { * @param body the message body * @return endpoints to go, or null to indicate the end */ - String slip(String body,@Properties Map properties); - void addRoutingRules(Map rules); + String slip(String body,@Header(Exchange.SLIP_ENDPOINT) String previous); + void addRoutingRules(ArrayList rules); } Modified: incubator/streams/trunk/streams-eip-routes/src/main/java/org/apache/streams/messaging/routers/impl/ActivityRouterImpl.java URL: http://svn.apache.org/viewvc/incubator/streams/trunk/streams-eip-routes/src/main/java/org/apache/streams/messaging/routers/impl/ActivityRouterImpl.java?rev=1433510&r1=1433509&r2=1433510&view=diff ============================================================================== --- incubator/streams/trunk/streams-eip-routes/src/main/java/org/apache/streams/messaging/routers/impl/ActivityRouterImpl.java (original) +++ incubator/streams/trunk/streams-eip-routes/src/main/java/org/apache/streams/messaging/routers/impl/ActivityRouterImpl.java Tue Jan 15 16:46:05 2013 @@ -1,61 +1,60 @@ package org.apache.streams.messaging.routers.impl; + import org.apache.streams.messaging.routers.ActivityRouter; import java.lang.String; import java.util.HashMap; +import java.util.LinkedList; import java.util.Map; import java.util.ArrayList; import org.apache.streams.messaging.rules.RoutingRule; -import org.apache.camel.Properties; + +import org.apache.camel.Header; +import org.apache.camel.Exchange; + import org.apache.streams.messaging.rules.impl.SimpleRoutingRule; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -public class ActivityRouterImpl implements ActivityRouter { +public class ActivityRouterImpl implements ActivityRouter { private static final transient Log LOG = LogFactory.getLog(ActivityRouterImpl.class); - private ArrayList routingRules; + private HashMap routingRules; public ActivityRouterImpl(){ - routingRules = new ArrayList(); + routingRules = new HashMap(); } - public ActivityRouterImpl(HashMap routes){ + public ActivityRouterImpl(ArrayList routes){ LOG.info(">> setting up routes >>"); + routingRules = new HashMap(); addRoutingRules(routes); } - public String slip(String body, @Properties Map properties) { - // get the state from the exchange properties and keep track how many times - // we have been invoked - int invoked = 0; - Object current = properties.get("invoked"); - if (current != null) { - invoked = Integer.valueOf(current.toString()); - } - invoked++; - // and store the state back on the properties - properties.put("invoked", invoked); - - for(RoutingRule r : routingRules){ - if (r.isMessageRoutable(body)){ - return r.getDestination(); - } - } + public String slip(String body,@Header(Exchange.SLIP_ENDPOINT) String previous) { + + LOG.info("previous: " + previous); + if (routingRules.containsKey(previous) ){ + return routingRules.get(previous).getDestination(); + } + return null; + - // no more so return null - return "direct:foo"; } - public void addRoutingRules(@Properties Map rules){ - for(String key : rules.keySet()){ - LOG.info(key + ">> setting up routes >>" + rules.get(key)); - routingRules.add(new SimpleRoutingRule(key,rules.get(key))); + public void addRoutingRules(ArrayList routes){ + String previous = null; + //previous endpoint will be the key lookup to maintain routing order + for(RoutingRule r : routes){ + + LOG.info(previous + ">> setting up routes >>" + r.getDestination()); + routingRules.put(previous, new SimpleRoutingRule(r.getSource(),r.getDestination())); + previous = r.getDestination(); } } Modified: incubator/streams/trunk/streams-eip-routes/src/main/java/org/apache/streams/messaging/rules/impl/SimpleRoutingRule.java URL: http://svn.apache.org/viewvc/incubator/streams/trunk/streams-eip-routes/src/main/java/org/apache/streams/messaging/rules/impl/SimpleRoutingRule.java?rev=1433510&r1=1433509&r2=1433510&view=diff ============================================================================== --- incubator/streams/trunk/streams-eip-routes/src/main/java/org/apache/streams/messaging/rules/impl/SimpleRoutingRule.java (original) +++ incubator/streams/trunk/streams-eip-routes/src/main/java/org/apache/streams/messaging/rules/impl/SimpleRoutingRule.java Tue Jan 15 16:46:05 2013 @@ -6,6 +6,7 @@ public class SimpleRoutingRule implement private String source; private String destination; + public SimpleRoutingRule(){} public SimpleRoutingRule(String source, String destination){ setSource(source); setDestination(destination); Modified: incubator/streams/trunk/streams-eip-routes/src/main/resources/META-INF/spring/camelContext.xml URL: http://svn.apache.org/viewvc/incubator/streams/trunk/streams-eip-routes/src/main/resources/META-INF/spring/camelContext.xml?rev=1433510&r1=1433509&r2=1433510&view=diff ============================================================================== --- incubator/streams/trunk/streams-eip-routes/src/main/resources/META-INF/spring/camelContext.xml (original) +++ incubator/streams/trunk/streams-eip-routes/src/main/resources/META-INF/spring/camelContext.xml Tue Jan 15 16:46:05 2013 @@ -16,17 +16,19 @@ + + + + + + - - - - - + \ No newline at end of file Modified: incubator/streams/trunk/streams-eip-routes/src/main/resources/META-INF/spring/osgi-component-import.xml URL: http://svn.apache.org/viewvc/incubator/streams/trunk/streams-eip-routes/src/main/resources/META-INF/spring/osgi-component-import.xml?rev=1433510&r1=1433509&r2=1433510&view=diff ============================================================================== --- incubator/streams/trunk/streams-eip-routes/src/main/resources/META-INF/spring/osgi-component-import.xml (original) +++ incubator/streams/trunk/streams-eip-routes/src/main/resources/META-INF/spring/osgi-component-import.xml Tue Jan 15 16:46:05 2013 @@ -12,9 +12,12 @@ - - - + + + + + +