Repository: camel
Updated Branches:
  refs/heads/master 37a31c283 -> bd364a95f


CAMEL-8038: Fixed @UriPath


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

Branch: refs/heads/master
Commit: 4883e1f5d51fad8a7bf0dc4348e95d19c7706d24
Parents: 37a31c2
Author: Claus Ibsen <davscl...@apache.org>
Authored: Wed Nov 26 11:28:03 2014 +0100
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Wed Nov 26 11:28:03 2014 +0100

----------------------------------------------------------------------
 .../component/binding/BindingEndpoint.java      | 43 +++++++++++++++++++-
 .../component/binding/BindingNameComponent.java | 10 +----
 .../camel/component/rest/RestEndpoint.java      |  7 ++--
 3 files changed, 46 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4883e1f5/camel-core/src/main/java/org/apache/camel/component/binding/BindingEndpoint.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/component/binding/BindingEndpoint.java
 
b/camel-core/src/main/java/org/apache/camel/component/binding/BindingEndpoint.java
index b20afa7..4ab848d 100644
--- 
a/camel-core/src/main/java/org/apache/camel/component/binding/BindingEndpoint.java
+++ 
b/camel-core/src/main/java/org/apache/camel/component/binding/BindingEndpoint.java
@@ -28,8 +28,12 @@ import org.apache.camel.processor.PipelineHelper;
 import org.apache.camel.spi.Binding;
 import org.apache.camel.spi.HasBinding;
 import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.util.CamelContextHelper;
 import org.apache.camel.util.ServiceHelper;
 
+import static org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint;
+
 /**
  * Applies a {@link org.apache.camel.spi.Binding} to an underlying {@link 
Endpoint} so that the binding processes messages
  * before its sent to the endpoint and processes messages received by the 
endpoint consumer before its passed
@@ -37,13 +41,27 @@ import org.apache.camel.util.ServiceHelper;
  */
 @UriEndpoint(scheme = "binding", consumerClass = 
BindingConsumerProcessor.class, label = "core,transformation")
 public class BindingEndpoint extends DefaultEndpoint implements HasBinding {
-    private final Binding binding;
-    private final Endpoint delegate;
 
+    @UriPath
+    private final String bindingName;
+    @UriPath
+    private final String delegateUri;
+    private Binding binding;
+    private Endpoint delegate;
+
+    @Deprecated
     public BindingEndpoint(String uri, Component component, Binding binding, 
Endpoint delegate) {
         super(uri, component);
         this.binding = binding;
         this.delegate = delegate;
+        this.bindingName = null;
+        this.delegateUri = null;
+    }
+
+    public BindingEndpoint(String uri, Component component, String 
bindingName, String delegateUri) {
+        super(uri, component);
+        this.bindingName = bindingName;
+        this.delegateUri = delegateUri;
     }
 
     @Override
@@ -72,6 +90,20 @@ public class BindingEndpoint extends DefaultEndpoint 
implements HasBinding {
     }
 
     /**
+     * Name of the binding to lookup in the Camel registry.
+     */
+    public String getBindingName() {
+        return bindingName;
+    }
+
+    /**
+     * Uri of the delegate endpoint.
+     */
+    public String getDelegateUri() {
+        return delegateUri;
+    }
+
+    /**
      * Applies the {@link Binding} processor to the given exchange before 
passing it on to the delegateProcessor (either a producer or consumer)
      */
     public void pipelineBindingProcessor(Processor bindingProcessor, Exchange 
exchange, Processor delegateProcessor) throws Exception {
@@ -83,6 +115,13 @@ public class BindingEndpoint extends DefaultEndpoint 
implements HasBinding {
 
     @Override
     protected void doStart() throws Exception {
+        if (binding == null) {
+            binding = CamelContextHelper.mandatoryLookup(getCamelContext(), 
bindingName, Binding.class);
+        }
+        if (delegate == null) {
+            delegate = getMandatoryEndpoint(getCamelContext(), delegateUri);
+        }
+
         // inject CamelContext
         if (binding instanceof CamelContextAware) {
             ((CamelContextAware) binding).setCamelContext(getCamelContext());

http://git-wip-us.apache.org/repos/asf/camel/blob/4883e1f5/camel-core/src/main/java/org/apache/camel/component/binding/BindingNameComponent.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/component/binding/BindingNameComponent.java
 
b/camel-core/src/main/java/org/apache/camel/component/binding/BindingNameComponent.java
index 558e0f7..3ed73e6 100644
--- 
a/camel-core/src/main/java/org/apache/camel/component/binding/BindingNameComponent.java
+++ 
b/camel-core/src/main/java/org/apache/camel/component/binding/BindingNameComponent.java
@@ -18,13 +18,8 @@ package org.apache.camel.component.binding;
 
 import java.util.Map;
 
-import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.impl.UriEndpointComponent;
-import org.apache.camel.spi.Binding;
-import org.apache.camel.util.CamelContextHelper;
-
-import static org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint;
 
 /**
  * To compose a Camel component with a Camel data-format as a single binding 
unit.
@@ -43,7 +38,6 @@ public class BindingNameComponent extends 
UriEndpointComponent {
 
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, 
Map<String, Object> parameters) throws Exception {
-        CamelContext camelContext = getCamelContext();
         int idx = remaining.indexOf(":");
         if (idx <= 0) {
             throw new IllegalArgumentException(BAD_FORMAT_MESSAGE);
@@ -53,9 +47,7 @@ public class BindingNameComponent extends 
UriEndpointComponent {
         if (delegateURI.isEmpty()) {
             throw new IllegalArgumentException(BAD_FORMAT_MESSAGE);
         }
-        Binding binding = CamelContextHelper.mandatoryLookup(camelContext, 
bindingName, Binding.class);
-        Endpoint delegate = getMandatoryEndpoint(camelContext, delegateURI);
-        return new BindingEndpoint(uri, this, binding,  delegate);
+        return new BindingEndpoint(uri, this, bindingName, delegateURI);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/4883e1f5/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java 
b/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
index 56cc17e..79ceae4 100644
--- a/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
@@ -29,17 +29,18 @@ import org.apache.camel.spi.RestConfiguration;
 import org.apache.camel.spi.RestConsumerFactory;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
 import org.apache.camel.util.HostUtils;
 import org.apache.camel.util.ObjectHelper;
 
 @UriEndpoint(scheme = "rest", label = "core,http,rest")
 public class RestEndpoint extends DefaultEndpoint {
 
-    @UriParam
+    @UriPath
     private String method;
-    @UriParam
+    @UriPath
     private String path;
-    @UriParam
+    @UriPath
     private String uriTemplate;
     @UriParam
     private String consumes;

Reply via email to