diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 8b91ac9a6..d9994f113 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -1,6 +1,9 @@ Changes since 4.0 Alpha 2 ------------------- +* [HTTPCLIENT-736] route planners use SchemeRegistry instead of ConnManager + Contributed by Roland Weber + * [HTTPCLIENT-730] Fixed rewriting of URIs containing escaped characters Contributed by Sam Berlin and Oleg Kalnichevski diff --git a/module-client/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java b/module-client/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java index a4bee1902..826b3e510 100644 --- a/module-client/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java +++ b/module-client/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java @@ -301,7 +301,8 @@ public class DefaultHttpClient extends AbstractHttpClient { // non-javadoc, see base class AbstractHttpClient @Override protected HttpRoutePlanner createHttpRoutePlanner() { - return new DefaultHttpRoutePlanner(getConnectionManager()); + return new DefaultHttpRoutePlanner + (getConnectionManager().getSchemeRegistry()); } } // class DefaultHttpClient diff --git a/module-client/src/main/java/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java b/module-client/src/main/java/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java index 6b52aa06c..a5a8e71c8 100644 --- a/module-client/src/main/java/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java +++ b/module-client/src/main/java/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java @@ -40,9 +40,9 @@ import org.apache.http.HttpRequest; import org.apache.http.protocol.HttpContext; import org.apache.http.conn.Scheme; +import org.apache.http.conn.SchemeRegistry; import org.apache.http.conn.routing.HttpRoute; import org.apache.http.conn.routing.HttpRoutePlanner; -import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.params.ConnRoutePNames; @@ -55,18 +55,21 @@ import org.apache.http.conn.params.ConnRoutePNames; */ public class DefaultHttpRoutePlanner implements HttpRoutePlanner { - /** The connection manager, to get at the scheme registry. */ - protected ClientConnectionManager connectionManager; - - - public DefaultHttpRoutePlanner(ClientConnectionManager aConnManager) { - setConnectionManager(aConnManager); - } + /** The scheme registry. */ + protected SchemeRegistry schemeRegistry; - - public void setConnectionManager(ClientConnectionManager aConnManager) { - this.connectionManager = aConnManager; + /** + * Creates a new default route planner. + * + * @param schreg the scheme registry + */ + public DefaultHttpRoutePlanner(SchemeRegistry schreg) { + if (schreg == null) { + throw new IllegalArgumentException + ("SchemeRegistry must not be null."); + } + schemeRegistry = schreg; } @@ -100,8 +103,7 @@ public class DefaultHttpRoutePlanner implements HttpRoutePlanner { final HttpHost proxy = (HttpHost) request.getParams().getParameter(ConnRoutePNames.DEFAULT_PROXY); - final Scheme schm = this.connectionManager.getSchemeRegistry(). - getScheme(target.getSchemeName()); + final Scheme schm = schemeRegistry.getScheme(target.getSchemeName()); // as it is typically used for TLS/SSL, we assume that // a layered scheme implies a secure connection final boolean secure = schm.isLayered(); diff --git a/module-client/src/main/java/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java b/module-client/src/main/java/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java index c710c9ebe..98d13037e 100644 --- a/module-client/src/main/java/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java +++ b/module-client/src/main/java/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java @@ -48,7 +48,7 @@ import org.apache.http.protocol.HttpContext; import org.apache.http.conn.routing.HttpRoute; import org.apache.http.conn.routing.HttpRoutePlanner; import org.apache.http.conn.Scheme; -import org.apache.http.conn.ClientConnectionManager; +import org.apache.http.conn.SchemeRegistry; import org.apache.http.conn.params.ConnRoutePNames; @@ -63,20 +63,29 @@ import org.apache.http.conn.params.ConnRoutePNames; */ public class ProxySelectorRoutePlanner implements HttpRoutePlanner { - /** The connection manager, to get at the scheme registry. */ - protected ClientConnectionManager connectionManager; + /** The scheme registry. */ + protected SchemeRegistry schemeRegistry; /** The proxy selector to use, or null for system default. */ protected ProxySelector proxySelector; - - public ProxySelectorRoutePlanner(ClientConnectionManager aConnManager) { - setConnectionManager(aConnManager); - } + /** + * Creates a new proxy selector route planner. + * + * @param schreg the scheme registry + * @param prosel the proxy selector, or + * null for the system default + */ + public ProxySelectorRoutePlanner(SchemeRegistry schreg, + ProxySelector prosel) { - public void setConnectionManager(ClientConnectionManager aConnManager) { - this.connectionManager = aConnManager; + if (schreg == null) { + throw new IllegalArgumentException + ("SchemeRegistry must not be null."); + } + schemeRegistry = schreg; + proxySelector = prosel; } @@ -93,11 +102,11 @@ public class ProxySelectorRoutePlanner implements HttpRoutePlanner { /** * Sets the proxy selector to use. * - * @param psel the proxy selector, or + * @param prosel the proxy selector, or * null to use the system default */ - public void setProxySelector(ProxySelector psel) { - this.proxySelector = psel; + public void setProxySelector(ProxySelector prosel) { + this.proxySelector = prosel; } @@ -131,8 +140,8 @@ public class ProxySelectorRoutePlanner implements HttpRoutePlanner { request.getParams().getParameter(ConnRoutePNames.LOCAL_ADDRESS); final HttpHost proxy = determineProxy(target, request, context); - final Scheme schm = this.connectionManager.getSchemeRegistry(). - getScheme(target.getSchemeName()); + final Scheme schm = + this.schemeRegistry.getScheme(target.getSchemeName()); // as it is typically used for TLS/SSL, we assume that // a layered scheme implies a secure connection final boolean secure = schm.isLayered();