Repository: camel Updated Branches: refs/heads/camel-2.14.x bfd3797eb -> c23c4c158
CAMEL-8218: Fix the issue that REST DSL with RestletComponent doesn't support servelet container Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/52fb5f14 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/52fb5f14 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/52fb5f14 Branch: refs/heads/camel-2.14.x Commit: 52fb5f142e46a41fe33624cedb4aebebcb19af30 Parents: bfd3797 Author: Willem Jiang <willem.ji...@gmail.com> Authored: Thu Jan 8 14:42:48 2015 +0800 Committer: Willem Jiang <willem.ji...@gmail.com> Committed: Thu Jan 8 14:50:28 2015 +0800 ---------------------------------------------------------------------- .../camel/component/restlet/RestletComponent.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/52fb5f14/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java index 954c24b..c1d3d16 100644 --- a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java +++ b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java @@ -532,7 +532,8 @@ public class RestletComponent extends HeaderFilterStrategyComponent implements R String scheme = "http"; String host = ""; - int port = 0; + // use the component's port as the default value + int port = this.getPort(); // if no explicit port/host configured, then use port from rest configuration RestConfiguration config = getCamelContext().getRestConfiguration(); @@ -569,15 +570,22 @@ public class RestletComponent extends HeaderFilterStrategyComponent implements R String query = URISupport.createQueryString(map); - String url = "restlet:%s://%s:%s/%s?restletMethod=%s"; + String url; // must use upper case for restrict String restrict = verb.toUpperCase(Locale.US); - // get the endpoint - url = String.format(url, scheme, host, port, path, restrict); + + if (port > 0) { + url = "restlet:%s://%s:%s/%s?restletMethod=%s"; + url = String.format(url, scheme, host, port, path, restrict); + } else { + // It could use the restlet servlet transport + url = "restlet:/%s?restletMethod=%s"; + url = String.format(url, path, restrict); + } if (!query.isEmpty()) { url = url + "&" + query; } - + // get the endpoint RestletEndpoint endpoint = camelContext.getEndpoint(url, RestletEndpoint.class); setProperties(endpoint, parameters);