Repository: camel Updated Branches: refs/heads/master a4aeefef5 -> 7bc2cc33a
Camel component docs Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7bc2cc33 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7bc2cc33 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7bc2cc33 Branch: refs/heads/master Commit: 7bc2cc33a050313ba59288b962b65c040a587266 Parents: a4aeefe Author: Claus Ibsen <davscl...@apache.org> Authored: Tue Jan 5 18:25:13 2016 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Jan 5 18:25:13 2016 +0100 ---------------------------------------------------------------------- .../camel/component/http4/HttpComponent.java | 8 ++++--- .../camel/component/http4/HttpEndpoint.java | 24 ++++++++++++++++++-- .../http4/HttpReferenceParameterTest.java | 2 +- 3 files changed, 28 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/7bc2cc33/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java index c2f8c3c..1ff3300 100644 --- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java +++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java @@ -152,14 +152,15 @@ public class HttpComponent extends HttpCommonComponent { // http client can be configured from URI options HttpClientBuilder clientBuilder = HttpClientBuilder.create(); // allow the builder pattern - IntrospectionSupport.setProperties(clientBuilder, parameters, "httpClient.", true); + Map<String, Object> httpClientOptions = IntrospectionSupport.extractProperties(parameters, "httpClient."); + IntrospectionSupport.setProperties(clientBuilder, httpClientOptions); // set the Request configure this way and allow the builder pattern RequestConfig.Builder requestConfigBuilder = RequestConfig.custom(); - IntrospectionSupport.setProperties(requestConfigBuilder, parameters, "httpClient.", true); + IntrospectionSupport.setProperties(requestConfigBuilder, httpClientOptions); clientBuilder.setDefaultRequestConfig(requestConfigBuilder.build()); // validate that we could resolve all httpClient. parameters as this component is lenient - validateParameters(uri, parameters, "httpClient."); + validateParameters(uri, httpClientOptions, null); HttpBinding httpBinding = resolveAndRemoveReferenceParameter(parameters, "httpBinding", HttpBinding.class); HttpContext httpContext = resolveAndRemoveReferenceParameter(parameters, "httpContext", HttpContext.class); @@ -269,6 +270,7 @@ public class HttpComponent extends HttpCommonComponent { if (endpoint.getCookieStore() == null) { endpoint.setCookieStore(getCookieStore()); } + endpoint.setHttpClientOptions(httpClientOptions); return endpoint; } http://git-wip-us.apache.org/repos/asf/camel/blob/7bc2cc33/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java index 874a595..19b8d8f 100644 --- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java +++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java @@ -19,6 +19,7 @@ package org.apache.camel.component.http4; import java.io.Closeable; import java.net.URI; import java.net.URISyntaxException; +import java.util.Map; import org.apache.camel.Consumer; import org.apache.camel.PollingConsumer; @@ -49,12 +50,17 @@ public class HttpEndpoint extends HttpCommonEndpoint { private static final Logger LOG = LoggerFactory.getLogger(HttpEndpoint.class); - // Note: all options must be documented with description in annotations so extended components can access the documentation - + @UriParam(label = "advanced") private HttpContext httpContext; + @UriParam(label = "advanced") private HttpClientConfigurer httpClientConfigurer; + @UriParam(label = "advanced", prefix = "httpClient.", multiValue = true) + private Map<String, Object> httpClientOptions; + @UriParam(label = "advanced") private HttpClientConnectionManager clientConnectionManager; + @UriParam(label = "advanced") private HttpClientBuilder clientBuilder; + @UriParam(label = "advanced") private HttpClient httpClient; @UriParam(label = "producer") @@ -218,6 +224,9 @@ public class HttpEndpoint extends HttpCommonEndpoint { this.httpClientConfigurer = httpClientConfigurer; } + /** + * To use a custom HttpContext instance + */ public void setHttpContext(HttpContext httpContext) { this.httpContext = httpContext; } @@ -270,4 +279,15 @@ public class HttpEndpoint extends HttpCommonEndpoint { this.authenticationPreemptive = authenticationPreemptive; } + public Map<String, Object> getHttpClientOptions() { + return httpClientOptions; + } + + /** + * To configure the HttpClient using the key/values from the Map. + */ + public void setHttpClientOptions(Map<String, Object> httpClientOptions) { + this.httpClientOptions = httpClientOptions; + } + } http://git-wip-us.apache.org/repos/asf/camel/blob/7bc2cc33/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpReferenceParameterTest.java ---------------------------------------------------------------------- diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpReferenceParameterTest.java b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpReferenceParameterTest.java index 5046e5e..ff2599f 100644 --- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpReferenceParameterTest.java +++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpReferenceParameterTest.java @@ -33,7 +33,7 @@ import org.junit.Test; public class HttpReferenceParameterTest extends CamelTestSupport { private static final String TEST_URI_1 = "http4://localhost:8080?httpBinding=#customBinding&httpClientConfigurer=#customConfigurer&httpContext=#customContext"; - private static final String TEST_URI_2 = "http4://localhost:8081?httpBinding=customBinding&httpClientConfigurer=customConfigurer&httpContext=customContext"; + private static final String TEST_URI_2 = "http4://localhost:8081?httpBinding=#customBinding&httpClientConfigurer=#customConfigurer&httpContext=#customContext"; private HttpEndpoint endpoint1; private HttpEndpoint endpoint2;