1 |
/* SelectorProvider.java |
/* SelectorProvider.java |
2 |
Copyright (C) 2002 Free Software Foundation, Inc. |
Copyright (C) 2002, 2003 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
50 |
*/ |
*/ |
51 |
public abstract class SelectorProvider |
public abstract class SelectorProvider |
52 |
{ |
{ |
53 |
static SelectorProvider pr; |
private static SelectorProvider systemDefaultProvider; |
54 |
|
|
55 |
/** |
/** |
56 |
* Initializes the selector provider. |
* Initializes the selector provider. |
95 |
* Returns the system-wide default selector provider for this invocation |
* Returns the system-wide default selector provider for this invocation |
96 |
* of the Java virtual machine. |
* of the Java virtual machine. |
97 |
*/ |
*/ |
98 |
public static SelectorProvider provider () |
public static synchronized SelectorProvider provider () |
99 |
{ |
{ |
100 |
if (pr == null) |
if (systemDefaultProvider == null) |
101 |
{ |
{ |
102 |
pr = new SelectorProviderImpl (); |
String propertyValue = |
103 |
|
System.getProperty ("java.nio.channels.spi.SelectorProvider"); |
104 |
|
|
105 |
|
if (propertyValue == null |
106 |
|
|| propertyValue.equals ("")) |
107 |
|
systemDefaultProvider = new SelectorProviderImpl(); |
108 |
|
else |
109 |
|
{ |
110 |
|
try |
111 |
|
{ |
112 |
|
systemDefaultProvider = (SelectorProvider) Class.forName |
113 |
|
(propertyValue).newInstance(); |
114 |
|
} |
115 |
|
catch (Exception e) |
116 |
|
{ |
117 |
|
System.err.println ("Could not instantiate class: " |
118 |
|
+ propertyValue); |
119 |
|
systemDefaultProvider = new SelectorProviderImpl(); |
120 |
|
} |
121 |
|
} |
122 |
} |
} |
123 |
|
|
124 |
return pr; |
return systemDefaultProvider; |
125 |
} |
} |
126 |
} |
} |