setDefault
method. The
currently registered proxy selector can be retrieved by calling
getDefault
method.
When a proxy selector is registered, for instance, a subclass
of URLConnection class should call the select
method for each URL request so that the proxy selector can decide
if a direct, or proxied connection should be used. The select
method returns an iterator over a collection with
the preferred connection approach.
If a connection cannot be established to a proxy (PROXY or
SOCKS) servers then the caller should call the proxy selector's
connectFailed
method to notify the proxy
selector that the proxy server is unavailable.
The default proxy selector does enforce a set of System Properties related to proxy settings.
Modifier and Type | Class and Description |
---|---|
pack-priv static class |
Modifier and Type | Field and Description |
---|---|
private static volatile ProxySelector | theProxySelector
The system wide proxy selector that selects the proxy server to use, if any, when connecting to a remote object referenced by an URL. |
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
public abstract void | connectFailed(URI
The URI that the proxy at sa failed to serve. uri, SocketAddress The socket address of the proxy/SOCKS server sa, IOException The I/O exception thrown when the connect failed. ioe)Called to indicate that a connection could not be established to a proxy/socks server. |
public static ProxySelector | |
public static ProxySelector | Returns: a ProxySelectorThe address of the proxy proxyAddress)Returns a ProxySelector which uses the given proxy address for all HTTP and HTTPS requests. |
public abstract List | |
public static void | setDefault(ProxySelector
The HTTP proxy selector, or
ps)null to unset the proxy selector.Sets (or unsets) the system-wide proxy selector. |
theProxySelector | back to summary |
---|---|
private static volatile ProxySelector theProxySelector The system wide proxy selector that selects the proxy server to use, if any, when connecting to a remote object referenced by an URL.
|
ProxySelector | back to summary |
---|---|
public ProxySelector() Constructor for subclasses to call. |
connectFailed | back to summary |
---|---|
public abstract void connectFailed(URI uri, SocketAddress sa, IOException ioe) Called to indicate that a connection could not be established
to a proxy/socks server. An implementation of this method can
temporarily remove the proxies or reorder the sequence of
proxies returned by
|
getDefault | back to summary |
---|---|
public static ProxySelector getDefault() Gets the system-wide proxy selector.
|
of | back to summary |
---|---|
public static ProxySelector of(InetSocketAddress proxyAddress) Returns a ProxySelector which uses the given proxy address for all HTTP
and HTTPS requests. If
|
select | back to summary |
---|---|
public abstract List Selects all the applicable proxies based on the protocol to access the resource with and a destination address to access the resource at. The format of the URI is defined as follows:
|
setDefault | back to summary |
---|---|
public static void setDefault(ProxySelector ps) Sets (or unsets) the system-wide proxy selector. Note non-standard protocol handlers may ignore this setting.
|
Modifier and Type | Field and Description |
---|---|
pack-priv final List | |
private static final List |
Access | Constructor and Description |
---|---|
pack-priv |
Modifier and Type | Method and Description |
---|---|
public void | connectFailed(URI
The URI that the proxy at sa failed to serve. uri, SocketAddress The socket address of the proxy/SOCKS server sa, IOException The I/O exception thrown when the connect failed. e)Implements abstract java. Called to indicate that a connection could not be established to a proxy/socks server. |
public List | select(URI
The URI that a connection is required to uri)Implements abstract java. Selects all the applicable proxies based on the protocol to access the resource with and a destination address to access the resource at. |
list | back to summary |
---|---|
pack-priv final List<Proxy> list |
NO_PROXY_LIST | back to summary |
---|---|
private static final List<Proxy> NO_PROXY_LIST |
StaticProxySelector | back to summary |
---|---|
pack-priv StaticProxySelector(InetSocketAddress address) |
connectFailed | back to summary |
---|---|
public void connectFailed(URI uri, SocketAddress sa, IOException e) Implements abstract java. Doc from java. Called to indicate that a connection could not be established
to a proxy/socks server. An implementation of this method can
temporarily remove the proxies or reorder the sequence of
proxies returned by
|
select | back to summary |
---|---|
public List Implements abstract java. Doc from java. Selects all the applicable proxies based on the protocol to access the resource with and a destination address to access the resource at. The format of the URI is defined as follows:
|