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 2016/06/10 06:55:53 UTC
camel git commit: CAMEL-10036: Add api on rest-dsl to transform as
routes using a specific rest configuration. Thanks to Jay mann for the patch.
Repository: camel
Updated Branches:
refs/heads/camel-2.17.x 368cb746a -> 4bab34ec0
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/4bab34ec
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4bab34ec
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4bab34ec
Branch: refs/heads/camel-2.17.x
Commit: 4bab34ec06fb8a8508471d3bb756b6e72639db95
Parents: 368cb74
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Jun 10 08:55:15 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Jun 10 08:55:45 2016 +0200
----------------------------------------------------------------------
.../apache/camel/model/rest/RestDefinition.java | 24 ++++++++++++++++++++
1 file changed, 24 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/4bab34ec/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) {