< prev index next >

src/java.base/share/classes/java/net/ProxySelector.java

Print this page




  54  * related to proxy settings.</P>
  55  *
  56  * @author Yingxian Wang
  57  * @author Jean-Christophe Collet
  58  * @since 1.5
  59  */
  60 public abstract class ProxySelector {
  61     /**
  62      * The system wide proxy selector that selects the proxy server to
  63      * use, if any, when connecting to a remote object referenced by
  64      * an URL.
  65      *
  66      * @see #setDefault(ProxySelector)
  67      */
  68     private static ProxySelector theProxySelector;
  69 
  70     static {
  71         try {
  72             Class<?> c = Class.forName("sun.net.spi.DefaultProxySelector");
  73             if (c != null && ProxySelector.class.isAssignableFrom(c)) {
  74                 theProxySelector = (ProxySelector) c.newInstance();


  75             }
  76         } catch (Exception e) {
  77             theProxySelector = null;
  78         }
  79     }
  80 
  81     /**
  82      * Gets the system-wide proxy selector.
  83      *
  84      * @throws  SecurityException
  85      *          If a security manager has been installed and it denies
  86      * {@link NetPermission}{@code ("getProxySelector")}
  87      * @see #setDefault(ProxySelector)
  88      * @return the system-wide {@code ProxySelector}
  89      * @since 1.5
  90      */
  91     public static ProxySelector getDefault() {
  92         SecurityManager sm = System.getSecurityManager();
  93         if (sm != null) {
  94             sm.checkPermission(SecurityConstants.GET_PROXYSELECTOR_PERMISSION);




  54  * related to proxy settings.</P>
  55  *
  56  * @author Yingxian Wang
  57  * @author Jean-Christophe Collet
  58  * @since 1.5
  59  */
  60 public abstract class ProxySelector {
  61     /**
  62      * The system wide proxy selector that selects the proxy server to
  63      * use, if any, when connecting to a remote object referenced by
  64      * an URL.
  65      *
  66      * @see #setDefault(ProxySelector)
  67      */
  68     private static ProxySelector theProxySelector;
  69 
  70     static {
  71         try {
  72             Class<?> c = Class.forName("sun.net.spi.DefaultProxySelector");
  73             if (c != null && ProxySelector.class.isAssignableFrom(c)) {
  74                 @SuppressWarnings("deprecation")
  75                 ProxySelector tmp = (ProxySelector) c.newInstance();
  76                 theProxySelector = tmp;
  77             }
  78         } catch (Exception e) {
  79             theProxySelector = null;
  80         }
  81     }
  82 
  83     /**
  84      * Gets the system-wide proxy selector.
  85      *
  86      * @throws  SecurityException
  87      *          If a security manager has been installed and it denies
  88      * {@link NetPermission}{@code ("getProxySelector")}
  89      * @see #setDefault(ProxySelector)
  90      * @return the system-wide {@code ProxySelector}
  91      * @since 1.5
  92      */
  93     public static ProxySelector getDefault() {
  94         SecurityManager sm = System.getSecurityManager();
  95         if (sm != null) {
  96             sm.checkPermission(SecurityConstants.GET_PROXYSELECTOR_PERMISSION);


< prev index next >