1 7 8 package java.net; 9 10 import java.io.IOException ; 11 import java.util.List ; 12 import sun.security.util.SecurityConstants; 13 14 39 public abstract class ProxySelector { 40 47 private static ProxySelector theProxySelector; 48 49 static { 50 try { 51 Class c = Class.forName("sun.net.spi.DefaultProxySelector"); 52 if (c != null && ProxySelector .class.isAssignableFrom(c)) { 53 theProxySelector = (ProxySelector ) c.newInstance(); 54 } 55 } catch (Exception e) { 56 theProxySelector = null; 57 } 58 } 59 60 70 public static ProxySelector getDefault() { 71 SecurityManager sm = System.getSecurityManager(); 72 if (sm != null) { 73 sm.checkPermission(SecurityConstants.GET_PROXYSELECTOR_PERMISSION); 74 } 75 return theProxySelector; 76 } 77 78 93 public static void setDefault(ProxySelector ps) { 94 SecurityManager sm = System.getSecurityManager(); 95 if (sm != null) { 96 sm.checkPermission(SecurityConstants.SET_PROXYSELECTOR_PERMISSION); 97 } 98 theProxySelector = ps; 99 } 100 101 126 public abstract List <Proxy > select(URI uri); 127 128 144 public abstract void connectFailed(URI uri, SocketAddress sa, IOException ioe); 145 } 146 147 | Popular Tags |