HTTPCLIENT-736: SchemeRegistry instead of ConnectionManager

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@617616 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Roland Weber 2008-02-01 19:27:30 +00:00
parent 9eb66c7f11
commit 799365d07a
4 changed files with 43 additions and 28 deletions

View File

@ -1,6 +1,9 @@
Changes since 4.0 Alpha 2
-------------------
* [HTTPCLIENT-736] route planners use SchemeRegistry instead of ConnManager
Contributed by Roland Weber <rolandw at apache.org>
* [HTTPCLIENT-730] Fixed rewriting of URIs containing escaped characters
Contributed by Sam Berlin <sberlin at gmail.com> and
Oleg Kalnichevski <olegk at apache.org>

View File

@ -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

View File

@ -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();

View File

@ -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 <code>null</code> 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
* <code>null</code> 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
* <code>null</code> 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();