1 /* |
1 /* |
2 * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2005, 2011, 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 |
79 private static boolean loadProviderFromProperty() { |
79 private static boolean loadProviderFromProperty() { |
80 String cn = System.getProperty("com.sun.net.httpserver.HttpServerProvider"); |
80 String cn = System.getProperty("com.sun.net.httpserver.HttpServerProvider"); |
81 if (cn == null) |
81 if (cn == null) |
82 return false; |
82 return false; |
83 try { |
83 try { |
84 Class c = Class.forName(cn, true, |
84 Class<?> c = Class.forName(cn, true, |
85 ClassLoader.getSystemClassLoader()); |
85 ClassLoader.getSystemClassLoader()); |
86 provider = (HttpServerProvider)c.newInstance(); |
86 provider = (HttpServerProvider)c.newInstance(); |
87 return true; |
87 return true; |
88 } catch (ClassNotFoundException x) { |
88 } catch (ClassNotFoundException | |
89 throw new ServiceConfigurationError(x); |
89 IllegalAccessException | |
90 } catch (IllegalAccessException x) { |
90 InstantiationException | |
91 throw new ServiceConfigurationError(x); |
91 SecurityException x) { |
92 } catch (InstantiationException x) { |
|
93 throw new ServiceConfigurationError(x); |
|
94 } catch (SecurityException x) { |
|
95 throw new ServiceConfigurationError(x); |
92 throw new ServiceConfigurationError(x); |
96 } |
93 } |
97 } |
94 } |
98 |
95 |
99 private static boolean loadProviderAsService() { |
96 private static boolean loadProviderAsService() { |
100 Iterator i = Service.providers(HttpServerProvider.class, |
97 @SuppressWarnings("unchecked") |
|
98 Iterator<HttpServerProvider> i = Service.providers(HttpServerProvider.class, |
101 ClassLoader.getSystemClassLoader()); |
99 ClassLoader.getSystemClassLoader()); |
102 for (;;) { |
100 for (;;) { |
103 try { |
101 try { |
104 if (!i.hasNext()) |
102 if (!i.hasNext()) |
105 return false; |
103 return false; |
106 provider = (HttpServerProvider)i.next(); |
104 provider = i.next(); |
107 return true; |
105 return true; |
108 } catch (ServiceConfigurationError sce) { |
106 } catch (ServiceConfigurationError sce) { |
109 if (sce.getCause() instanceof SecurityException) { |
107 if (sce.getCause() instanceof SecurityException) { |
110 // Ignore the security exception, try the next provider |
108 // Ignore the security exception, try the next provider |
111 continue; |
109 continue; |