FileDocCategorySizeDatePackage
ProxySelector.javaAPI DocAndroid 1.5 API4910Wed May 06 22:41:04 BST 2009java.net

ProxySelector

public abstract class ProxySelector extends Object
Selects an applicable proxy server when connecting to a resource specified by a URL. Proxy selectors are concrete subclasses of {@code ProxySelector} and can be set as default by calling the {@code setDefault()} method. If a connection can't be established, the caller should notify the proxy selector by invoking the {@code connectFailed()} method.
since
Android 1.0

Fields Summary
private static ProxySelector
defaultSelector
private static final NetPermission
getProxySelectorPermission
private static final NetPermission
setProxySelectorPermission
Constructors Summary
public ProxySelector()
Creates a new {@code ProxySelector} instance.

since
Android 1.0

 //$NON-NLS-1$

                   
      
        super();
    
Methods Summary
public abstract voidconnectFailed(java.net.URI uri, java.net.SocketAddress sa, java.io.IOException ioe)
Notifies the {@code ProxySelector} that a connection to the proxy server could not be established. A concrete implementation should upon this notification maintain the list of available proxies, since an updated version should be provided by {@code select()}.

param
uri the URI to which the connection could not be established.
param
sa the address of the proxy.
param
ioe the exception which was thrown during connection establishment.
see
#select(URI)
since
Android 1.0

public static java.net.ProxySelectorgetDefault()
Gets the default {@code ProxySelector} of the system.

return
the currently set default {@code ProxySelector}.
throws
SecurityException if a security manager is installed but it doesn't have the NetPermission("getProxySelector").
since
Android 1.0

        SecurityManager sm = System.getSecurityManager();
        if (null != sm) {
            sm.checkPermission(getProxySelectorPermission);
        }
        return defaultSelector;
    
public abstract java.util.Listselect(java.net.URI uri)
Gets all applicable proxies based on the accessing protocol of {@code uri}. The format of URI is defined as below:

  • http URI stands for http connection.
  • https URI stands for https connection.
  • ftp URI stands for ftp connection.
  • socket:://ip:port URI stands for tcp client sockets connection.
  • param
    uri the target URI object.
    return
    a list containing all applicable proxies. If no proxy is available, the list contains only the {@code Proxy.NO_PROXY} element.
    since
    Android 1.0

    public static voidsetDefault(java.net.ProxySelector selector)
    Sets the default {@code ProxySelector} of the system. Removes the system default {@code ProxySelector} if the parameter {@code selector} is set to {@code null}.

    param
    selector the {@code ProxySelector} instance to set as default or {@code null} to remove the current default {@code ProxySelector}.
    throws
    SecurityException if a security manager is installed but it doesn't have the NetPermission("setProxySelector").
    since
    Android 1.0

            SecurityManager sm = System.getSecurityManager();
            if (null != sm) {
                sm.checkPermission(setProxySelectorPermission);
            }
            defaultSelector = selector;