|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectice.net.proxy.ProxyManager
This class provides support for use of proxy servers. This class is used to initialize the proxy property of each HttpURLConnection, that is , control which proxies are used.
You must be aware that all the settings made in this class
have the only effect to change the value of whatProxy().
As a consequence, you must study the order in which the whatProxy()
method takes the settings into account to be sure to get the proper result.
For example, the method setProxyUse() disables all
the proxies in all cases. So if you want to set a proxy server
for a limited quantity of domains, sets the proxy use to true and sets the
global proxy to null. Then, use the method setProxyDomain() for
the specific domains.
Proxy| Constructor Summary | |
ProxyManager()
The hostname in property "http.proxyHost" is used as a global proxy at initialization. |
|
| Method Summary | |
void |
addNonProxyDomain(String nonProxyDomain)
Adds the specified nonProxyDomain to the list of non
proxy domains of this ProxyManager. |
void |
addNonProxyDomainOrHost(String domainOrHost)
|
void |
addNonProxyHost(String nonProxyHost)
Adds the specified nonProxyHost to the list of non proxy
hosts of this ProxyManager. |
void |
addNonProxyPort(int nonProxyPort)
Adds the specified nonProxyPort to the list of non proxy
ports of this ProxyManager. |
void |
clearNonProxyDomains()
Clears the list of non proxy domains of this ProxyManager. |
void |
clearNonProxyHosts()
Clears the list of non proxy hosts of this ProxyManager. |
void |
clearNonProxyPorts()
Clears the list of non proxy ports of this ProxyManager. |
Enumeration |
elements()
Returns an enumeration containing java.lang.String objects. |
Proxy[] |
findProxy(String url)
Deprecated. As of 1.5.0, replaced by . |
ConnectionRoute |
findProxyForUrl(URL url)
Finds a usable connection route for the specified url. |
Proxy[] |
getAllGlobalProxies()
|
Proxy[] |
getAllProxies()
Returns an array containing all proxies used. |
String[] |
getAllProxyDomainsByProtocol(String protocol)
Returns an array containing all domains used for the protocol specified. |
String[] |
getDomainsForProxy(Proxy p)
Will return an array of strings giving all the domains the specified proxy will proxy. |
Proxy |
getGlobalProxy()
Gets global proxy server. |
Proxy |
getGlobalProxy(String protocol)
Gets global proxy server for a specified protocol. |
String[] |
getNonProxyDomains()
Gets the list of non proxy domains of this ProxyManager. |
String[] |
getNonProxyHosts()
Gets the list of non proxy hosts of this ProxyManager. |
int[] |
getNonProxyPorts()
Gets the list of non proxy ports of this ProxyManager. |
String[] |
getNoProxy()
Deprecated. As of 1.6.0, replaced by and
. Please not that
this method returned a list of both non proxy domains and
hosts. |
Proxy |
getProxy(String domain)
Returns the proxy set for a specific domain. |
Proxy |
getProxy(String host,
int port)
|
Proxy |
getProxy(String host,
int port,
String protocol)
|
Proxy |
getProxyForDomain(String domain)
Returns the http proxy for the specified domain, or null if none exists. |
Proxy |
getProxyForDomain(String domain,
String protocol)
Return the proxy for the specified domain and protocol, or null if none exists. |
boolean |
getProxyUse()
Indicates if connections are going through proxies. |
boolean |
isNonProxyHost(String host)
Checks to see if the specified host should not be
proxied. |
boolean |
isNonProxyPort(int port)
Checks to see if the specified port should not be
proxied. |
boolean |
isNoProxy(String host)
Deprecated. As of 1.6.0, replaced by . |
void |
readProxies(ObjectInput objectInput)
Reads all proxies into this ProxyManager from the
specified objectInput. |
void |
removeAllProxies()
Removes all proxies. |
void |
removeGlobalProxy(Proxy proxyRef)
Remove the global proxy server that correspond to the specified reference. |
void |
removeNonProxyDomain(String nonProxyDomain)
Removes the specified nonProxyDomain from the list of non
proxy domains of this ProxyManager. |
void |
removeNonProxyHost(String nonProxyHost)
Removes the specified nonProxyHost from the list of non
proxy hosts of this ProxyManager. |
void |
removeNonProxyPort(int nonProxyPort)
Removes the specified nonProxyPort from the list of non
proxy ports of this ProxyManager. |
void |
removeProxy(String domain)
Removes a proxy server for a specific domain. |
void |
removeProxy(String domain,
String protocol)
Removes a proxy server for a specific domain and a specific protocol. |
void |
rereadProperties()
|
void |
setGlobalProxy(Proxy proxy)
Sets the global proxy server. |
void |
setNonProxyDomains(String[] nonProxyDomains)
Sets the list of non proxy domains of this ProxyManager
to the specified nonProxyDomains. |
void |
setNonProxyHosts(String nonProxyHosts)
Sets the list of non proxy hosts of this ProxyManager to
the specified nonProxyHosts. |
void |
setNonProxyHosts(String[] nonProxyHosts)
Sets the list of non proxy hosts of this ProxyManager to
the specified nonProxyHosts. |
void |
setNonProxyPorts(int[] nonProxyPorts)
Sets the list of non proxy ports of this ProxyManager to
the specified nonProxyPorts. |
void |
setNonProxyPorts(String nonProxyPorts)
Sets the list of non proxy ports of this ProxyManager to
the specified nonProxyPorts. |
void |
setNoProxy(String domainOrHost)
Deprecated. As of 1.6.0, replaced by . |
void |
setNoProxy(String[] domains)
Deprecated. As of 1.6.0, replaced by . Please note
that this method was used to set the non proxy hosts list,
not the non proxy domain list. |
void |
setProxyDomain(String domain,
Proxy proxy)
Sets a proxy server for a specific domain. |
void |
setProxyForDomain(String domain,
Proxy proxy)
Set the proxy for the specified domain and protocol. |
void |
setProxyUse(boolean useproxies)
Set the use of proxies. |
Proxy |
whatProxy(String host)
Deprecated. As of 1.6.0, replaced by . |
Proxy |
whatProxy(String host,
String protocol)
Deprecated. As of 1.6.0, replaced by . |
void |
writeProxies(ObjectOutput objectOutput)
Writes all proxies contained in this ProxyManager to the
specified objectOutput. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ProxyManager()
setProxyUse(boolean)| Method Detail |
public void addNonProxyDomainOrHost(String domainOrHost)
domainOrHost - public void addNonProxyDomain(String nonProxyDomain)
Adds the specified nonProxyDomain to the list of non
proxy domains of this ProxyManager.
nonProxyDomain - the non proxy domain to be added.clearNonProxyDomains(),
getNonProxyDomains(),
removeNonProxyDomain(String),
setNonProxyDomains(String[]),
addNonProxyHost(String),
addNonProxyPort(int)public void addNonProxyHost(String nonProxyHost)
Adds the specified nonProxyHost to the list of non proxy
hosts of this ProxyManager.
nonProxyHost - the non proxy host to be added.clearNonProxyHosts(),
getNonProxyHosts(),
removeNonProxyHost(String),
setNonProxyHosts(String[]),
addNonProxyDomain(String),
addNonProxyPort(int)public void addNonProxyPort(int nonProxyPort)
Adds the specified nonProxyPort to the list of non proxy
ports of this ProxyManager.
nonProxyPort - the non proxy port to be added.clearNonProxyPorts(),
getNonProxyPorts(),
removeNonProxyPort(int),
setNonProxyPorts(int[]),
addNonProxyDomain(String),
addNonProxyHost(String)public void clearNonProxyDomains()
Clears the list of non proxy domains of this
ProxyManager.
addNonProxyDomain(String),
getNonProxyDomains(),
removeNonProxyDomain(String),
setNonProxyDomains(String[]),
clearNonProxyHosts(),
clearNonProxyPorts()public void clearNonProxyHosts()
Clears the list of non proxy hosts of this
ProxyManager.
addNonProxyHost(String),
getNonProxyHosts(),
removeNonProxyHost(String),
setNonProxyHosts(String[]),
clearNonProxyDomains(),
clearNonProxyPorts()public void clearNonProxyPorts()
Clears the list of non proxy ports of this
ProxyManager.
addNonProxyPort(int),
getNonProxyPorts(),
removeNonProxyPort(int),
setNonProxyPorts(int[]),
clearNonProxyDomains(),
clearNonProxyHosts()public ConnectionRoute findProxyForUrl(URL url)
ProxyResolverFinds a usable connection route for the specified
url.
findProxyForUrl in interface ProxyResolverurl - the full URL being accessed.
ConnectionRoute.public String[] getNonProxyDomains()
Gets the list of non proxy domains of this
ProxyManager.
addNonProxyDomain(String),
clearNonProxyDomains(),
removeNonProxyDomain(String),
setNonProxyDomains(String[]),
getNonProxyHosts(),
getNonProxyPorts()public String[] getNonProxyHosts()
Gets the list of non proxy hosts of this
ProxyManager.
addNonProxyHost(String),
clearNonProxyHosts(),
removeNonProxyHost(String),
setNonProxyHosts(String[]),
getNonProxyDomains(),
getNonProxyPorts()public int[] getNonProxyPorts()
Gets the list of non proxy ports of this
ProxyManager.
addNonProxyPort(int),
clearNonProxyPorts(),
removeNonProxyPort(int),
setNonProxyPorts(int[]),
getNonProxyDomains(),
getNonProxyHosts()
public Proxy getProxy(String host,
int port)
host - port -
getProxy(String, int, String)
public Proxy getProxy(String host,
int port,
String protocol)
host - port - protocol -
public boolean isNonProxyHost(String host)
Checks to see if the specified host should not be
proxied.
host -
true if the specified host should
not be proxied, false if not.isNonProxyPort(int)public boolean isNonProxyPort(int port)
Checks to see if the specified port should not be
proxied.
port -
true if the specified port should
not be proxied, false if not.isNonProxyHost(String)public void readProxies(ObjectInput objectInput)
Reads all proxies into this ProxyManager from the
specified objectInput. That is, all proxies and global
proxies, and all non proxy hosts, domains, and ports.
objectInput - the object input to read from.writeProxies(ObjectOutput)public void removeNonProxyDomain(String nonProxyDomain)
Removes the specified nonProxyDomain from the list of non
proxy domains of this ProxyManager.
nonProxyDomain - the non proxy domain to be removed.addNonProxyDomain(String),
clearNonProxyDomains(),
getNonProxyDomains(),
setNonProxyDomains(String[]),
removeNonProxyHost(String),
removeNonProxyPort(int)public void removeNonProxyHost(String nonProxyHost)
Removes the specified nonProxyHost from the list of non
proxy hosts of this ProxyManager.
nonProxyHost - the non proxy host to be removed.addNonProxyHost(String),
clearNonProxyHosts(),
getNonProxyHosts(),
setNonProxyHosts(String[]),
removeNonProxyDomain(String),
removeNonProxyPort(int)public void removeNonProxyPort(int nonProxyPort)
Removes the specified nonProxyPort from the list of non
proxy ports of this ProxyManager.
nonProxyPort - the non proxy port to be removed.addNonProxyPort(int),
clearNonProxyPorts(),
getNonProxyPorts(),
setNonProxyPorts(int[]),
removeNonProxyDomain(String),
removeNonProxyHost(String)public void setNonProxyDomains(String[] nonProxyDomains)
Sets the list of non proxy domains of this ProxyManager
to the specified nonProxyDomains. Please note that any
previous set non proxy domain(s) will be overriden.
nonProxyDomains - the new proxy domains.addNonProxyDomain(String),
clearNonProxyDomains(),
getNonProxyDomains(),
removeNonProxyDomain(String),
setNonProxyHosts(String[]),
setNonProxyPorts(int[])public void setNonProxyHosts(String nonProxyHosts)
Sets the list of non proxy hosts of this ProxyManager to
the specified nonProxyHosts. Please note that any previous
set non proxy host(s) will be overriden.
nonProxyHosts - the new non proxy hosts.public void setNonProxyHosts(String[] nonProxyHosts)
Sets the list of non proxy hosts of this ProxyManager to
the specified nonProxyHosts. Please note that any previous
set non proxy host(s) will be overriden.
nonProxyHosts - the new non proxy hosts.addNonProxyHost(String),
clearNonProxyHosts(),
getNonProxyHosts(),
removeNonProxyHost(String),
setNonProxyDomains(String[]),
setNonProxyPorts(int[])public void setNonProxyPorts(String nonProxyPorts)
Sets the list of non proxy ports of this ProxyManager to
the specified nonProxyPorts. Please note that any previous
set non proxy port(s) will be overriden.
nonProxyPorts - the new non proxy ports.public void setNonProxyPorts(int[] nonProxyPorts)
Sets the list of non proxy ports of this ProxyManager to
the specified nonProxyPorts. Please note that any previous
set non proxy port(s) will be overriden.
nonProxyPorts - the new non proxy ports.addNonProxyPort(int),
clearNonProxyPorts(),
getNonProxyPorts(),
removeNonProxyPort(int),
setNonProxyDomains(String[]),
setNonProxyHosts(String[])public void writeProxies(ObjectOutput objectOutput)
Writes all proxies contained in this ProxyManager to the
specified objectOutput. That is, all proxies and global
proxies, and all non proxy hosts, domains, and ports.
objectOutput - the object output to write to.readProxies(ObjectInput)public Proxy[] findProxy(String url)
findProxyForUrl(URL).
findProxy in interface ProxyResolverpublic String[] getNoProxy()
getNonProxyDomains() and
getNonProxyHosts(). Please not that
this method returned a list of both non proxy domains and
hosts.
getNonProxyPorts()public boolean isNoProxy(String host)
isNonProxyHost(String).
isNonProxyPort(int)public void setNoProxy(String domainOrHost)
addNonProxyDomainOrHost(String).
addNonProxyDomain(String),
addNonProxyHost(String),
addNonProxyPort(int)public void setNoProxy(String[] domains)
setNonProxyHosts(String[]). Please note
that this method was used to set the non proxy hosts list,
not the non proxy domain list.
setNonProxyDomains(String[]),
setNonProxyPorts(int[])public Proxy whatProxy(String host)
getProxy(String, int).
public Proxy whatProxy(String host,
String protocol)
getProxy(String, int, String).
public void rereadProperties()
public boolean getProxyUse()
whatProxy.
setGlobalProxy(Proxy),
whatProxy(String)public void setProxyUse(boolean useproxies)
useproxies - if true, all http connections
will use proxies.getProxyUse(),
setGlobalProxy(Proxy),
whatProxy(String)public void removeAllProxies()
public void setGlobalProxy(Proxy proxy)
http.proxyHost http.proxyPort
proxy - The global proxy server.getProxyUse(),
getGlobalProxy(),
whatProxy(String)public Proxy getGlobalProxy()
getProxyUse(),
setGlobalProxy(Proxy),
whatProxy(String)public Proxy getGlobalProxy(String protocol)
getProxyUse(),
setGlobalProxy(Proxy),
whatProxy(String)public Proxy[] getAllGlobalProxies()
public void setProxyDomain(String domain,
Proxy proxy)
domain - the domain for which the proxy will be setproxy - the proxy servergetProxyUse(),
removeProxy(String),
whatProxy(String)public void removeProxy(String domain)
Note: this method does not disable the use
of proxies for a specific domain. It disables the use of a
specific proxy for a domain. Use the
setNoProxy() method if you want to disable proxies
for a domain.
domain - the domain for which the specific proxy will
be removed.getProxyUse(),
whatProxy(String)
public void removeProxy(String domain,
String protocol)
Note: this method does not disable the use
of proxies for a specific domain. It disables the use of a
specific proxy for a domain. Use the
setNoProxy() method if you want to disable proxies
for a domain.
domain - the domain for which the specific proxy will
be removed.protocol - the protocol for which the specific proxy will be removed.getProxyUse(),
whatProxy(String)public void removeGlobalProxy(Proxy proxyRef)
public Proxy getProxy(String domain)
getProxyUse(),
removeProxy(String),
whatProxy(String)public String[] getDomainsForProxy(Proxy p)
public Proxy getProxyForDomain(String domain,
String protocol)
public Proxy getProxyForDomain(String domain)
public void setProxyForDomain(String domain,
Proxy proxy)
public Proxy[] getAllProxies()
public String[] getAllProxyDomainsByProtocol(String protocol)
public Enumeration elements()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||