59 }
60 private AsynchronousChannelProvider(Void ignore) { }
61
62 /**
63 * Initializes a new instance of this class.
64 *
65 * @throws SecurityException
66 * If a security manager has been installed and it denies
67 * {@link RuntimePermission}<tt>("asynchronousChannelProvider")</tt>
68 */
69 protected AsynchronousChannelProvider() {
70 this(checkPermission());
71 }
72
73 // lazy initialization of default provider
74 private static class ProviderHolder {
75 static final AsynchronousChannelProvider provider = load();
76
77 private static AsynchronousChannelProvider load() {
78 return AccessController
79 .doPrivileged(new PrivilegedAction<AsynchronousChannelProvider>() {
80 public AsynchronousChannelProvider run() {
81 AsynchronousChannelProvider p;
82 p = loadProviderFromProperty();
83 if (p != null)
84 return p;
85 p = loadProviderAsService();
86 if (p != null)
87 return p;
88 return sun.nio.ch.DefaultAsynchronousChannelProvider.create();
89 }});
90 }
91
92 private static AsynchronousChannelProvider loadProviderFromProperty() {
93 String cn = System.getProperty("java.nio.channels.spi.AsynchronousChannelProvider");
94 if (cn == null)
95 return null;
96 try {
97 Class<?> c = Class.forName(cn, true,
98 ClassLoader.getSystemClassLoader());
99 return (AsynchronousChannelProvider)c.newInstance();
|
59 }
60 private AsynchronousChannelProvider(Void ignore) { }
61
62 /**
63 * Initializes a new instance of this class.
64 *
65 * @throws SecurityException
66 * If a security manager has been installed and it denies
67 * {@link RuntimePermission}<tt>("asynchronousChannelProvider")</tt>
68 */
69 protected AsynchronousChannelProvider() {
70 this(checkPermission());
71 }
72
73 // lazy initialization of default provider
74 private static class ProviderHolder {
75 static final AsynchronousChannelProvider provider = load();
76
77 private static AsynchronousChannelProvider load() {
78 return AccessController
79 .doPrivileged(new PrivilegedAction<>() {
80 public AsynchronousChannelProvider run() {
81 AsynchronousChannelProvider p;
82 p = loadProviderFromProperty();
83 if (p != null)
84 return p;
85 p = loadProviderAsService();
86 if (p != null)
87 return p;
88 return sun.nio.ch.DefaultAsynchronousChannelProvider.create();
89 }});
90 }
91
92 private static AsynchronousChannelProvider loadProviderFromProperty() {
93 String cn = System.getProperty("java.nio.channels.spi.AsynchronousChannelProvider");
94 if (cn == null)
95 return null;
96 try {
97 Class<?> c = Class.forName(cn, true,
98 ClassLoader.getSystemClassLoader());
99 return (AsynchronousChannelProvider)c.newInstance();
|