Top Description Fields Constructors Methods
org.apache.http.impl.conn

public Class ProxySelectorRoutePlanner

extends Object
implements HttpRoutePlanner
Class Inheritance
All Implemented Interfaces
org.apache.http.conn.routing.HttpRoutePlanner
Annotations
@Deprecated
Imports
java.net.InetAddress, .InetSocketAddress, .Proxy, .ProxySelector, .URI, .URISyntaxException, java.util.List, org.apache.http.HttpException, .HttpHost, .HttpRequest, org.apache.http.conn.params.ConnRouteParams, org.apache.http.conn.routing.HttpRoute, .HttpRoutePlanner, org.apache.http.conn.scheme.Scheme, .SchemeRegistry, org.apache.http.protocol.HttpContext, org.apache.http.util.Args, .Asserts

Deprecated

(4.3) use SystemDefaultRoutePlanner

Default implementation of an HttpRoutePlanner. This implementation is based on java.net.ProxySelector. By default, it will pick up the proxy settings of the JVM, either from system properties or from the browser running the application. Additionally, it interprets some parameters, though not the DEFAULT_PROXY.

The following parameters can be used to customize the behavior of this class:

Since
4.0

Field Summary

Modifier and TypeField and Description
protected ProxySelector
proxySelector

The proxy selector to use, or null for system default.

protected final SchemeRegistry
schemeRegistry

The scheme registry.

Constructor Summary

AccessConstructor and Description
public
ProxySelectorRoutePlanner(final SchemeRegistry
the scheme registry
schreg
,
final ProxySelector
the proxy selector, or null for the system default
prosel
)

Deprecated as a consequence of SchemeRegistry being deprecated.
Creates a new proxy selector route planner.

Method Summary

Modifier and TypeMethod and Description
protected Proxy

Returns:

a proxy type
chooseProxy
(final List<Proxy>
the list of proxies to choose from, never null or empty
proxies
,
final HttpHost
the planned target, never null
target
,
final HttpRequest
the request to be sent, never null
request
,
final HttpContext
the context, or null
context
)

Chooses a proxy from a list of available proxies.

protected HttpHost

Returns:

the proxy to use, or null for a direct route
determineProxy
(final HttpHost
the planned target, never null
target
,
final HttpRequest
the request to be sent, never null
request
,
final HttpContext
the context, or null
context
)

Determines a proxy for the given target.

public HttpRoute
determineRoute(final HttpHost
the target host for the request. Implementations may accept null if they can still determine a route, for example to a default target or by inspecting the request.
target
,
final HttpRequest
the request to execute
request
,
final HttpContext
the context to use for the subsequent execution. Implementations may accept null.
context
)

Implements org.apache.http.conn.routing.HttpRoutePlanner.determineRoute.

Determines the route for a request.
protected String

Returns:

a host string, either as a symbolic name or as a literal IP address string

(TODO: determine format for IPv6 addresses, with or without [brackets])

getHost
(final InetSocketAddress
the socket address
isa
)

Obtains a host from an InetSocketAddress.

public ProxySelector

Returns:

the proxy selector, or null for the system default
getProxySelector
()

Obtains the proxy selector to use.

public void
setProxySelector(final ProxySelector
the proxy selector, or null to use the system default
prosel
)

Sets the proxy selector to use.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

proxySelectorback to summary
protected ProxySelector proxySelector

The proxy selector to use, or null for system default.

schemeRegistryback to summary
protected final SchemeRegistry schemeRegistry

Deprecated

as a consequence of SchemeRegistry being deprecated. See corresponding docs for further information.

The scheme registry.

Constructor Detail

ProxySelectorRoutePlannerback to summary
public ProxySelectorRoutePlanner(final SchemeRegistry schreg, final ProxySelector prosel)

Deprecated

as a consequence of SchemeRegistry being deprecated. See corresponding docs for further information.

Creates a new proxy selector route planner.

Parameters
schreg:SchemeRegistry

the scheme registry

prosel:ProxySelector

the proxy selector, or null for the system default

Method Detail

chooseProxyback to summary
protected Proxy chooseProxy(final List<Proxy> proxies, final HttpHost target, final HttpRequest request, final HttpContext context)

Chooses a proxy from a list of available proxies. The default implementation just picks the first non-SOCKS proxy from the list. If there are only SOCKS proxies, Proxy.NO_PROXY is returned. Derived classes may implement more advanced strategies, such as proxy rotation if there are multiple options.

Parameters
proxies:List<Proxy>

the list of proxies to choose from, never null or empty

target:HttpHost

the planned target, never null

request:HttpRequest

the request to be sent, never null

context:HttpContext

the context, or null

Returns:Proxy

a proxy type

determineProxyback to summary
protected HttpHost determineProxy(final HttpHost target, final HttpRequest request, final HttpContext context) throws HttpException

Determines a proxy for the given target.

Parameters
target:HttpHost

the planned target, never null

request:HttpRequest

the request to be sent, never null

context:HttpContext

the context, or null

Returns:HttpHost

the proxy to use, or null for a direct route

Exceptions
HttpException:
in case of system proxy settings that cannot be handled
determineRouteback to summary
public HttpRoute determineRoute(final HttpHost target, final HttpRequest request, final HttpContext context) throws HttpException

Implements org.apache.http.conn.routing.HttpRoutePlanner.determineRoute.

Doc from org.apache.http.conn.routing.HttpRoutePlanner.determineRoute.

Determines the route for a request.

Parameters
target:HttpHost

the target host for the request. Implementations may accept null if they can still determine a route, for example to a default target or by inspecting the request.

request:HttpRequest

the request to execute

context:HttpContext

the context to use for the subsequent execution. Implementations may accept null.

Returns:HttpRoute

the route that the request should take

Annotations
@Override
Exceptions
HttpException:
in case of a problem
getHostback to summary
protected String getHost(final InetSocketAddress isa)

Obtains a host from an InetSocketAddress.

Parameters
isa:InetSocketAddress

the socket address

Returns:String

a host string, either as a symbolic name or as a literal IP address string

(TODO: determine format for IPv6 addresses, with or without [brackets])

getProxySelectorback to summary
public ProxySelector getProxySelector()

Obtains the proxy selector to use.

Returns:ProxySelector

the proxy selector, or null for the system default

setProxySelectorback to summary
public void setProxySelector(final ProxySelector prosel)

Sets the proxy selector to use.

Parameters
prosel:ProxySelector

the proxy selector, or null to use the system default