org.jurvis.net
Class JvProxyConfig

java.lang.Object
  extended by org.jurvis.net.JvProxyConfig

public class JvProxyConfig
extends Object

The internet proxy configuration.

Author:
Neil W. Weber

Field Summary
static int AUTOMATIC
          Enumerated value indicating internet connections should be made through an automatically configured proxy (i.e.
protected  String configurationScriptURL
          The URL of the automatic configuration proxy script.
static int DIRECT
          Enumerated value indicating internet connections should be made directly (i.e.
protected  Map manual
          Map keyed by protocol (e.g.
static int MANUAL
          Enumerated value indicating internet connections should be made through a manually configured proxy (i.e.
protected  int method
          The method used to connect to the internet.
 
Constructor Summary
JvProxyConfig()
          Construct a new JvProxyConfig with a method of DIRECT (i.e.
JvProxyConfig(String scriptURL)
          Construct a new JvProxyConfig that uses a proxy auto-config script.
 
Method Summary
 int getMethod()
          Return the method used to connect to the internet.
 JvProxyInfo getProxy(String protocol)
          Return the manually configured proxy for the specified protocol (e.g.
 List getProxyForURI(String uri)
          For the specified URI, return the list of proxies that should be used to access the resource at the URI.
 List getProxyForURI(URI uri)
          For the specified URI, return the list of proxies that should be used to access the resource at the URI.
 void setMethod(int method)
          Set the method used to connect to the internet.
 void setProxy(String protocol, String host, int port)
          Set the manually configured proxy for the specified protocol.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIRECT

public static final int DIRECT
Enumerated value indicating internet connections should be made directly (i.e. without proxies).

See Also:
Constant Field Values

MANUAL

public static final int MANUAL
Enumerated value indicating internet connections should be made through a manually configured proxy (i.e. the user has explicitly provided the Internet address of the proxy).

See Also:
Constant Field Values

AUTOMATIC

public static final int AUTOMATIC
Enumerated value indicating internet connections should be made through an automatically configured proxy (i.e. the proxy is determined via an auto-config script).

See Also:
Constant Field Values

method

protected int method
The method used to connect to the internet. One of DIRECT, MANUAL, or AUTOMATIC.


configurationScriptURL

protected String configurationScriptURL
The URL of the automatic configuration proxy script.


manual

protected Map manual
Map keyed by protocol (e.g. "http") of manually configured proxies. Value is a JvProxyInfo object holding host and port.

Constructor Detail

JvProxyConfig

public JvProxyConfig()
Construct a new JvProxyConfig with a method of DIRECT (i.e. a proxy is not used).


JvProxyConfig

public JvProxyConfig(String scriptURL)
Construct a new JvProxyConfig that uses a proxy auto-config script.

Parameters:
scriptURL - the URL of the auto-config script
Method Detail

getMethod

public int getMethod()
Return the method used to connect to the internet. One of DIRECT, MANUAL, or AUTOMATIC.

Returns:
the method used to connect to the internet

setMethod

public void setMethod(int method)
Set the method used to connect to the internet.

Parameters:
method - the method used to connect to the internet

getProxy

public JvProxyInfo getProxy(String protocol)
Return the manually configured proxy for the specified protocol (e.g. "http"). Returns null if no proxy has been specified for the protocol or if the protocol is invalid.

Returns:
the proxy hostname and port for the specified protocol or null if not set

setProxy

public void setProxy(String protocol,
                     String host,
                     int port)
Set the manually configured proxy for the specified protocol. No validity checking is performed on the protocol (i.e. "blech" is silently accepted).

Parameters:
protocol - the internet protocol
host - the name of the proxy host
port - the proxy port number

getProxyForURI

public List getProxyForURI(String uri)
                    throws Exception
For the specified URI, return the list of proxies that should be used to access the resource at the URI.

Parameters:
uri - the desired URI
Returns:
an ordered list of JvProxyInfos or null if no proxies should be used (i.e. connect directly)
Throws:
Exception

getProxyForURI

public List getProxyForURI(URI uri)
                    throws Exception
For the specified URI, return the list of proxies that should be used to access the resource at the URI. This method evaluates the proxy configuration to determine the proxy(s). For automatic configurations via a configuration script, the script is downloaded and evaluated.

Parameters:
uri - the desired URI
Returns:
an ordered list of JvProxyInfos or null if no proxies should be used (i.e. connect directly)
Throws:
Exception


Copyright © 1999-2004 Neil W. Weber. All Rights Reserved.