|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectice.net.pac.PacManager
The PacManager is basically the entry point for everything that
has to do with the PAC (Proxy Auto-Config) specification by Netscape
Communications Corporation
(Navigator Proxy Auto-Config File Format).
Its responsibilities include:
PacScripter,
PacManager can be
used:
try {
PacManager _pacManager =
new PacManager(new URL("http://localhost/pac/proxy.pac"));
URL _requestedUrl = new URL("http://www.icesoft.com/");
ConnectionRoute _connectionRoute;
boolean _connected = false;
while (!_connected) {
try {
_connectionRoute = _pacManager.findProxyForUrl(_requestedUrl);
if (_connectionRoute instanceof Direct) {
// do your thing for a direct connection route.
} else if (_connectionRoute instanceof Indirect) {
// do your thing for a indirect connection route.
}
connect(); // try actually connecting (can throw IOException).
_connected = true;
_connectionRoute.setStatus(ConnectionRoute.KNOWN_GOOD);
} catch (ConnectionNotFoundException exception) {
throw new UnknownHostException(_requestedUrl.getHost());
} catch (IOException exception) {
_connectionRoute.setStatus(ConnectionRoute.KNOWN_BAD);
}
}
} catch (MalformedURLException exception) {
// handle the exception.
}
PacScripter| Constructor Summary | |
PacManager()
Constructs a PacManager. |
|
PacManager(URL pacLocation)
Deprecated. As of 1.6.0, replaced by
followed by . The
setPacLocation(URL) method throws an
IOException or JavaScriptException
as of 1.6.0 if respectively loading the implementation and/or
the PAC script fails, and/or the implementation and/or the
PAC script contains a JavaScript error. Previously it was
difficult for the user of this PacManager to
know if loading or parsing the implementation and/or PAC
script failed, unless by investigating the debug output.
Constructs a |
|
| Method Summary | |
boolean |
areProxiesEnabled()
Determines whether proxies are enabled. |
Proxy[] |
findProxy(String url)
Deprecated. As of 1.5.0, replaced by |
ConnectionRoute |
findProxyForUrl(URL url)
Finds the first usable connection route according to the PAC specification for the specified url. |
PacCallback |
getPacCallback()
Returns the PAC callback of this PacManager. |
URL |
getPacLocation()
Returns the location where the PAC can be found. |
void |
setPacCallback(PacCallback pacCallback)
Sets this PacManager's PAC callback to the specified
pacCallback. |
void |
setPacLocation(URL pacLocation)
Sets the location where the PAC can be found to the specified pacLocation. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public PacManager()
Constructs a PacManager.
public PacManager(URL pacLocation)
throws IllegalArgumentException
PacManager()
followed by setPacLocation(URL). The
setPacLocation(URL) method throws an
IOException or JavaScriptException
as of 1.6.0 if respectively loading the implementation and/or
the PAC script fails, and/or the implementation and/or the
PAC script contains a JavaScript error. Previously it was
difficult for the user of this PacManager to
know if loading or parsing the implementation and/or PAC
script failed, unless by investigating the debug output.
Constructs a PacManager with the specified
pacLocation, which loads the implementation and PAC scripts
using a PacScripter.
pacLocation - the location where the PAC can be found.
IllegalArgumentException - if the specified pacLocation is
null.PacScripter#PacScripter(URL)| Method Detail |
public boolean areProxiesEnabled()
Determines whether proxies are enabled.
true if proxies are enabled, false
if not.#setProxiesEnabled(boolean)
public Proxy[] findProxy(String url)
throws UnsupportedOperationException
findProxyForUrl(URL).
findProxy in interface ProxyResolverUnsupportedOperationException
public ConnectionRoute findProxyForUrl(URL url)
throws ConnectionRouteNotFoundException,
IllegalArgumentException
Finds the first usable connection route according to the PAC
specification for the specified url.
In the following scenarios it will return a default
Direct connection route containing the specified
url:
areProxiesEnabled()).
If no usable connection route could be found, no DIRECT
option was specified and a PacCallback was registered with
this PacManager
(), the end-user is asked
for confirmation if proxies should be temporarily ignored
(getPacCallback() != null), and
PacCallback.ignoreProxies()Direct connection routes should be attempted
(). The end-user will
again be asked if proxies should be retried after 20 minutes, or whatever
the property #setProxiesEnabled(boolean)ice.net.pac.proxiesRetryInterval defines in
milliseconds, has passed
(), always increasing the
interval by itself.#setProxiesEnabled(boolean)
If no usable connection route could be found, no DIRECT
option was specified and no PacCallback was registered with
this PacManager
(), all the possible
getPacCallback() == nullConnectionRoutes for the specified url will be
reset to ConnectionRoute.UNTESTED
() and an
ConnectionRoute.setStatus(int)UnknownHostException is thrown.
A usable connection route is a ConnectionRoute with
either an or
ConnectionRoute.UNTESTED status.ConnectionRoute.KNOWN_GOOD
findProxyForUrl in interface ProxyResolverurl - the full URL being accessed.
ConnectionRoute.
ConnectionRouteNotFoundException - if no usable ConnectionRoute could be found.
IllegalArgumentException - if the specified url is null.ConnectionRoute,
Directpublic PacCallback getPacCallback()
Returns the PAC callback of this PacManager.
setPacCallback(PacCallback)public URL getPacLocation()
Returns the location where the PAC can be found.
PacScripter#getPacLocation(),
setPacLocation(URL)public void setPacCallback(PacCallback pacCallback)
Sets this PacManager's PAC callback to the specified
pacCallback.
pacCallback - the new PAC callback.getPacCallback()
public void setPacLocation(URL pacLocation)
throws IllegalArgumentException,
IOException,
org.mozilla.javascript.JavaScriptException
Sets the location where the PAC can be found to the specified
pacLocation.
pacLocation - the location where the PAC can be found.
IllegalArgumentException - if the specified pacLocation is
null.
IOException - if the implementation or the PAC script could not be
loaded.
org.mozilla.javascript.JavaScriptException - if the implementation or the PAC script contains a
JavaScript error.PacScripter#setPacLocation(URL),
getPacLocation()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||