You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2020/03/04 08:57:55 UTC
[camel] 10/32: Use NamedNode instead of RouteDefinition as in the
RoutePolicy
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 8f1441eb3af218a1554404d02933d319d4846bf2
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Tue Mar 3 14:20:36 2020 +0100
Use NamedNode instead of RouteDefinition as in the RoutePolicy
---
.../org/apache/camel/impl/cluster/ClusteredRouteFilter.java | 4 ++--
.../org/apache/camel/impl/cluster/ClusteredRouteFilters.java | 10 ++++++----
.../apache/camel/impl/cluster/ClusteredRoutePolicyFactory.java | 3 ++-
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/impl/cluster/ClusteredRouteFilter.java b/core/camel-core-engine/src/main/java/org/apache/camel/impl/cluster/ClusteredRouteFilter.java
index 67387a2..85ddf48 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/impl/cluster/ClusteredRouteFilter.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/impl/cluster/ClusteredRouteFilter.java
@@ -17,7 +17,7 @@
package org.apache.camel.impl.cluster;
import org.apache.camel.CamelContext;
-import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.NamedNode;
@FunctionalInterface
public interface ClusteredRouteFilter {
@@ -29,5 +29,5 @@ public interface ClusteredRouteFilter {
* @param route the route definition
* @return true if the route should be included
*/
- boolean test(CamelContext camelContext, String routeId, RouteDefinition route);
+ boolean test(CamelContext camelContext, String routeId, NamedNode route);
}
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/impl/cluster/ClusteredRouteFilters.java b/core/camel-core-engine/src/main/java/org/apache/camel/impl/cluster/ClusteredRouteFilters.java
index ae96925..278f506 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/impl/cluster/ClusteredRouteFilters.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/impl/cluster/ClusteredRouteFilters.java
@@ -22,6 +22,7 @@ import java.util.HashSet;
import java.util.Set;
import org.apache.camel.CamelContext;
+import org.apache.camel.NamedNode;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.model.RouteDefinition;
import org.apache.camel.support.CamelContextHelper;
@@ -32,13 +33,14 @@ public final class ClusteredRouteFilters {
public static final class IsAutoStartup implements ClusteredRouteFilter {
@Override
- public boolean test(CamelContext camelContext, String routeId, RouteDefinition route) {
+ public boolean test(CamelContext camelContext, String routeId, NamedNode route) {
try {
- if (route.getAutoStartup() == null) {
+ String autoStartup = ((RouteDefinition) route).getAutoStartup();
+ if (autoStartup == null) {
// should auto startup by default
return true;
}
- Boolean isAutoStartup = CamelContextHelper.parseBoolean(camelContext, route.getAutoStartup());
+ Boolean isAutoStartup = CamelContextHelper.parseBoolean(camelContext, autoStartup);
return isAutoStartup != null && isAutoStartup;
} catch (Exception e) {
throw RuntimeCamelException.wrapRuntimeCamelException(e);
@@ -58,7 +60,7 @@ public final class ClusteredRouteFilters {
}
@Override
- public boolean test(CamelContext camelContext, String routeId, RouteDefinition route) {
+ public boolean test(CamelContext camelContext, String routeId, NamedNode route) {
return !names.contains(routeId);
}
}
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/impl/cluster/ClusteredRoutePolicyFactory.java b/core/camel-core-engine/src/main/java/org/apache/camel/impl/cluster/ClusteredRoutePolicyFactory.java
index 2d9e01c..f3c87a0 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/impl/cluster/ClusteredRoutePolicyFactory.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/impl/cluster/ClusteredRoutePolicyFactory.java
@@ -60,7 +60,8 @@ public class ClusteredRoutePolicyFactory implements RoutePolicyFactory {
public RoutePolicy createRoutePolicy(CamelContext camelContext, String routeId, NamedNode route) {
try {
return clusterService != null
- ? ClusteredRoutePolicy.forNamespace(clusterService, namespace) : ClusteredRoutePolicy.forNamespace(camelContext, clusterServiceSelector, namespace);
+ ? ClusteredRoutePolicy.forNamespace(clusterService, namespace)
+ : ClusteredRoutePolicy.forNamespace(camelContext, clusterServiceSelector, namespace);
} catch (Exception e) {
throw new RuntimeCamelException(e);
}