camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [10/33] git commit: CAMEL-7354: Migrating rest DSL to be separated from regular Camel routes.
Date Sun, 20 Jul 2014 06:53:16 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/aff59879
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/aff59879
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/aff59879

Branch: refs/heads/master
Commit: aff598798e6830c442cfd260e984c766eebfc7cc
Parents: 2ffb9a5
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Jul 2 19:34:20 2014 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat Jul 19 09:38:49 2014 +0200

----------------------------------------------------------------------
 .../restbinding/RestBindingComponent.java       | 21 --------
 .../restbinding/RestBindingEndpoint.java        | 54 +++++++++++++++++---
 .../apache/camel/model/AggregateDefinition.java |  2 +-
 .../apache/camel/model/ChoiceDefinition.java    |  2 +-
 .../org/apache/camel/model/ExpressionNode.java  |  2 +-
 .../apache/camel/model/ProcessorDefinition.java |  2 +-
 .../apache/camel/model/rest/PathDefinition.java |  2 +-
 .../apache/camel/model/rest/RestDefinition.java |  2 +-
 .../apache/camel/model/rest/VerbDefinition.java | 25 ++++++---
 .../apache/camel/spi/RestBindingCapable.java    | 37 --------------
 .../apache/camel/spi/RestConsumerFactory.java   | 43 ++++++++++++++++
 .../DummyRestBindingCapableComponent.java       | 51 ------------------
 .../restbinding/DummyRestConsumerFactory.java   | 43 ++++++++++++++++
 .../component/restbinding/FromRestGetTest.java  | 20 ++++----
 .../management/ManagedFromRestGetTest.java      | 18 +++----
 .../restbinding/SpringFromRestGetTest.xml       |  4 +-
 .../restbinding/DummyRestConsumerFactory.java   | 43 ++++++++++++++++
 .../component/restbinding/FromRestGetTest.java  | 10 ++--
 .../component/restbinding/FromRestGetTest.xml   |  4 +-
 19 files changed, 225 insertions(+), 160 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/aff59879/camel-core/src/main/java/org/apache/camel/component/restbinding/RestBindingComponent.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/restbinding/RestBindingComponent.java
b/camel-core/src/main/java/org/apache/camel/component/restbinding/RestBindingComponent.java
index d24b72e..b10f06f 100644
--- a/camel-core/src/main/java/org/apache/camel/component/restbinding/RestBindingComponent.java
+++ b/camel-core/src/main/java/org/apache/camel/component/restbinding/RestBindingComponent.java
@@ -18,10 +18,8 @@ package org.apache.camel.component.restbinding;
 
 import java.util.Map;
 
-import org.apache.camel.Component;
 import org.apache.camel.Endpoint;
 import org.apache.camel.impl.UriEndpointComponent;
-import org.apache.camel.spi.RestBindingCapable;
 import org.apache.camel.util.ObjectHelper;
 
 public class RestBindingComponent extends UriEndpointComponent {
@@ -32,8 +30,6 @@ public class RestBindingComponent extends UriEndpointComponent {
 
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object>
parameters) throws Exception {
-        preCheckConditions();
-
         RestBindingEndpoint answer = new RestBindingEndpoint(uri, this);
         setProperties(answer, parameters);
         answer.setParameters(parameters);
@@ -51,21 +47,4 @@ public class RestBindingComponent extends UriEndpointComponent {
         return answer;
     }
 
-
-    protected void preCheckConditions() throws Exception {
-        if (lookupRestBindingCapableComponent() == null) {
-            throw new IllegalStateException("There are no registered components in CamelContext
that is RestBindingCapable");
-        }
-    }
-
-    public RestBindingCapable lookupRestBindingCapableComponent() {
-        for (String id : getCamelContext().getComponentNames()) {
-            Component component = getCamelContext().getComponent(id);
-            if (component instanceof RestBindingCapable) {
-                return (RestBindingCapable) component;
-            }
-        }
-        return null;
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/aff59879/camel-core/src/main/java/org/apache/camel/component/restbinding/RestBindingEndpoint.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/restbinding/RestBindingEndpoint.java
b/camel-core/src/main/java/org/apache/camel/component/restbinding/RestBindingEndpoint.java
index da6ce09..42595b2 100644
--- a/camel-core/src/main/java/org/apache/camel/component/restbinding/RestBindingEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/restbinding/RestBindingEndpoint.java
@@ -17,12 +17,14 @@
 package org.apache.camel.component.restbinding;
 
 import java.util.Map;
+import java.util.Set;
 
+import org.apache.camel.Component;
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.impl.DefaultEndpoint;
-import org.apache.camel.spi.RestBindingCapable;
+import org.apache.camel.spi.RestConsumerFactory;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 
@@ -35,6 +37,8 @@ public class RestBindingEndpoint extends DefaultEndpoint {
     private String path;
     @UriParam
     private String accept;
+    @UriParam
+    private String componentName;
 
     private Map<String, Object> parameters;
 
@@ -71,6 +75,14 @@ public class RestBindingEndpoint extends DefaultEndpoint {
         this.accept = accept;
     }
 
+    public String getComponentName() {
+        return componentName;
+    }
+
+    public void setComponentName(String componentName) {
+        this.componentName = componentName;
+    }
+
     public Map<String, Object> getParameters() {
         return parameters;
     }
@@ -86,16 +98,42 @@ public class RestBindingEndpoint extends DefaultEndpoint {
 
     @Override
     public Consumer createConsumer(Processor processor) throws Exception {
-        // create the consumer directly from the component that supports rest binding
-        // TODO: should we have a RestBindingConsumer class that delegates to the actual
consumer?
-        // TODO: what if there is 2+ RestBindingCapable components in the registry?
-        RestBindingCapable component = getComponent().lookupRestBindingCapableComponent();
-        if (component != null) {
-            Consumer consumer = component.createConsumer(this, processor);
+        RestConsumerFactory factory = null;
+
+        if (getComponentName() != null) {
+            Component comp = getCamelContext().getComponent(getComponentName());
+            if (comp != null && comp instanceof RestConsumerFactory) {
+                factory = (RestConsumerFactory) comp;
+            } else {
+                throw new IllegalArgumentException("Component " + getComponentName() + "
is not a RestConsumerFactory");
+            }
+        }
+
+        // try all components
+        if (factory == null) {
+            for (String name : getCamelContext().getComponentNames()) {
+                Component comp = getCamelContext().getComponent(name);
+                if (comp != null && comp instanceof RestConsumerFactory) {
+                    factory = (RestConsumerFactory) comp;
+                    break;
+                }
+            }
+        }
+
+        // lookup in registry
+        if (factory == null) {
+            Set<RestConsumerFactory> factories = getCamelContext().getRegistry().findByType(RestConsumerFactory.class);
+            if (factories != null && factories.size() == 1) {
+                factory = factories.iterator().next();
+            }
+        }
+
+        if (factory != null) {
+            Consumer consumer = factory.createConsumer(getCamelContext(), processor, getVerb(),
getPath(), getAccept(), getParameters());
             configureConsumer(consumer);
             return consumer;
         } else {
-            throw new IllegalStateException("There are no registered components in CamelContext
that is RestBindingCapable");
+            throw new IllegalStateException("Cannot find RestConsumerFactory in Registry
or as a Component to use");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/aff59879/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java b/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java
index e31743f..59c2104 100644
--- a/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java
@@ -263,7 +263,7 @@ public class AggregateDefinition extends ProcessorDefinition<AggregateDefinition
     }
 
     @Override
-    protected void configureChild(ProcessorDefinition<?> output) {
+    public void configureChild(ProcessorDefinition<?> output) {
         if (expression != null && expression instanceof ExpressionClause) {
             ExpressionClause<?> clause = (ExpressionClause<?>) expression;
             if (clause.getExpressionType() != null) {

http://git-wip-us.apache.org/repos/asf/camel/blob/aff59879/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java
index e8e31e4..202f86a 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java
@@ -227,7 +227,7 @@ public class ChoiceDefinition extends ProcessorDefinition<ChoiceDefinition>
{
     }
 
     @Override
-    protected void configureChild(ProcessorDefinition<?> output) {
+    public void configureChild(ProcessorDefinition<?> output) {
         if (whenClauses == null || whenClauses.isEmpty()) {
             return;
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/aff59879/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java b/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java
index ef64c2d..2e1f764 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java
@@ -121,7 +121,7 @@ public class ExpressionNode extends ProcessorDefinition<ExpressionNode>
{
     }
 
     @Override
-    protected void configureChild(ProcessorDefinition<?> output) {
+    public void configureChild(ProcessorDefinition<?> output) {
         // reuse the logic from pre create processor
         preCreateProcessor();
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/aff59879/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
----------------------------------------------------------------------
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 833457c..1503d3c 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
@@ -641,7 +641,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
      *
      * @param output the child to be added as output to this
      */
-    protected void configureChild(ProcessorDefinition<?> output) {
+    public void configureChild(ProcessorDefinition<?> output) {
         // noop
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/aff59879/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
index bfa8d79..d646916 100644
--- 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
@@ -87,7 +87,7 @@ public class PathDefinition {
         }
 
         VerbDefinition verb = getVerbs().get(getVerbs().size() - 1);
-        verb.setTo(new ToDefinition(url));
+        verb.addOutput(new ToDefinition(url));
 
         return this;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/aff59879/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 d63badc..db48564 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
@@ -90,7 +90,7 @@ public class RestDefinition {
                 RouteDefinition route = new RouteDefinition();
                 route.fromRest(from);
                 answer.add(route);
-                route.getOutputs().add(verb.getTo());
+                route.getOutputs().addAll(verb.getOutputs());
             }
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/aff59879/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
index 388b4ea..5ef289e 100644
--- 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
@@ -16,13 +16,15 @@
  */
 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;
 
-import org.apache.camel.model.ToDefinition;
+import org.apache.camel.model.ProcessorDefinition;
 
 @XmlRootElement(name = "verb")
 @XmlAccessorType(XmlAccessType.FIELD)
@@ -34,8 +36,8 @@ public class VerbDefinition {
     @XmlAttribute
     private String uri;
 
-    @XmlElementRef(required = false)
-    private ToDefinition to;
+    @XmlElementRef
+    private List<ProcessorDefinition<?>> outputs = new ArrayList<ProcessorDefinition<?>>();
 
     public String getMethod() {
         return method;
@@ -53,12 +55,21 @@ public class VerbDefinition {
         this.uri = uri;
     }
 
-    public ToDefinition getTo() {
-        return to;
+    public List<ProcessorDefinition<?>> getOutputs() {
+        return outputs;
     }
 
-    public void setTo(ToDefinition to) {
-        this.to = to;
+    public void setOutputs(List<ProcessorDefinition<?>> outputs) {
+        this.outputs = outputs;
+
+        if (outputs != null) {
+            for (ProcessorDefinition<?> output : outputs) {
+                output.configureChild(output);
+            }
+        }
     }
 
+    public void addOutput(ProcessorDefinition<?> output) {
+        outputs.add(output);
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/aff59879/camel-core/src/main/java/org/apache/camel/spi/RestBindingCapable.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/spi/RestBindingCapable.java b/camel-core/src/main/java/org/apache/camel/spi/RestBindingCapable.java
deleted file mode 100644
index 645f1bc..0000000
--- a/camel-core/src/main/java/org/apache/camel/spi/RestBindingCapable.java
+++ /dev/null
@@ -1,37 +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.spi;
-
-import org.apache.camel.Consumer;
-import org.apache.camel.Processor;
-import org.apache.camel.component.restbinding.RestBindingEndpoint;
-
-public interface RestBindingCapable {
-
-    /**
-     * Creates a new REST <a
-     * href="http://camel.apache.org/event-driven-consumer.html">Event
-     * Driven Consumer</a>, using the details from the {@link org.apache.camel.component.restbinding.RestBindingEndpoint},
-     * which consumes messages from the endpoint using the given processor
-     *
-     * @param endpoint  the binding endpoint
-     * @param processor the processor
-     * @return a newly created REST consumer
-     * @throws Exception can be thrown
-     */
-    Consumer createConsumer(RestBindingEndpoint endpoint, Processor processor) throws Exception;
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/aff59879/camel-core/src/main/java/org/apache/camel/spi/RestConsumerFactory.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/spi/RestConsumerFactory.java b/camel-core/src/main/java/org/apache/camel/spi/RestConsumerFactory.java
new file mode 100644
index 0000000..bab308a
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/spi/RestConsumerFactory.java
@@ -0,0 +1,43 @@
+/**
+ * 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.spi;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+
+public interface RestConsumerFactory {
+
+    /**
+     * Creates a new REST <a
+     * href="http://camel.apache.org/event-driven-consumer.html">Event
+     * Driven Consumer</a>, which consumes messages from the endpoint using the given
processor
+     *
+     * @param camelContext the camel context
+     * @param processor    the processor
+     * @param verb         HTTP verb such as GET, POST
+     * @param path         HTTP context-path
+     * @param accept       accept-type, is <tt>null</tt> to accept anything
+     * @param parameters   additional parameters
+     * @return a newly created REST consumer
+     * @throws Exception can be thrown
+     */
+    Consumer createConsumer(CamelContext camelContext, Processor processor,
+                            String verb, String path, String accept, Map<String, Object>
parameters) throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/aff59879/camel-core/src/test/java/org/apache/camel/component/restbinding/DummyRestBindingCapableComponent.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/restbinding/DummyRestBindingCapableComponent.java
b/camel-core/src/test/java/org/apache/camel/component/restbinding/DummyRestBindingCapableComponent.java
deleted file mode 100644
index cf3a4ae..0000000
--- a/camel-core/src/test/java/org/apache/camel/component/restbinding/DummyRestBindingCapableComponent.java
+++ /dev/null
@@ -1,51 +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.component.restbinding;
-
-import java.util.Map;
-
-import org.apache.camel.Consumer;
-import org.apache.camel.Endpoint;
-import org.apache.camel.Processor;
-import org.apache.camel.component.seda.SedaEndpoint;
-import org.apache.camel.impl.ActiveMQUuidGenerator;
-import org.apache.camel.impl.DefaultComponent;
-import org.apache.camel.spi.RestBindingCapable;
-
-public class DummyRestBindingCapableComponent extends DefaultComponent implements RestBindingCapable
{
-
-    public void enlist() {
-        getCamelContext().addComponent("dummy-rest", this);
-    }
-
-    @Override
-    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object>
parameters) throws Exception {
-        return null;
-    }
-
-    @Override
-    public Consumer createConsumer(RestBindingEndpoint endpoint, Processor processor) throws
Exception {
-        // just use a seda endpoint for testing purpose
-        String id = ActiveMQUuidGenerator.generateSanitizedId(endpoint.getPath());
-        // remove leading dash as we add that ourselves
-        if (id.startsWith("-")) {
-            id = id.substring(1);
-        }
-        SedaEndpoint seda = getCamelContext().getEndpoint("seda:" + endpoint.getVerb() +
"-" + id, SedaEndpoint.class);
-        return seda.createConsumer(processor);
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/aff59879/camel-core/src/test/java/org/apache/camel/component/restbinding/DummyRestConsumerFactory.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/restbinding/DummyRestConsumerFactory.java
b/camel-core/src/test/java/org/apache/camel/component/restbinding/DummyRestConsumerFactory.java
new file mode 100644
index 0000000..95d8106
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/component/restbinding/DummyRestConsumerFactory.java
@@ -0,0 +1,43 @@
+/**
+ * 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.component.restbinding;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.component.seda.SedaEndpoint;
+import org.apache.camel.impl.ActiveMQUuidGenerator;
+import org.apache.camel.spi.RestConsumerFactory;
+
+public class DummyRestConsumerFactory implements RestConsumerFactory {
+
+    @Override
+    public Consumer createConsumer(CamelContext camelContext, Processor processor,
+                                   String verb, String path, String accept, Map<String,
Object> parameters) throws Exception {
+        // just use a seda endpoint for testing purpose
+        String id = ActiveMQUuidGenerator.generateSanitizedId(path);
+        // remove leading dash as we add that ourselves
+        if (id.startsWith("-")) {
+            id = id.substring(1);
+        }
+        SedaEndpoint seda = camelContext.getEndpoint("seda:" + verb + "-" + id, SedaEndpoint.class);
+        return seda.createConsumer(processor);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/aff59879/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 5e0565c..72798fc 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
@@ -16,22 +16,20 @@
  */
 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.impl.JndiRegistry;
+import org.apache.camel.model.ToDefinition;
 import org.apache.camel.model.rest.PathDefinition;
 import org.apache.camel.model.rest.RestDefinition;
 
 public class FromRestGetTest extends ContextTestSupport {
 
     @Override
-    protected CamelContext createCamelContext() throws Exception {
-        CamelContext context = super.createCamelContext();
-
-        // register our dummy rest capable component
-        context.addComponent("dummy-rest", new DummyRestBindingCapableComponent());
-
-        return context;
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = super.createRegistry();
+        jndi.bind("dummy-test", new DummyRestConsumerFactory());
+        return jndi;
     }
 
     public void testFromRestModel() {
@@ -45,10 +43,12 @@ public class FromRestGetTest extends ContextTestSupport {
         assertEquals("/say", path.getUri());
 
         assertEquals("/hello", path.getVerbs().get(0).getUri());
-        assertEquals("direct:hello", path.getVerbs().get(0).getTo().getUri());
+        ToDefinition to = assertIsInstanceOf(ToDefinition.class, path.getVerbs().get(0).getOutputs().get(0));
+        assertEquals("direct:hello", to.getUri());
 
         assertEquals("/bye", path.getVerbs().get(1).getUri());
-        assertEquals("direct:bye", path.getVerbs().get(1).getTo().getUri());
+        to = assertIsInstanceOf(ToDefinition.class, path.getVerbs().get(1).getOutputs().get(0));
+        assertEquals("direct:bye", to.getUri());
 
         assertEquals(null, path.getVerbs().get(2).getUri());
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/aff59879/camel-core/src/test/java/org/apache/camel/management/ManagedFromRestGetTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/management/ManagedFromRestGetTest.java
b/camel-core/src/test/java/org/apache/camel/management/ManagedFromRestGetTest.java
index f70d372..17060bf 100644
--- a/camel-core/src/test/java/org/apache/camel/management/ManagedFromRestGetTest.java
+++ b/camel-core/src/test/java/org/apache/camel/management/ManagedFromRestGetTest.java
@@ -19,23 +19,17 @@ package org.apache.camel.management;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
-import org.apache.camel.CamelContext;
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.restbinding.DummyRestBindingCapableComponent;
-import org.apache.camel.model.rest.PathDefinition;
-import org.apache.camel.model.rest.RestDefinition;
+import org.apache.camel.component.restbinding.DummyRestConsumerFactory;
+import org.apache.camel.impl.JndiRegistry;
 
 public class ManagedFromRestGetTest extends ManagementTestSupport {
 
     @Override
-    protected CamelContext createCamelContext() throws Exception {
-        CamelContext context = super.createCamelContext();
-
-        // register our dummy rest capable component
-        context.addComponent("dummy-rest", new DummyRestBindingCapableComponent());
-
-        return context;
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = super.createRegistry();
+        jndi.bind("dummy-test", new DummyRestConsumerFactory());
+        return jndi;
     }
 
     public void testFromRestModel() throws Exception {

http://git-wip-us.apache.org/repos/asf/camel/blob/aff59879/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 12ae236..156a2c1 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,8 +22,8 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-  <!-- use a dummy rest component for the rest engine -->
-  <bean id="dummy-rest" class="org.apache.camel.component.restbinding.DummyRestBindingCapableComponent"
init-method="enlist"/>
+  <!-- use a dummy rest consumer factory for the rest engine -->
+  <bean id="dummy-rest" class="org.apache.camel.component.restbinding.DummyRestConsumerFactory"/>
 
   <camelContext xmlns="http://camel.apache.org/schema/spring">
 

http://git-wip-us.apache.org/repos/asf/camel/blob/aff59879/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/component/restbinding/DummyRestConsumerFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/component/restbinding/DummyRestConsumerFactory.java
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/component/restbinding/DummyRestConsumerFactory.java
new file mode 100644
index 0000000..b8349c5
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/component/restbinding/DummyRestConsumerFactory.java
@@ -0,0 +1,43 @@
+/**
+ * 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.test.blueprint.component.restbinding;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.component.seda.SedaEndpoint;
+import org.apache.camel.impl.ActiveMQUuidGenerator;
+import org.apache.camel.spi.RestConsumerFactory;
+
+public class DummyRestConsumerFactory implements RestConsumerFactory {
+
+    @Override
+    public Consumer createConsumer(CamelContext camelContext, Processor processor,
+                                   String verb, String path, String accept, Map<String,
Object> parameters) throws Exception {
+        // just use a seda endpoint for testing purpose
+        String id = ActiveMQUuidGenerator.generateSanitizedId(path);
+        // remove leading dash as we add that ourselves
+        if (id.startsWith("-")) {
+            id = id.substring(1);
+        }
+        SedaEndpoint seda = camelContext.getEndpoint("seda:" + verb + "-" + id, SedaEndpoint.class);
+        return seda.createConsumer(processor);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/aff59879/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/component/restbinding/FromRestGetTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/component/restbinding/FromRestGetTest.java
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/component/restbinding/FromRestGetTest.java
index ce3b3b9..c02c1de 100644
--- a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/component/restbinding/FromRestGetTest.java
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/component/restbinding/FromRestGetTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.test.blueprint.component.restbinding;
 
+import org.apache.camel.model.ToDefinition;
 import org.apache.camel.model.rest.PathDefinition;
 import org.apache.camel.model.rest.RestDefinition;
 import org.apache.camel.test.blueprint.CamelBlueprintTestSupport;
@@ -30,7 +31,7 @@ public class FromRestGetTest extends CamelBlueprintTestSupport {
 
     @Test
     public void testFromRestModel() {
-        assertEquals(2, context.getRoutes().size());
+        assertEquals(2 + 3, context.getRoutes().size());
 
         RestDefinition rest = context.getRestDefinitions().get(0);
         assertNotNull(rest);
@@ -40,13 +41,14 @@ public class FromRestGetTest extends CamelBlueprintTestSupport {
         assertEquals("/say", path.getUri());
 
         assertEquals("/hello", path.getVerbs().get(0).getUri());
-        assertEquals("direct:hello", path.getVerbs().get(0).getTo().getUri());
+        ToDefinition to = assertIsInstanceOf(ToDefinition.class, path.getVerbs().get(0).getOutputs().get(0));
+        assertEquals("direct:hello", to.getUri());
 
         assertEquals("/bye", path.getVerbs().get(1).getUri());
-        assertEquals("direct:bye", path.getVerbs().get(1).getTo().getUri());
+        to = assertIsInstanceOf(ToDefinition.class, path.getVerbs().get(1).getOutputs().get(0));
+        assertEquals("direct:bye", to.getUri());
 
         assertEquals(null, path.getVerbs().get(2).getUri());
     }
 
-
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/aff59879/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/component/restbinding/FromRestGetTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/component/restbinding/FromRestGetTest.xml
b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/component/restbinding/FromRestGetTest.xml
index 806124b..2ba7b41 100644
--- a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/component/restbinding/FromRestGetTest.xml
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/component/restbinding/FromRestGetTest.xml
@@ -20,8 +20,8 @@
            xsi:schemaLocation="
              http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
 
-  <!-- use a dummy rest component for the rest engine -->
-  <!--<bean id="dummy-rest" class="org.apache.camel.component.restbinding.DummyRestBindingCapableComponent"/>-->
+  <!-- use a dummy rest consumer factory for the rest engine -->
+  <bean id="dummy-rest" class="org.apache.camel.test.blueprint.component.restbinding.DummyRestConsumerFactory"/>
 
   <camelContext xmlns="http://camel.apache.org/schema/blueprint">
 


Mime
View raw message