330 protected PlatformSocketOptions() {}
331
332 @SuppressWarnings("unchecked")
333 private static PlatformSocketOptions newInstance(String cn) {
334 Class<PlatformSocketOptions> c;
335 try {
336 c = (Class<PlatformSocketOptions>)Class.forName(cn);
337 return c.getConstructor(new Class<?>[] { }).newInstance();
338 } catch (ReflectiveOperationException x) {
339 throw new AssertionError(x);
340 }
341 }
342
343 private static PlatformSocketOptions create() {
344 String osname = AccessController.doPrivileged(
345 new PrivilegedAction<String>() {
346 public String run() {
347 return System.getProperty("os.name");
348 }
349 });
350 if ("SunOS".equals(osname)) {
351 return newInstance("jdk.net.SolarisSocketOptions");
352 } else if ("Linux".equals(osname)) {
353 return newInstance("jdk.net.LinuxSocketOptions");
354 } else if (osname.startsWith("Mac")) {
355 return newInstance("jdk.net.MacOSXSocketOptions");
356 } else {
357 return new PlatformSocketOptions();
358 }
359 }
360
361 private static final PlatformSocketOptions instance = create();
362
363 static PlatformSocketOptions get() {
364 return instance;
365 }
366
367 int setFlowOption(int fd, int priority, long bandwidth)
368 throws SocketException
369 {
370 throw new UnsupportedOperationException("unsupported socket option");
371 }
372
|
330 protected PlatformSocketOptions() {}
331
332 @SuppressWarnings("unchecked")
333 private static PlatformSocketOptions newInstance(String cn) {
334 Class<PlatformSocketOptions> c;
335 try {
336 c = (Class<PlatformSocketOptions>)Class.forName(cn);
337 return c.getConstructor(new Class<?>[] { }).newInstance();
338 } catch (ReflectiveOperationException x) {
339 throw new AssertionError(x);
340 }
341 }
342
343 private static PlatformSocketOptions create() {
344 String osname = AccessController.doPrivileged(
345 new PrivilegedAction<String>() {
346 public String run() {
347 return System.getProperty("os.name");
348 }
349 });
350 if ("Linux".equals(osname)) {
351 return newInstance("jdk.net.LinuxSocketOptions");
352 } else if (osname.startsWith("Mac")) {
353 return newInstance("jdk.net.MacOSXSocketOptions");
354 } else {
355 return new PlatformSocketOptions();
356 }
357 }
358
359 private static final PlatformSocketOptions instance = create();
360
361 static PlatformSocketOptions get() {
362 return instance;
363 }
364
365 int setFlowOption(int fd, int priority, long bandwidth)
366 throws SocketException
367 {
368 throw new UnsupportedOperationException("unsupported socket option");
369 }
370
|