Repository: camel Updated Branches: refs/heads/master 2f63b13ef -> 540daa010
CAMEL-10036: Add api on rest-dsl to transform as routes using a specific rest configuration. Thanks to Jay mann for the patch. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/540daa01 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/540daa01 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/540daa01 Branch: refs/heads/master Commit: 540daa0102aa05253eb2953b8ea67cc7656fa422 Parents: 2f63b13 Author: Claus Ibsen <davscl...@apache.org> Authored: Fri Jun 10 08:55:15 2016 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Fri Jun 10 08:56:04 2016 +0200 ---------------------------------------------------------------------- .../apache/camel/model/rest/RestDefinition.java | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/540daa01/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 840e567..c7ba4b8 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 @@ -590,8 +590,12 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition> * Transforms this REST definition into a list of {@link org.apache.camel.model.RouteDefinition} which * Camel routing engine can add and run. This allows us to define REST services using this * REST DSL and turn those into regular Camel routes. + * + * @param camelContext The Camel context */ public List<RouteDefinition> asRouteDefinition(CamelContext camelContext) { + ObjectHelper.notNull(camelContext, "CamelContext"); + // sanity check this rest definition do not have duplicates validateUniquePaths(); @@ -605,6 +609,26 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition> return answer; } + /** + * Transforms this REST definition into a list of {@link org.apache.camel.model.RouteDefinition} which + * Camel routing engine can add and run. This allows us to define REST services using this + * REST DSL and turn those into regular Camel routes. + * + * @param camelContext The Camel context + * @param restConfiguration The rest configuration to use + */ + public List<RouteDefinition> asRouteDefinition(CamelContext camelContext, RestConfiguration restConfiguration) { + ObjectHelper.notNull(camelContext, "CamelContext"); + ObjectHelper.notNull(restConfiguration, "RestConfiguration"); + + // sanity check this rest definition do not have duplicates + validateUniquePaths(); + + List<RouteDefinition> answer = new ArrayList<RouteDefinition>(); + addRouteDefinition(camelContext, answer, restConfiguration.getComponent()); + return answer; + } + protected void validateUniquePaths() { Set<String> paths = new HashSet<String>(); for (VerbDefinition verb : verbs) {