< prev index next >

src/jdk.httpserver/share/classes/com/sun/net/httpserver/spi/HttpServerProvider.java

Print this page




  72     private static HttpServerProvider provider = null;
  73 
  74     /**
  75      * Initializes a new instance of this class.
  76      *
  77      * @throws  SecurityException
  78      *          If a security manager has been installed and it denies
  79      *          {@link RuntimePermission}{@code ("httpServerProvider")}
  80      */
  81     protected HttpServerProvider() {
  82         SecurityManager sm = System.getSecurityManager();
  83         if (sm != null)
  84             sm.checkPermission(new RuntimePermission("httpServerProvider"));
  85     }
  86 
  87     private static boolean loadProviderFromProperty() {
  88         String cn = System.getProperty("com.sun.net.httpserver.HttpServerProvider");
  89         if (cn == null)
  90             return false;
  91         try {
  92             Class<?> c = Class.forName(cn, true,
  93                                        ClassLoader.getSystemClassLoader());
  94             provider = (HttpServerProvider)c.newInstance();

  95             return true;
  96         } catch (ClassNotFoundException |
  97                  IllegalAccessException |
  98                  InstantiationException |
  99                  SecurityException x) {
 100             throw new ServiceConfigurationError(null, x);
 101         }
 102     }
 103 
 104     private static boolean loadProviderAsService() {
 105         Iterator<HttpServerProvider> i =
 106             ServiceLoader.load(HttpServerProvider.class,
 107                                ClassLoader.getSystemClassLoader())
 108                 .iterator();
 109         for (;;) {
 110             try {
 111                 if (!i.hasNext())
 112                     return false;
 113                 provider = i.next();
 114                 return true;




  72     private static HttpServerProvider provider = null;
  73 
  74     /**
  75      * Initializes a new instance of this class.
  76      *
  77      * @throws  SecurityException
  78      *          If a security manager has been installed and it denies
  79      *          {@link RuntimePermission}{@code ("httpServerProvider")}
  80      */
  81     protected HttpServerProvider() {
  82         SecurityManager sm = System.getSecurityManager();
  83         if (sm != null)
  84             sm.checkPermission(new RuntimePermission("httpServerProvider"));
  85     }
  86 
  87     private static boolean loadProviderFromProperty() {
  88         String cn = System.getProperty("com.sun.net.httpserver.HttpServerProvider");
  89         if (cn == null)
  90             return false;
  91         try {
  92             @SuppressWarnings("deprecation")
  93             Object o = Class.forName(cn, true,
  94                                      ClassLoader.getSystemClassLoader()).newInstance();
  95             provider = (HttpServerProvider)o;
  96             return true;
  97         } catch (ClassNotFoundException |
  98                  IllegalAccessException |
  99                  InstantiationException |
 100                  SecurityException x) {
 101             throw new ServiceConfigurationError(null, x);
 102         }
 103     }
 104 
 105     private static boolean loadProviderAsService() {
 106         Iterator<HttpServerProvider> i =
 107             ServiceLoader.load(HttpServerProvider.class,
 108                                ClassLoader.getSystemClassLoader())
 109                 .iterator();
 110         for (;;) {
 111             try {
 112                 if (!i.hasNext())
 113                     return false;
 114                 provider = i.next();
 115                 return true;


< prev index next >