You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2017/06/26 05:53:02 UTC

camel git commit: clustered-route-policy: add an option to set the CamelClusterService a ClusteredRoutePolicyFactory should use

Repository: camel
Updated Branches:
  refs/heads/master 02b8bca7c -> 1352b9d4c


clustered-route-policy: add an option to set the CamelClusterService a ClusteredRoutePolicyFactory should use


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1352b9d4
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1352b9d4
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1352b9d4

Branch: refs/heads/master
Commit: 1352b9d4cedfbf65b493aa2cba7ce6b8e9f627ad
Parents: 02b8bca
Author: lburgazzoli <lb...@gmail.com>
Authored: Mon Jun 26 07:52:42 2017 +0200
Committer: lburgazzoli <lb...@gmail.com>
Committed: Mon Jun 26 07:52:42 2017 +0200

----------------------------------------------------------------------
 .../camel/impl/ha/ClusteredRoutePolicyFactory.java  | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/1352b9d4/camel-core/src/main/java/org/apache/camel/impl/ha/ClusteredRoutePolicyFactory.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/ha/ClusteredRoutePolicyFactory.java b/camel-core/src/main/java/org/apache/camel/impl/ha/ClusteredRoutePolicyFactory.java
index b7ed05a..cd8782b 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/ha/ClusteredRoutePolicyFactory.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/ha/ClusteredRoutePolicyFactory.java
@@ -18,6 +18,7 @@ package org.apache.camel.impl.ha;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.ha.CamelClusterService;
 import org.apache.camel.model.RouteDefinition;
 import org.apache.camel.spi.RoutePolicy;
 import org.apache.camel.spi.RoutePolicyFactory;
@@ -25,15 +26,24 @@ import org.apache.camel.util.ObjectHelper;
 
 public class ClusteredRoutePolicyFactory implements RoutePolicyFactory {
     private final String namespace;
+    private final CamelClusterService clusterService;
 
     public ClusteredRoutePolicyFactory(String viewName) {
         this.namespace = ObjectHelper.notNull(viewName, "Cluster View Namespace");
+        this.clusterService = null;
+    }
+
+    public ClusteredRoutePolicyFactory(CamelClusterService clusterService, String viewName) {
+        this.namespace = ObjectHelper.notNull(viewName, "Cluster View Namespace");
+        this.clusterService = ObjectHelper.notNull(clusterService, "Cluster Service");
     }
 
     @Override
     public RoutePolicy createRoutePolicy(CamelContext camelContext, String routeId, RouteDefinition route) {
         try {
-            return ClusteredRoutePolicy.forNamespace(camelContext, namespace);
+            return clusterService != null
+                ? ClusteredRoutePolicy.forNamespace(clusterService, namespace)
+                : ClusteredRoutePolicy.forNamespace(camelContext, namespace);
         } catch (Exception e) {
             throw new RuntimeCamelException(e);
         }
@@ -46,4 +56,8 @@ public class ClusteredRoutePolicyFactory implements RoutePolicyFactory {
     public static ClusteredRoutePolicyFactory forNamespace(String namespace) {
         return new ClusteredRoutePolicyFactory(namespace);
     }
+
+    public static ClusteredRoutePolicyFactory forNamespace(CamelClusterService clusterService, String namespace) {
+        return new ClusteredRoutePolicyFactory(clusterService, namespace);
+    }
 }