camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [02/33] git commit: CAMEL-7354: Migrating rest DSL to be separated from regular Camel routes.
Date Sun, 20 Jul 2014 06:53:08 GMT
CAMEL-7354: Migrating rest DSL to be separated from regular Camel routes.


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

Branch: refs/heads/master
Commit: fe0f3f713dd54a4e84eefc7ac56139ed6556a9d0
Parents: 71eaf52
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Tue Jul 1 17:11:03 2014 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat Jul 19 09:38:47 2014 +0200

----------------------------------------------------------------------
 .../org/apache/camel/builder/RouteBuilder.java  | 10 ---
 .../java/org/apache/camel/model/Constants.java  |  3 +-
 .../apache/camel/model/FromRestDefinition.java  | 93 --------------------
 .../org/apache/camel/model/RouteDefinition.java | 10 ---
 .../apache/camel/model/RoutesDefinition.java    | 11 ---
 .../camel/model/rest/GetVerbDefinition.java     | 27 ++++++
 .../apache/camel/model/rest/PathDefinition.java | 52 +++++++++++
 .../camel/model/rest/PostVerbDefinition.java    | 27 ++++++
 .../apache/camel/model/rest/RestContainer.java  | 41 +++++++++
 .../apache/camel/model/rest/RestDefinition.java | 48 ++++++++++
 .../camel/model/rest/RestsDefinition.java       | 81 +++++++++++++++++
 .../apache/camel/model/rest/VerbDefinition.java | 50 +++++++++++
 .../apache/camel/model/rest/package-info.java   | 23 +++++
 .../resources/org/apache/camel/model/jaxb.index |  1 -
 .../org/apache/camel/model/rest/jaxb.index      | 21 +++++
 .../component/restbinding/FromRestGetTest.java  | 12 ++-
 .../blueprint/CamelContextFactoryBean.java      | 11 +++
 .../xml/AbstractCamelContextFactoryBean.java    |  6 +-
 .../camel/spring/CamelContextFactoryBean.java   | 11 +++
 .../restbinding/SpringFromRestGetTest.xml       | 31 +++++--
 20 files changed, 429 insertions(+), 140 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/fe0f3f71/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 4392d1b..e17dace 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
@@ -69,16 +69,6 @@ public abstract class RouteBuilder extends BuilderSupport implements RoutesBuild
     public abstract void configure() throws Exception;
 
     /**
-     * Creates a new REST route
-     */
-    public RouteDefinition fromRest(String verb, String path) {
-        getRouteCollection().setCamelContext(getContext());
-        RouteDefinition answer = getRouteCollection().fromRest(verb, path);
-        configureRoute(answer);
-        return answer;
-    }
-
-    /**
      * Creates a new route from the given URI input
      *
      * @param uri  the from uri

http://git-wip-us.apache.org/repos/asf/camel/blob/fe0f3f71/camel-core/src/main/java/org/apache/camel/model/Constants.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/Constants.java b/camel-core/src/main/java/org/apache/camel/model/Constants.java
index dab5a95..b33eef7 100644
--- a/camel-core/src/main/java/org/apache/camel/model/Constants.java
+++ b/camel-core/src/main/java/org/apache/camel/model/Constants.java
@@ -29,7 +29,8 @@ public final class Constants {
         + "org.apache.camel.model.config:"
         + "org.apache.camel.model.dataformat:"
         + "org.apache.camel.model.language:"
-        + "org.apache.camel.model.loadbalancer";
+        + "org.apache.camel.model.loadbalancer:"
+        + "org.apache.camel.model.rest";
 
     public static final String PLACEHOLDER_QNAME = "http://camel.apache.org/schema/placeholder";
 

http://git-wip-us.apache.org/repos/asf/camel/blob/fe0f3f71/camel-core/src/main/java/org/apache/camel/model/FromRestDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/FromRestDefinition.java b/camel-core/src/main/java/org/apache/camel/model/FromRestDefinition.java
deleted file mode 100644
index dca9ce4..0000000
--- a/camel-core/src/main/java/org/apache/camel/model/FromRestDefinition.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * 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.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlTransient;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.spi.RouteContext;
-
-@XmlRootElement(name = "fromRest")
-@XmlAccessorType(XmlAccessType.FIELD)
-public class FromRestDefinition extends FromDefinition {
-
-    // TODO: verb should be an enum
-
-    @XmlAttribute
-    private String verb;
-    @XmlAttribute
-    private String path;
-    @XmlAttribute
-    private String accept;
-    @XmlTransient
-    private Endpoint endpoint;
-
-    public FromRestDefinition() {
-    }
-
-    public FromRestDefinition(String verb, String path) {
-        this(verb, path, null);
-    }
-
-    public FromRestDefinition(String verb, String path, String accept) {
-        this.verb = verb;
-        this.path = path;
-        this.accept = accept;
-    }
-
-    public Endpoint resolveEndpoint(RouteContext context) {
-        if (endpoint == null) {
-            if (accept != null) {
-                return context.resolveEndpoint("rest-binding:" + verb + ":" + path + "?accept="
+ accept);
-            } else {
-                return context.resolveEndpoint("rest-binding:" + verb + ":" + path);
-            }
-        } else {
-            return endpoint;
-        }
-    }
-
-    @Override
-    public String toString() {
-        return "fromRest[" + getLabel() + "]";
-    }
-
-    @Override
-    public String getShortName() {
-        return "fromRest";
-    }
-
-    public String getLabel() {
-        return verb + "(" + "/" + path + ")";
-    }
-
-    public String getVerb() {
-        return verb;
-    }
-
-    public String getPath() {
-        return path;
-    }
-
-    public String getAccept() {
-        return accept;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/fe0f3f71/camel-core/src/main/java/org/apache/camel/model/RouteDefinition.java
----------------------------------------------------------------------
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 3caade6..05a5b5f 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
@@ -284,16 +284,6 @@ public class RouteDefinition extends ProcessorDefinition<RouteDefinition>
{
     // -----------------------------------------------------------------------
 
     /**
-     * Creates an REST input to the route
-     *
-     * @return the builder
-     */
-    public RouteDefinition fromRest(String verb, String path) {
-        getInputs().add(new FromRestDefinition(verb, path));
-        return this;
-    }
-
-    /**
      * Creates an input to the route
      *
      * @param uri the from uri

http://git-wip-us.apache.org/repos/asf/camel/blob/fe0f3f71/camel-core/src/main/java/org/apache/camel/model/RoutesDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/RoutesDefinition.java b/camel-core/src/main/java/org/apache/camel/model/RoutesDefinition.java
index b5929ec..ab99fe0 100644
--- a/camel-core/src/main/java/org/apache/camel/model/RoutesDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/RoutesDefinition.java
@@ -149,17 +149,6 @@ public class RoutesDefinition extends OptionalIdentifiedDefinition<RoutesDefinit
     }
 
     /**
-     * Creates a new REST route
-     *
-     * @return the builder
-     */
-    public RouteDefinition fromRest(String verb, String path) {
-        RouteDefinition route = createRoute();
-        route.fromRest(verb, path);
-        return route(route);
-    }
-
-    /**
      * Creates a new route from the given URI input
      *
      * @param uri  the from uri

http://git-wip-us.apache.org/repos/asf/camel/blob/fe0f3f71/camel-core/src/main/java/org/apache/camel/model/rest/GetVerbDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/GetVerbDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/GetVerbDefinition.java
new file mode 100644
index 0000000..f3e398e
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/GetVerbDefinition.java
@@ -0,0 +1,27 @@
+/**
+ * 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.rest;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "get")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class GetVerbDefinition extends VerbDefinition {
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/fe0f3f71/camel-core/src/main/java/org/apache/camel/model/rest/PathDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/PathDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/PathDefinition.java
new file mode 100644
index 0000000..e9c526b
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/PathDefinition.java
@@ -0,0 +1,52 @@
+/**
+ * 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.rest;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "path")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class PathDefinition {
+
+    @XmlAttribute
+    private String uri;
+
+    @XmlElementRef
+    private List<VerbDefinition> verbs = new ArrayList<VerbDefinition>();
+
+    public String getUri() {
+        return uri;
+    }
+
+    public void setUri(String uri) {
+        this.uri = uri;
+    }
+
+    public List<VerbDefinition> getVerbs() {
+        return verbs;
+    }
+
+    public void setVerbs(List<VerbDefinition> verbs) {
+        this.verbs = verbs;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/fe0f3f71/camel-core/src/main/java/org/apache/camel/model/rest/PostVerbDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/PostVerbDefinition.java
b/camel-core/src/main/java/org/apache/camel/model/rest/PostVerbDefinition.java
new file mode 100644
index 0000000..a5d2fb0
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/PostVerbDefinition.java
@@ -0,0 +1,27 @@
+/**
+ * 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.rest;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "post")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class PostVerbDefinition extends VerbDefinition {
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/fe0f3f71/camel-core/src/main/java/org/apache/camel/model/rest/RestContainer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestContainer.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestContainer.java
new file mode 100644
index 0000000..05dbdfb
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestContainer.java
@@ -0,0 +1,41 @@
+/**
+ * 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.rest;
+
+import java.util.List;
+import javax.xml.bind.annotation.XmlElementRef;
+
+/**
+ * Container to hold {@link RestDefinition Rest}.
+ */
+public interface RestContainer {
+
+    /**
+     * Returns the RESTs
+     *
+     * @return the RESTs
+     */
+    @XmlElementRef
+    List<RestDefinition> getRests();
+
+    /**
+     * Sets the RESTs to use
+     *
+     * @param rests the RESTs
+     */
+    void setRests(List<RestDefinition> rests);
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/fe0f3f71/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
new file mode 100644
index 0000000..a44b181
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
@@ -0,0 +1,48 @@
+/**
+ * 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.rest;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * Represents an XML &lt;rest/&gt; element
+ */
+@XmlRootElement(name = "rest")
+@XmlAccessorType(XmlAccessType.PROPERTY)
+public class RestDefinition {
+
+    @XmlAttribute
+    private String component;
+
+    private List<PathDefinition> paths = new ArrayList<PathDefinition>();
+
+    public List<PathDefinition> getPaths() {
+        return paths;
+    }
+
+    @XmlElementRef
+    public void setPaths(List<PathDefinition> paths) {
+        this.paths = paths;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/fe0f3f71/camel-core/src/main/java/org/apache/camel/model/rest/RestsDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestsDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestsDefinition.java
new file mode 100644
index 0000000..8361c17
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestsDefinition.java
@@ -0,0 +1,81 @@
+/**
+ * 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.rest;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.apache.camel.model.ModelCamelContext;
+import org.apache.camel.model.OptionalIdentifiedDefinition;
+
+/**
+ * Represents a collection of RESTs
+ */
+@XmlRootElement(name = "rests")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class RestsDefinition extends OptionalIdentifiedDefinition<RestsDefinition>
implements RestContainer {
+    @XmlElementRef
+    private List<RestDefinition> rests = new ArrayList<RestDefinition>();
+    @XmlTransient
+    private ModelCamelContext camelContext;
+
+    public RestsDefinition() {
+    }
+
+    @Override
+    public String toString() {
+        return "Rests: " + rests;
+    }
+
+    @Override
+    public String getShortName() {
+        return "rests";
+    }
+
+    public String getLabel() {
+        return "Rest " + getId();
+    }
+
+    // Properties
+    //-----------------------------------------------------------------------
+
+    public List<RestDefinition> getRests() {
+        return rests;
+    }
+
+    public void setRests(List<RestDefinition> rests) {
+        this.rests = rests;
+    }
+
+    public ModelCamelContext getCamelContext() {
+        return camelContext;
+    }
+
+    public void setCamelContext(ModelCamelContext camelContext) {
+        this.camelContext = camelContext;
+    }
+
+    // Fluent API
+    //-------------------------------------------------------------------------
+
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/fe0f3f71/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
new file mode 100644
index 0000000..b0f5050
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
@@ -0,0 +1,50 @@
+/**
+ * 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.rest;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElementRef;
+
+import org.apache.camel.model.ToDefinition;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+public abstract class VerbDefinition {
+
+    @XmlAttribute
+    private String uri;
+
+    @XmlElementRef(required = true)
+    private ToDefinition to;
+
+    public String getUri() {
+        return uri;
+    }
+
+    public void setUri(String uri) {
+        this.uri = uri;
+    }
+
+    public ToDefinition getTo() {
+        return to;
+    }
+
+    public void setTo(ToDefinition to) {
+        this.to = to;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/fe0f3f71/camel-core/src/main/java/org/apache/camel/model/rest/package-info.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/package-info.java b/camel-core/src/main/java/org/apache/camel/model/rest/package-info.java
new file mode 100644
index 0000000..d765338
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/package-info.java
@@ -0,0 +1,23 @@
+/**
+ * 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.
+ */
+
+
+/**
+ * The JAXB POJOs for the REST DSL
+ */
+@javax.xml.bind.annotation.XmlSchema(namespace = "http://camel.apache.org/schema/spring",
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
+package org.apache.camel.model.rest;

http://git-wip-us.apache.org/repos/asf/camel/blob/fe0f3f71/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
----------------------------------------------------------------------
diff --git a/camel-core/src/main/resources/org/apache/camel/model/jaxb.index b/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
index 61991d5..1e32f42 100644
--- a/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
+++ b/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
@@ -30,7 +30,6 @@ ExpressionSubElementDefinition
 FilterDefinition
 FinallyDefinition
 FromDefinition
-FromRestDefinition
 IdempotentConsumerDefinition
 InOnlyDefinition
 InOutDefinition

http://git-wip-us.apache.org/repos/asf/camel/blob/fe0f3f71/camel-core/src/main/resources/org/apache/camel/model/rest/jaxb.index
----------------------------------------------------------------------
diff --git a/camel-core/src/main/resources/org/apache/camel/model/rest/jaxb.index b/camel-core/src/main/resources/org/apache/camel/model/rest/jaxb.index
new file mode 100644
index 0000000..98ae8de
--- /dev/null
+++ b/camel-core/src/main/resources/org/apache/camel/model/rest/jaxb.index
@@ -0,0 +1,21 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+GetVerbDefinition
+PostVerbDefinition
+PathDefinition
+RestDefinition
+RestsDefinition
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/fe0f3f71/camel-core/src/test/java/org/apache/camel/component/restbinding/FromRestGetTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/restbinding/FromRestGetTest.java
b/camel-core/src/test/java/org/apache/camel/component/restbinding/FromRestGetTest.java
index 69141c4..5b11cb5 100644
--- a/camel-core/src/test/java/org/apache/camel/component/restbinding/FromRestGetTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/restbinding/FromRestGetTest.java
@@ -19,7 +19,6 @@ package org.apache.camel.component.restbinding;
 import org.apache.camel.CamelContext;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.model.FromRestDefinition;
 import org.apache.camel.model.RouteDefinition;
 
 public class FromRestGetTest extends ContextTestSupport {
@@ -34,7 +33,7 @@ public class FromRestGetTest extends ContextTestSupport {
         return context;
     }
 
-    public void testFromRestModel() {
+/*    public void testFromRestModel() {
         assertEquals(1, context.getRoutes().size());
 
         RouteDefinition route = context.getRouteDefinition("foo");
@@ -53,17 +52,16 @@ public class FromRestGetTest extends ContextTestSupport {
         template.sendBody("seda:get-hello", "Hello World");
 
         assertMockEndpointsSatisfied();
-    }
+    }*/
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                // fromRest().get("/hello")
-                fromRest("get", "/hello").routeId("foo")
-                    .to("mock:foo")
-                    .transform().constant("Bye World");
+//                rest()
+//                    .get("/hello").to("mock:foo")
+//                    .get("/bye").to("mock:bar");
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/fe0f3f71/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
index 0ead959..f9cbaa0 100644
--- a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
+++ b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
@@ -54,6 +54,7 @@ import org.apache.camel.model.RouteDefinition;
 import org.apache.camel.model.ThreadPoolProfileDefinition;
 import org.apache.camel.model.config.PropertiesDefinition;
 import org.apache.camel.model.dataformat.DataFormatsDefinition;
+import org.apache.camel.model.rest.RestDefinition;
 import org.apache.camel.spi.PackageScanFilter;
 import org.apache.camel.spi.Registry;
 import org.osgi.framework.BundleContext;
@@ -160,6 +161,8 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Blu
     private List<InterceptFromDefinition> interceptFroms = new ArrayList<InterceptFromDefinition>();
     @XmlElement(name = "interceptSendToEndpoint", required = false)
     private List<InterceptSendToEndpointDefinition> interceptSendToEndpoints = new
ArrayList<InterceptSendToEndpointDefinition>();
+    @XmlElement(name = "rest", required = false)
+    private List<RestDefinition> rests = new ArrayList<RestDefinition>();
     @XmlElement(name = "route", required = false)
     private List<RouteDefinition> routes = new ArrayList<RouteDefinition>();
     @XmlTransient
@@ -619,6 +622,14 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Blu
         this.routes = routes;
     }
 
+    public List<RestDefinition> getRests() {
+        return rests;
+    }
+
+    public void setRests(List<RestDefinition> rests) {
+        this.rests = rests;
+    }
+
     public boolean isImplicitId() {
         return implicitId;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/fe0f3f71/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
index ead2bf0..d411edd 100644
--- a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
+++ b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
@@ -60,6 +60,8 @@ import org.apache.camel.model.RouteDefinitionHelper;
 import org.apache.camel.model.ThreadPoolProfileDefinition;
 import org.apache.camel.model.config.PropertiesDefinition;
 import org.apache.camel.model.dataformat.DataFormatsDefinition;
+import org.apache.camel.model.rest.RestContainer;
+import org.apache.camel.model.rest.RestDefinition;
 import org.apache.camel.processor.interceptor.BacklogTracer;
 import org.apache.camel.processor.interceptor.Delayer;
 import org.apache.camel.processor.interceptor.HandleFault;
@@ -102,7 +104,7 @@ import org.slf4j.LoggerFactory;
  * @version 
  */
 @XmlAccessorType(XmlAccessType.FIELD)
-public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContext>
extends IdentifiedType implements RouteContainer {
+public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContext>
extends IdentifiedType implements RouteContainer, RestContainer {
     
     /**
      * JVM system property to control lazy loading of type converters.
@@ -535,6 +537,8 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
 
     public abstract List<RouteDefinition> getRoutes();
 
+    public abstract List<RestDefinition> getRests();
+
     public abstract List<? extends AbstractCamelEndpointFactoryBean> getEndpoints();
 
     public abstract List<? extends AbstractCamelRedeliveryPolicyFactoryBean> getRedeliveryPolicies();

http://git-wip-us.apache.org/repos/asf/camel/blob/fe0f3f71/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
index 7f89623..ba19118 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
@@ -52,6 +52,7 @@ import org.apache.camel.model.RouteDefinition;
 import org.apache.camel.model.ThreadPoolProfileDefinition;
 import org.apache.camel.model.config.PropertiesDefinition;
 import org.apache.camel.model.dataformat.DataFormatsDefinition;
+import org.apache.camel.model.rest.RestDefinition;
 import org.apache.camel.spi.PackageScanFilter;
 import org.apache.camel.spi.Registry;
 import org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer;
@@ -168,6 +169,8 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Spr
     private List<InterceptFromDefinition> interceptFroms = new ArrayList<InterceptFromDefinition>();
     @XmlElement(name = "interceptSendToEndpoint", required = false)
     private List<InterceptSendToEndpointDefinition> interceptSendToEndpoints = new
ArrayList<InterceptSendToEndpointDefinition>();
+    @XmlElement(name = "rest", required = false)
+    private List<RestDefinition> rests = new ArrayList<RestDefinition>();
     @XmlElement(name = "route", required = false)
     private List<RouteDefinition> routes = new ArrayList<RouteDefinition>();
     @XmlTransient
@@ -392,6 +395,14 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Spr
         this.routes = routes;
     }
 
+    public List<RestDefinition> getRests() {
+        return rests;
+    }
+
+    public void setRests(List<RestDefinition> rests) {
+        this.rests = rests;
+    }
+
     public List<CamelEndpointFactoryBean> getEndpoints() {
         return endpoints;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/fe0f3f71/components/camel-spring/src/test/resources/org/apache/camel/component/restbinding/SpringFromRestGetTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/component/restbinding/SpringFromRestGetTest.xml
b/components/camel-spring/src/test/resources/org/apache/camel/component/restbinding/SpringFromRestGetTest.xml
index 0626079..7a9242d 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/component/restbinding/SpringFromRestGetTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/component/restbinding/SpringFromRestGetTest.xml
@@ -22,14 +22,33 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-  <!-- use a dummy rest component and enlist it in the CamelContext -->
-  <bean id="dummy-rest" class="org.apache.camel.component.restbinding.DummyRestBindingCapableComponent"
-        init-method="enlist"/>
+  <!-- use a dummy rest component for the rest engine -->
+  <bean id="dummy-rest" class="org.apache.camel.component.restbinding.DummyRestBindingCapableComponent"/>
 
   <camelContext xmlns="http://camel.apache.org/schema/spring">
-    <route id="foo">
-      <fromRest verb="get" path="/hello"/>
-      <to uri="mock:foo"/>
+
+    <rest component="dummy-rest">
+      <path uri="/say">
+        <get uri="/hello">
+          <to uri="direct:hello"/>
+        </get>
+        <get uri="/bye">
+          <to uri="direct:bye"/>
+        </get>
+        <post>
+          <to uri="seda:update"/>
+        </post>
+      </path>
+    </rest>
+
+    <route>
+      <to uri="direct:hello"/>
+      <transform>
+        <constant>Hello World</constant>
+      </transform>
+    </route>
+    <route>
+      <to uri="direct:bye"/>
       <transform>
         <constant>Bye World</constant>
       </transform>


Mime
View raw message