Repository: camel Updated Branches: refs/heads/master f61bd50c1 -> 7b67a04ed
CAMEL-7328: A minor refactoring in camel-ahc so that it can be reused for websocket client Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7b67a04e Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7b67a04e Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7b67a04e Branch: refs/heads/master Commit: 7b67a04edccd42d2cb8122711f7984dafd8e6e0f Parents: f61bd50 Author: Akitoshi Yoshida <a...@apache.org> Authored: Tue Mar 25 15:12:43 2014 +0100 Committer: Akitoshi Yoshida <a...@apache.org> Committed: Tue Mar 25 15:12:43 2014 +0100 ---------------------------------------------------------------------- .../org/apache/camel/component/ahc/AhcComponent.java | 14 +++++++++++--- .../org/apache/camel/component/ahc/AhcEndpoint.java | 15 +++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/7b67a04e/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcComponent.java b/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcComponent.java index e16a60f..98ddb1c 100644 --- a/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcComponent.java +++ b/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcComponent.java @@ -50,11 +50,11 @@ public class AhcComponent extends HeaderFilterStrategyComponent { @Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { - String addressUri = remaining; + String addressUri = createAddressUri(uri, remaining); // Do not set the HTTP URI because we still have all of the Camel internal // parameters in the URI at this point. - AhcEndpoint endpoint = new AhcEndpoint(uri, this, null); + AhcEndpoint endpoint = createAhcEndpoint(uri, this, null); setEndpointHeaderFilterStrategy(endpoint); endpoint.setClient(getClient()); endpoint.setClientConfig(getClientConfig()); @@ -145,7 +145,15 @@ public class AhcComponent extends HeaderFilterStrategyComponent { public void setSslContextParameters(SSLContextParameters sslContextParameters) { this.sslContextParameters = sslContextParameters; } - + + protected String createAddressUri(String uri, String remaining) { + return remaining; + } + + protected AhcEndpoint createAhcEndpoint(String endpointUri, AhcComponent component, URI httpUri) { + return new AhcEndpoint(endpointUri, component, httpUri); + } + /** * Creates a new client configuration builder using {@code clientConfig} as a template for * the builder. http://git-wip-us.apache.org/repos/asf/camel/blob/7b67a04e/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcEndpoint.java b/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcEndpoint.java index f503aef..276dfae 100644 --- a/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcEndpoint.java +++ b/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcEndpoint.java @@ -185,12 +185,15 @@ public class AhcEndpoint extends DefaultEndpoint implements HeaderFilterStrategy config = builder.build(); } } - - if (config == null) { - client = new AsyncHttpClient(); - } else { - client = new AsyncHttpClient(config); - } + client = createClient(config); + } + } + + protected AsyncHttpClient createClient(AsyncHttpClientConfig config) { + if (config == null) { + return new AsyncHttpClient(); + } else { + return new AsyncHttpClient(config); } }