src/java.base/share/classes/java/net/ProxySelector.java
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 52499 768b1c612100
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    83     /**
    83     /**
    84      * Gets the system-wide proxy selector.
    84      * Gets the system-wide proxy selector.
    85      *
    85      *
    86      * @throws  SecurityException
    86      * @throws  SecurityException
    87      *          If a security manager has been installed and it denies
    87      *          If a security manager has been installed and it denies
    88      * {@link NetPermission}{@code ("getProxySelector")}
    88      *          {@link NetPermission}{@code ("getProxySelector")}
    89      * @see #setDefault(ProxySelector)
    89      * @see     #setDefault(ProxySelector)
    90      * @return the system-wide {@code ProxySelector}
    90      * @return  the system-wide {@code ProxySelector}
    91      * @since 1.5
    91      * @since   1.5
    92      */
    92      */
    93     public static ProxySelector getDefault() {
    93     public static ProxySelector getDefault() {
    94         SecurityManager sm = System.getSecurityManager();
    94         SecurityManager sm = System.getSecurityManager();
    95         if (sm != null) {
    95         if (sm != null) {
    96             sm.checkPermission(SecurityConstants.GET_PROXYSELECTOR_PERMISSION);
    96             sm.checkPermission(SecurityConstants.GET_PROXYSELECTOR_PERMISSION);
   106      * @param ps The HTTP proxy selector, or
   106      * @param ps The HTTP proxy selector, or
   107      *          {@code null} to unset the proxy selector.
   107      *          {@code null} to unset the proxy selector.
   108      *
   108      *
   109      * @throws  SecurityException
   109      * @throws  SecurityException
   110      *          If a security manager has been installed and it denies
   110      *          If a security manager has been installed and it denies
   111      * {@link NetPermission}{@code ("setProxySelector")}
   111      *          {@link NetPermission}{@code ("setProxySelector")}
   112      *
   112      *
   113      * @see #getDefault()
   113      * @see #getDefault()
   114      * @since 1.5
   114      * @since 1.5
   115      */
   115      */
   116     public static void setDefault(ProxySelector ps) {
   116     public static void setDefault(ProxySelector ps) {
   141      *          {@link java.net.Proxy Proxy};
   141      *          {@link java.net.Proxy Proxy};
   142      *          when no proxy is available, the list will
   142      *          when no proxy is available, the list will
   143      *          contain one element of type
   143      *          contain one element of type
   144      *          {@link java.net.Proxy Proxy}
   144      *          {@link java.net.Proxy Proxy}
   145      *          that represents a direct connection.
   145      *          that represents a direct connection.
   146      * @throws IllegalArgumentException if the argument is null
   146      * @throws IllegalArgumentException if the argument is null or if
       
   147      *         the protocol or host cannot be determined from the provided
       
   148      *         {@code uri}
   147      */
   149      */
   148     public abstract List<Proxy> select(URI uri);
   150     public abstract List<Proxy> select(URI uri);
   149 
   151 
   150     /**
   152     /**
   151      * Called to indicate that a connection could not be established
   153      * Called to indicate that a connection could not be established
   159      * @param   sa
   161      * @param   sa
   160      *          The socket address of the proxy/SOCKS server
   162      *          The socket address of the proxy/SOCKS server
   161      *
   163      *
   162      * @param   ioe
   164      * @param   ioe
   163      *          The I/O exception thrown when the connect failed.
   165      *          The I/O exception thrown when the connect failed.
   164      * @throws IllegalArgumentException if either argument is null
   166      * @throws  IllegalArgumentException if either argument is null
   165      */
   167      */
   166     public abstract void connectFailed(URI uri, SocketAddress sa, IOException ioe);
   168     public abstract void connectFailed(URI uri, SocketAddress sa, IOException ioe);
   167 
   169 
   168     /**
   170     /**
   169      * Returns a ProxySelector which uses the given proxy address for all HTTP
   171      * Returns a ProxySelector which uses the given proxy address for all HTTP