[ 
https://issues.apache.org/jira/browse/CAMEL-11669?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16442346#comment-16442346
 ] 

ASF GitHub Bot commented on CAMEL-11669:
----------------------------------------

lburgazzoli closed pull request #2299: CAMEL-11669: Routes : add 'group'
URL: https://github.com/apache/camel/pull/2299
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/camel-core/src/main/java/org/apache/camel/Route.java 
b/camel-core/src/main/java/org/apache/camel/Route.java
index 48c64457488..7dd5af30a36 100644
--- a/camel-core/src/main/java/org/apache/camel/Route.java
+++ b/camel-core/src/main/java/org/apache/camel/Route.java
@@ -45,6 +45,13 @@
      */
     String getId();
 
+    /**
+     * Gets the route group
+     *
+     * @return the route group
+     */
+    String getGroup();
+
     /**
      * Gets the uptime in a human readable format
      *
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultRoute.java 
b/camel-core/src/main/java/org/apache/camel/impl/DefaultRoute.java
index d67c8cc50e2..b63093ce9c7 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultRoute.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultRoute.java
@@ -67,6 +67,10 @@ public String getId() {
         return (String) properties.get(Route.ID_PROPERTY);
     }
 
+    public String getGroup() {
+        return (String) properties.get(Route.GROUP_PROPERTY);
+    }
+
     public String getUptime() {
         long delta = getUptimeMillis();
         if (delta == 0) {
diff --git 
a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java 
b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
index 86e705bce1d..c5885e4b726 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
@@ -1094,6 +1094,24 @@ public Type routeId(String id) {
         return (Type) this;
     }
 
+    /**
+     * Set the route group for this route.
+     *
+     * @param group  the route group
+     * @return the builder
+     */
+    @SuppressWarnings("unchecked")
+    public Type routeGroup(String group) {
+        ProcessorDefinition<?> def = this;
+
+        RouteDefinition route = ProcessorDefinitionHelper.getRoute(def);
+        if (route != null) {
+            route.setGroup(group);
+        }
+
+        return (Type) this;
+    }
+
     /**
      * Set the route description for this route
      *
diff --git 
a/camel-core/src/main/java/org/apache/camel/model/RouteDefinition.java 
b/camel-core/src/main/java/org/apache/camel/model/RouteDefinition.java
index 9e17ac482ab..3f7a32c0a7a 100644
--- a/camel-core/src/main/java/org/apache/camel/model/RouteDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/RouteDefinition.java
@@ -375,6 +375,17 @@ public RouteDefinition group(String name) {
         return this;
     }
 
+    /**
+     * Set the route group for this route
+     *
+     * @param group the route group
+     * @return the builder
+     */
+    public RouteDefinition routeGroup(String group) {
+        setGroup(group);
+        return this;
+    }
+
     /**
      * Set the route id for this route
      *
diff --git 
a/camel-core/src/test/java/org/apache/camel/model/RouteGroupTest.java 
b/camel-core/src/test/java/org/apache/camel/model/RouteGroupTest.java
new file mode 100644
index 00000000000..67bbf2f3347
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/model/RouteGroupTest.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.model;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Route;
+import org.apache.camel.builder.RouteBuilder;
+
+public class RouteGroupTest extends ContextTestSupport {
+
+    public void testRouteGroup()  {
+        RouteDefinition definition = context.getRouteDefinition("route-id");
+        Route route = context.getRoute("route-id");
+
+        assertEquals("route-group", definition.getGroup());
+        assertEquals("route-group", route.getGroup());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .routeId("route-id")
+                    .routeGroup("route-group")
+                    .to("mock:output");
+            }
+        };
+    }
+}
diff --git 
a/camel-core/src/test/java/org/apache/camel/model/XmlRouteGroupTest.java 
b/camel-core/src/test/java/org/apache/camel/model/XmlRouteGroupTest.java
new file mode 100644
index 00000000000..0393f8002de
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/model/XmlRouteGroupTest.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.model;
+
+import javax.xml.bind.JAXBException;
+
+public class XmlRouteGroupTest extends XmlTestSupport {
+
+    public void testXmlRouteGroup() throws JAXBException {
+        RouteContainer context = assertParseAsJaxb("routeGroup.xml");
+        RouteDefinition route = assertOneElement(context.getRoutes());
+
+        assertEquals("route-id", route.getId());
+        assertEquals("route-group", route.getGroup());
+    }
+}
diff --git 
a/camel-core/src/test/resources/org/apache/camel/model/routeGroup.xml 
b/camel-core/src/test/resources/org/apache/camel/model/routeGroup.xml
new file mode 100644
index 00000000000..e05e5faa225
--- /dev/null
+++ b/camel-core/src/test/resources/org/apache/camel/model/routeGroup.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<routes xmlns="http://camel.apache.org/schema/spring";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
+
+  <!--
+       xsi:schemaLocation="http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd";
+  -->
+
+  <route id="route-id" group="route-group">
+    <from uri="seda:a"/>
+    <to uri="seda:b"/>
+  </route>
+</routes>


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Routes : add 'group'
> --------------------
>
>                 Key: CAMEL-11669
>                 URL: https://issues.apache.org/jira/browse/CAMEL-11669
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Luca Burgazzoli
>            Assignee: Luca Burgazzoli
>            Priority: Major
>             Fix For: 2.22.0
>
>
> It would be nice to have an option to set mark a route being part of a 
> logical group:
> {code:java}
> from('...')
>     .routeGroup('clustered')
>     .routeId('route-1')
>     .to(...)
> {code}
> This is useful for clustered/supervised routes so one can filter out routes 
> to be managed by a routes controller by group.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to