public class DefaultProxySelector extends java.net.ProxySelector
Modifier and Type | Field and Description |
---|---|
private java.net.ProxySelector |
delegate |
private java.util.Set<java.lang.String> |
errorMessages |
private java.util.Set<java.lang.String> |
errorResources |
private java.net.InetSocketAddress |
httpProxySocketAddress |
private static java.lang.String |
IPV4_LOOPBACK |
private static java.lang.String |
IPV6_LOOPBACK |
private static boolean |
jvmWillUseSystemProxies
The
ProxySelector provided by the JDK will retrieve proxy information
from the system settings, if the system property java.net.useSystemProxies
is defined at startup. |
private static java.util.List<java.net.Proxy> |
NO_PROXY_LIST |
static java.lang.String |
PROXY_EXCEPTIONS
Property key for proxy exceptions list
|
static java.lang.String |
PROXY_HTTP_HOST
Property key for HTTP proxy host
|
static java.lang.String |
PROXY_HTTP_PORT
Property key for HTTP proxy port
|
static java.lang.String |
PROXY_PASS
Property key for proxy password
|
static java.lang.String |
PROXY_POLICY
Property key for proxy policy
|
static java.lang.String |
PROXY_SOCKS_HOST
Property key for SOCKS proxy host
|
static java.lang.String |
PROXY_SOCKS_PORT
Property key for SOCKS proxy port
|
static java.lang.String |
PROXY_USER
Property key for proxy username
|
private java.util.Set<java.lang.String> |
proxyExceptions |
private ProxyPolicy |
proxyPolicy |
private java.net.InetSocketAddress |
socksProxySocketAddress |
Constructor and Description |
---|
DefaultProxySelector(java.net.ProxySelector delegate)
A typical example is:
|
Modifier and Type | Method and Description |
---|---|
void |
clearErrors()
Clear the sets of failed resources and error messages.
|
void |
connectFailed(java.net.URI uri,
java.net.SocketAddress sa,
java.io.IOException ioe) |
java.util.Set<java.lang.String> |
getErrorMessages()
Returns the set of current proxy error messages.
|
java.util.Set<java.lang.String> |
getErrorResources()
Returns the set of current proxy resources that failed to be retrieved.
|
boolean |
hasErrors()
Determines if proxy errors have occurred.
|
void |
initFromPreferences()
Initializes the proxy selector from the setting in the preferences.
|
protected int |
parseProxyPortValue(java.lang.String property,
java.lang.String value) |
java.util.List<java.net.Proxy> |
select(java.net.URI uri) |
static boolean |
willJvmRetrieveSystemProxies()
The
ProxySelector provided by the JDK will retrieve proxy information
from the system settings, if the system property java.net.useSystemProxies
is defined at startup. |
public static final java.lang.String PROXY_POLICY
public static final java.lang.String PROXY_HTTP_HOST
public static final java.lang.String PROXY_HTTP_PORT
public static final java.lang.String PROXY_SOCKS_HOST
public static final java.lang.String PROXY_SOCKS_PORT
public static final java.lang.String PROXY_USER
public static final java.lang.String PROXY_PASS
public static final java.lang.String PROXY_EXCEPTIONS
private static final java.util.List<java.net.Proxy> NO_PROXY_LIST
private static final java.lang.String IPV4_LOOPBACK
private static final java.lang.String IPV6_LOOPBACK
private static boolean jvmWillUseSystemProxies
ProxySelector
provided by the JDK will retrieve proxy information
from the system settings, if the system property java.net.useSystemProxies
is defined at startup. It has no effect if the property is set
later by the application.
We therefore read the property at class loading time and remember it's value.private ProxyPolicy proxyPolicy
private java.net.InetSocketAddress httpProxySocketAddress
private java.net.InetSocketAddress socksProxySocketAddress
private final java.net.ProxySelector delegate
private final java.util.Set<java.lang.String> errorResources
private final java.util.Set<java.lang.String> errorMessages
private java.util.Set<java.lang.String> proxyExceptions
public DefaultProxySelector(java.net.ProxySelector delegate)
PropertySelector delegate = PropertySelector.getDefault(); PropertySelector.setDefault(new DefaultPropertySelector(delegate));
delegate
- the proxy selector to delegate to if system settings are used. Usually
this is the proxy selector found by ProxySelector.getDefault() before this proxy
selector is installedpublic static boolean willJvmRetrieveSystemProxies()
ProxySelector
provided by the JDK will retrieve proxy information
from the system settings, if the system property java.net.useSystemProxies
is defined at startup. If the property is set later by the application,
this has no effect.java.net.useSystemProxies
was set to true at class initialization timeprotected int parseProxyPortValue(java.lang.String property, java.lang.String value)
public final void initFromPreferences()
public void connectFailed(java.net.URI uri, java.net.SocketAddress sa, java.io.IOException ioe)
connectFailed
in class java.net.ProxySelector
public final java.util.Set<java.lang.String> getErrorResources()
public final java.util.Set<java.lang.String> getErrorMessages()
public final void clearErrors()
public final boolean hasErrors()
true
if errors have occurred, false
otherwise.public java.util.List<java.net.Proxy> select(java.net.URI uri)
select
in class java.net.ProxySelector