You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/10/24 12:40:39 UTC

[1/6] camel git commit: camel-jackson - lets be less verbose on startup

Repository: camel
Updated Branches:
  refs/heads/camel-2.16.x 6e8a3fd1a -> d90d0ad42
  refs/heads/master df75c1ca7 -> 9ff11b57f


camel-jackson - lets be less verbose on startup


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

Branch: refs/heads/camel-2.16.x
Commit: 979e9a38faf06dff6501306b2271086501752f1e
Parents: 6e8a3fd
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Oct 24 11:51:18 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Oct 24 12:42:46 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/component/jackson/JacksonDataFormat.java    | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/979e9a38/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
index 6aa465d..381b81a 100644
--- a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
+++ b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
@@ -402,7 +402,7 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat, Dat
         if (enableJaxbAnnotationModule) {
             // Enables JAXB processing
             JaxbAnnotationModule module = new JaxbAnnotationModule();
-            LOG.info("Registering module: {}", module);
+            LOG.debug("Registering JaxbAnnotationModule: {}", module);
             objectMapper.registerModule(module);
         }
 
@@ -466,7 +466,7 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat, Dat
 
         if (modules != null) {
             for (Module module : modules) {
-                LOG.info("Registering module: {}", module);
+                LOG.debug("Registering module: {}", module);
                 objectMapper.registerModules(module);
             }
         }
@@ -476,7 +476,7 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat, Dat
                 String name = o.toString();
                 Class<Module> clazz = camelContext.getClassResolver().resolveMandatoryClass(name, Module.class);
                 Module module = camelContext.getInjector().newInstance(clazz);
-                LOG.info("Registering module: {} -> {}", name, module);
+                LOG.debug("Registering module: {} -> {}", name, module);
                 objectMapper.registerModule(module);
             }
         }
@@ -488,7 +488,7 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat, Dat
                     name = name.substring(1);
                 }
                 Module module = CamelContextHelper.mandatoryLookup(camelContext, name, Module.class);
-                LOG.info("Registering module: {} -> {}", name, module);
+                LOG.debug("Registering module: {} -> {}", name, module);
                 objectMapper.registerModule(module);
             }
         }


[3/6] camel git commit: CAMEL-9247: rest-dsl with api-doc should allow multiple rest's

Posted by da...@apache.org.
CAMEL-9247: rest-dsl with api-doc should allow multiple rest's


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

Branch: refs/heads/camel-2.16.x
Commit: 73cc80e117b420fc538a6e3551686c2fe45c4427
Parents: 979e9a3
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Oct 24 12:32:36 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Oct 24 12:42:47 2015 +0200

----------------------------------------------------------------------
 .../org/apache/camel/builder/RouteBuilder.java  | 20 +++++++++++++----
 .../apache/camel/model/rest/RestDefinition.java | 23 ++++++++++----------
 2 files changed, 28 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/73cc80e1/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java b/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
index a5872e9..984e7cf 100644
--- a/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
+++ b/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.builder;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -436,13 +437,24 @@ public abstract class RouteBuilder extends BuilderSupport implements RoutesBuild
         }
         camelContext.addRestDefinitions(getRestCollection().getRests());
 
-        // convert rests into routes so we reuse routes for runtime
+        // convert rests into routes so we they are routes for runtime
+        List<RouteDefinition> routes = new ArrayList<RouteDefinition>();
         for (RestDefinition rest : getRestCollection().getRests()) {
-            List<RouteDefinition> routes = rest.asRouteDefinition(getContext());
-            for (RouteDefinition route : routes) {
-                getRouteCollection().route(route);
+            List<RouteDefinition> list = rest.asRouteDefinition(getContext());
+            routes.addAll(list);
+        }
+        // convert rests api-doc into routes so they are routes for runtime
+        for (RestConfiguration config : camelContext.getRestConfigurations()) {
+            if (config.getApiContextPath() != null) {
+                RouteDefinition route = RestDefinition.asRouteApiDefinition(camelContext, config);
+                routes.add(route);
             }
         }
+
+        // add the rest routes
+        for (RouteDefinition route : routes) {
+            getRouteCollection().route(route);
+        }
     }
 
     public RestsDefinition getRestCollection() {

http://git-wip-us.apache.org/repos/asf/camel/blob/73cc80e1/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
index e2b1895..fd4970a 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
@@ -533,15 +533,16 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
         }
         for (RestConfiguration config : camelContext.getRestConfigurations()) {
             addRouteDefinition(camelContext, answer, config.getComponent());
-            if (config.getApiContextPath() != null) {
-                addApiRouteDefinition(camelContext, answer, config);
-            }
         }
         return answer;
     }
 
-    private void addApiRouteDefinition(CamelContext camelContext, List<RouteDefinition> answer, RestConfiguration configuration) {
-        RouteDefinition route = new RouteDefinition();
+    /**
+     * Transforms the rest api configuration into a {@link org.apache.camel.model.RouteDefinition} which
+     * Camel routing engine uses to service the rest api docs.
+     */
+    public static RouteDefinition asRouteApiDefinition(CamelContext camelContext, RestConfiguration configuration) {
+        RouteDefinition answer = new RouteDefinition();
 
         // create the from endpoint uri which is using the rest-api component
         String from = "rest-api:" + configuration.getApiContextPath();
@@ -549,7 +550,7 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
         // append options
         Map<String, Object> options = new HashMap<String, Object>();
 
-        String routeId = "rest-api-" + route.idOrCreate(camelContext.getNodeIdFactory());
+        String routeId = answer.idOrCreate(camelContext.getNodeIdFactory());
         options.put("routeId", routeId);
         if (configuration.getComponent() != null && !configuration.getComponent().isEmpty()) {
             options.put("componentName", configuration.getComponent());
@@ -570,12 +571,11 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
 
         // we use the same uri as the producer (so we have a little route for the rest api)
         String to = from;
+        answer.fromRest(from);
+        answer.id(routeId);
+        answer.to(to);
 
-        // the route should be from this rest endpoint
-        route.fromRest(from);
-        route.to(to);
-        route.setRestDefinition(this);
-        answer.add(route);
+        return answer;
     }
 
     private void addRouteDefinition(CamelContext camelContext, List<RouteDefinition> answer, String component) {
@@ -738,6 +738,7 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
 
             // the route should be from this rest endpoint
             route.fromRest(from);
+            route.id(routeId);
             route.setRestDefinition(this);
             answer.add(route);
         }


[6/6] camel git commit: CAMEL-9247: rest-dsl with api-doc should allow multiple rest's

Posted by da...@apache.org.
CAMEL-9247: rest-dsl with api-doc should allow multiple rest's


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

Branch: refs/heads/master
Commit: 041f7e57cfd871cbfecb6beb278fdd0303cb41f0
Parents: 4abb3b1
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Oct 24 12:32:36 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Oct 24 12:43:22 2015 +0200

----------------------------------------------------------------------
 .../org/apache/camel/builder/RouteBuilder.java  | 20 +++++++++++++----
 .../apache/camel/model/rest/RestDefinition.java | 23 ++++++++++----------
 2 files changed, 28 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/041f7e57/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java b/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
index a5872e9..984e7cf 100644
--- a/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
+++ b/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.builder;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -436,13 +437,24 @@ public abstract class RouteBuilder extends BuilderSupport implements RoutesBuild
         }
         camelContext.addRestDefinitions(getRestCollection().getRests());
 
-        // convert rests into routes so we reuse routes for runtime
+        // convert rests into routes so we they are routes for runtime
+        List<RouteDefinition> routes = new ArrayList<RouteDefinition>();
         for (RestDefinition rest : getRestCollection().getRests()) {
-            List<RouteDefinition> routes = rest.asRouteDefinition(getContext());
-            for (RouteDefinition route : routes) {
-                getRouteCollection().route(route);
+            List<RouteDefinition> list = rest.asRouteDefinition(getContext());
+            routes.addAll(list);
+        }
+        // convert rests api-doc into routes so they are routes for runtime
+        for (RestConfiguration config : camelContext.getRestConfigurations()) {
+            if (config.getApiContextPath() != null) {
+                RouteDefinition route = RestDefinition.asRouteApiDefinition(camelContext, config);
+                routes.add(route);
             }
         }
+
+        // add the rest routes
+        for (RouteDefinition route : routes) {
+            getRouteCollection().route(route);
+        }
     }
 
     public RestsDefinition getRestCollection() {

http://git-wip-us.apache.org/repos/asf/camel/blob/041f7e57/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
index e2b1895..fd4970a 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
@@ -533,15 +533,16 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
         }
         for (RestConfiguration config : camelContext.getRestConfigurations()) {
             addRouteDefinition(camelContext, answer, config.getComponent());
-            if (config.getApiContextPath() != null) {
-                addApiRouteDefinition(camelContext, answer, config);
-            }
         }
         return answer;
     }
 
-    private void addApiRouteDefinition(CamelContext camelContext, List<RouteDefinition> answer, RestConfiguration configuration) {
-        RouteDefinition route = new RouteDefinition();
+    /**
+     * Transforms the rest api configuration into a {@link org.apache.camel.model.RouteDefinition} which
+     * Camel routing engine uses to service the rest api docs.
+     */
+    public static RouteDefinition asRouteApiDefinition(CamelContext camelContext, RestConfiguration configuration) {
+        RouteDefinition answer = new RouteDefinition();
 
         // create the from endpoint uri which is using the rest-api component
         String from = "rest-api:" + configuration.getApiContextPath();
@@ -549,7 +550,7 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
         // append options
         Map<String, Object> options = new HashMap<String, Object>();
 
-        String routeId = "rest-api-" + route.idOrCreate(camelContext.getNodeIdFactory());
+        String routeId = answer.idOrCreate(camelContext.getNodeIdFactory());
         options.put("routeId", routeId);
         if (configuration.getComponent() != null && !configuration.getComponent().isEmpty()) {
             options.put("componentName", configuration.getComponent());
@@ -570,12 +571,11 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
 
         // we use the same uri as the producer (so we have a little route for the rest api)
         String to = from;
+        answer.fromRest(from);
+        answer.id(routeId);
+        answer.to(to);
 
-        // the route should be from this rest endpoint
-        route.fromRest(from);
-        route.to(to);
-        route.setRestDefinition(this);
-        answer.add(route);
+        return answer;
     }
 
     private void addRouteDefinition(CamelContext camelContext, List<RouteDefinition> answer, String component) {
@@ -738,6 +738,7 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
 
             // the route should be from this rest endpoint
             route.fromRest(from);
+            route.id(routeId);
             route.setRestDefinition(this);
             answer.add(route);
         }


[4/6] camel git commit: camel-jackson - lets be less verbose on startup

Posted by da...@apache.org.
camel-jackson - lets be less verbose on startup


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

Branch: refs/heads/master
Commit: 4abb3b1c1580d65894da915579abbb96993e8d89
Parents: df75c1c
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Oct 24 11:51:18 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Oct 24 12:43:21 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/component/jackson/JacksonDataFormat.java    | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4abb3b1c/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
index 6aa465d..381b81a 100644
--- a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
+++ b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
@@ -402,7 +402,7 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat, Dat
         if (enableJaxbAnnotationModule) {
             // Enables JAXB processing
             JaxbAnnotationModule module = new JaxbAnnotationModule();
-            LOG.info("Registering module: {}", module);
+            LOG.debug("Registering JaxbAnnotationModule: {}", module);
             objectMapper.registerModule(module);
         }
 
@@ -466,7 +466,7 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat, Dat
 
         if (modules != null) {
             for (Module module : modules) {
-                LOG.info("Registering module: {}", module);
+                LOG.debug("Registering module: {}", module);
                 objectMapper.registerModules(module);
             }
         }
@@ -476,7 +476,7 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat, Dat
                 String name = o.toString();
                 Class<Module> clazz = camelContext.getClassResolver().resolveMandatoryClass(name, Module.class);
                 Module module = camelContext.getInjector().newInstance(clazz);
-                LOG.info("Registering module: {} -> {}", name, module);
+                LOG.debug("Registering module: {} -> {}", name, module);
                 objectMapper.registerModule(module);
             }
         }
@@ -488,7 +488,7 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat, Dat
                     name = name.substring(1);
                 }
                 Module module = CamelContextHelper.mandatoryLookup(camelContext, name, Module.class);
-                LOG.info("Registering module: {} -> {}", name, module);
+                LOG.debug("Registering module: {} -> {}", name, module);
                 objectMapper.registerModule(module);
             }
         }


[5/6] camel git commit: CAMEL-9251: rest-dsl - Allow to configure api-doc route id

Posted by da...@apache.org.
CAMEL-9251: rest-dsl - Allow to configure api-doc route id


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

Branch: refs/heads/master
Commit: 9ff11b57f5f5ea8efee195680617930d67d2c8d9
Parents: 041f7e5
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Oct 24 12:37:58 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Oct 24 12:43:22 2015 +0200

----------------------------------------------------------------------
 .../model/rest/RestConfigurationDefinition.java | 29 ++++++++++++++++++++
 .../apache/camel/model/rest/RestDefinition.java |  5 +++-
 .../org/apache/camel/spi/RestConfiguration.java | 16 +++++++++++
 3 files changed, 49 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9ff11b57/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java
index 7429fb1..155a513 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java
@@ -61,6 +61,9 @@ public class RestConfigurationDefinition {
     private String apiContextPath;
 
     @XmlAttribute
+    private String apiContextRouteId;
+
+    @XmlAttribute
     private String apiContextIdPattern;
 
     @XmlAttribute
@@ -199,6 +202,21 @@ public class RestConfigurationDefinition {
         this.apiContextPath = contextPath;
     }
 
+    public String getApiContextRouteId() {
+        return apiContextRouteId;
+    }
+
+    /**
+     * Sets the route id to use for the route that services the REST API.
+     * <p/>
+     * The route will by default use an auto assigned route id.
+     *
+     * @param apiContextRouteId  the route id
+     */
+    public void setApiContextRouteId(String apiContextRouteId) {
+        this.apiContextRouteId = apiContextRouteId;
+    }
+
     public String getApiContextIdPattern() {
         return apiContextIdPattern;
     }
@@ -444,6 +462,14 @@ public class RestConfigurationDefinition {
     }
 
     /**
+     * Sets the route id to use for the route that services the REST API.
+     */
+    public RestConfigurationDefinition apiContextRouteId(String routeId) {
+        setApiContextRouteId(routeId);
+        return this;
+    }
+
+    /**
      * Sets an CamelContext id pattern to only allow Rest APIs from rest services within CamelContext's which name matches the pattern.
      * <p/>
      * The pattern uses the rules from {@link org.apache.camel.util.EndpointHelper#matchPattern(String, String)}
@@ -625,6 +651,9 @@ public class RestConfigurationDefinition {
         if (apiContextPath != null) {
             answer.setApiContextPath(CamelContextHelper.parseText(context, apiContextPath));
         }
+        if (apiContextRouteId != null) {
+            answer.setApiContextRouteId(CamelContextHelper.parseText(context, apiContextRouteId));
+        }
         if (apiContextIdPattern != null) {
             // special to allow #name# to refer to itself
             if ("#name#".equals(apiComponent)) {

http://git-wip-us.apache.org/repos/asf/camel/blob/9ff11b57/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
index fd4970a..8bbbe71 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
@@ -550,7 +550,10 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
         // append options
         Map<String, Object> options = new HashMap<String, Object>();
 
-        String routeId = answer.idOrCreate(camelContext.getNodeIdFactory());
+        String routeId = configuration.getApiContextRouteId();
+        if (routeId == null) {
+            routeId = answer.idOrCreate(camelContext.getNodeIdFactory());
+        }
         options.put("routeId", routeId);
         if (configuration.getComponent() != null && !configuration.getComponent().isEmpty()) {
             options.put("componentName", configuration.getComponent());

http://git-wip-us.apache.org/repos/asf/camel/blob/9ff11b57/camel-core/src/main/java/org/apache/camel/spi/RestConfiguration.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/spi/RestConfiguration.java b/camel-core/src/main/java/org/apache/camel/spi/RestConfiguration.java
index 8c057ea..aec8453 100644
--- a/camel-core/src/main/java/org/apache/camel/spi/RestConfiguration.java
+++ b/camel-core/src/main/java/org/apache/camel/spi/RestConfiguration.java
@@ -44,6 +44,7 @@ public class RestConfiguration {
     private int port;
     private String contextPath;
     private String apiContextPath;
+    private String apiContextRouteId;
     private String apiContextIdPattern;
     private boolean apiContextListing;
     private RestHostNameResolver restHostNameResolver = RestHostNameResolver.localHostName;
@@ -187,6 +188,21 @@ public class RestConfiguration {
         this.apiContextPath = contextPath;
     }
 
+    public String getApiContextRouteId() {
+        return apiContextRouteId;
+    }
+
+    /**
+     * Sets the route id to use for the route that services the REST API.
+     * <p/>
+     * The route will by default use an auto assigned route id.
+     *
+     * @param apiContextRouteId  the route id
+     */
+    public void setApiContextRouteId(String apiContextRouteId) {
+        this.apiContextRouteId = apiContextRouteId;
+    }
+
     public String getApiContextIdPattern() {
         return apiContextIdPattern;
     }


[2/6] camel git commit: CAMEL-9251: rest-dsl - Allow to configure api-doc route id

Posted by da...@apache.org.
CAMEL-9251: rest-dsl - Allow to configure api-doc route id


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

Branch: refs/heads/camel-2.16.x
Commit: d90d0ad423da8ad1888aa1ed24ed6dea66a17a10
Parents: 73cc80e
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Oct 24 12:37:58 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Oct 24 12:42:47 2015 +0200

----------------------------------------------------------------------
 .../model/rest/RestConfigurationDefinition.java | 29 ++++++++++++++++++++
 .../apache/camel/model/rest/RestDefinition.java |  5 +++-
 .../org/apache/camel/spi/RestConfiguration.java | 16 +++++++++++
 3 files changed, 49 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d90d0ad4/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java
index 7429fb1..155a513 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java
@@ -61,6 +61,9 @@ public class RestConfigurationDefinition {
     private String apiContextPath;
 
     @XmlAttribute
+    private String apiContextRouteId;
+
+    @XmlAttribute
     private String apiContextIdPattern;
 
     @XmlAttribute
@@ -199,6 +202,21 @@ public class RestConfigurationDefinition {
         this.apiContextPath = contextPath;
     }
 
+    public String getApiContextRouteId() {
+        return apiContextRouteId;
+    }
+
+    /**
+     * Sets the route id to use for the route that services the REST API.
+     * <p/>
+     * The route will by default use an auto assigned route id.
+     *
+     * @param apiContextRouteId  the route id
+     */
+    public void setApiContextRouteId(String apiContextRouteId) {
+        this.apiContextRouteId = apiContextRouteId;
+    }
+
     public String getApiContextIdPattern() {
         return apiContextIdPattern;
     }
@@ -444,6 +462,14 @@ public class RestConfigurationDefinition {
     }
 
     /**
+     * Sets the route id to use for the route that services the REST API.
+     */
+    public RestConfigurationDefinition apiContextRouteId(String routeId) {
+        setApiContextRouteId(routeId);
+        return this;
+    }
+
+    /**
      * Sets an CamelContext id pattern to only allow Rest APIs from rest services within CamelContext's which name matches the pattern.
      * <p/>
      * The pattern uses the rules from {@link org.apache.camel.util.EndpointHelper#matchPattern(String, String)}
@@ -625,6 +651,9 @@ public class RestConfigurationDefinition {
         if (apiContextPath != null) {
             answer.setApiContextPath(CamelContextHelper.parseText(context, apiContextPath));
         }
+        if (apiContextRouteId != null) {
+            answer.setApiContextRouteId(CamelContextHelper.parseText(context, apiContextRouteId));
+        }
         if (apiContextIdPattern != null) {
             // special to allow #name# to refer to itself
             if ("#name#".equals(apiComponent)) {

http://git-wip-us.apache.org/repos/asf/camel/blob/d90d0ad4/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
index fd4970a..8bbbe71 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
@@ -550,7 +550,10 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
         // append options
         Map<String, Object> options = new HashMap<String, Object>();
 
-        String routeId = answer.idOrCreate(camelContext.getNodeIdFactory());
+        String routeId = configuration.getApiContextRouteId();
+        if (routeId == null) {
+            routeId = answer.idOrCreate(camelContext.getNodeIdFactory());
+        }
         options.put("routeId", routeId);
         if (configuration.getComponent() != null && !configuration.getComponent().isEmpty()) {
             options.put("componentName", configuration.getComponent());

http://git-wip-us.apache.org/repos/asf/camel/blob/d90d0ad4/camel-core/src/main/java/org/apache/camel/spi/RestConfiguration.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/spi/RestConfiguration.java b/camel-core/src/main/java/org/apache/camel/spi/RestConfiguration.java
index 8c057ea..aec8453 100644
--- a/camel-core/src/main/java/org/apache/camel/spi/RestConfiguration.java
+++ b/camel-core/src/main/java/org/apache/camel/spi/RestConfiguration.java
@@ -44,6 +44,7 @@ public class RestConfiguration {
     private int port;
     private String contextPath;
     private String apiContextPath;
+    private String apiContextRouteId;
     private String apiContextIdPattern;
     private boolean apiContextListing;
     private RestHostNameResolver restHostNameResolver = RestHostNameResolver.localHostName;
@@ -187,6 +188,21 @@ public class RestConfiguration {
         this.apiContextPath = contextPath;
     }
 
+    public String getApiContextRouteId() {
+        return apiContextRouteId;
+    }
+
+    /**
+     * Sets the route id to use for the route that services the REST API.
+     * <p/>
+     * The route will by default use an auto assigned route id.
+     *
+     * @param apiContextRouteId  the route id
+     */
+    public void setApiContextRouteId(String apiContextRouteId) {
+        this.apiContextRouteId = apiContextRouteId;
+    }
+
     public String getApiContextIdPattern() {
         return apiContextIdPattern;
     }