Methods Summary |
---|
public java.nio.channels.Channel | inheritedChannel()Returns the channel inherited from the instance that created this
virtual machine.
// BEGIN android-added
SecurityManager smngr = System.getSecurityManager();
if (smngr != null) {
smngr.checkPermission(
new RuntimePermission("inheritedChannel")); //$NON-NLS-1$
}
// END android-added
if (null == inheritedChannel) {
inheritedChannel = Platform.getNetworkSystem().inheritedChannel();
}
return inheritedChannel;
|
static java.nio.channels.spi.SelectorProvider | loadProviderByJar()
Enumeration<URL> enumeration = null;
ClassLoader classLoader = AccessController.doPrivileged(
new PrivilegedAction<ClassLoader>() {
public ClassLoader run() {
return ClassLoader.getSystemClassLoader();
}
});
try {
enumeration = classLoader.getResources(PROVIDER_IN_JAR_RESOURCE);
} catch (IOException e) {
throw new Error(e);
}
if (null == enumeration) {
return null;
}
// for every jar, read until we find the provider name.
while (enumeration.hasMoreElements()) {
BufferedReader br = null;
String className = null;
try {
// BEGIN android-modified
br = new BufferedReader(
new InputStreamReader(
(enumeration.nextElement()).openStream()),
8192);
// END android-modified
} catch (Exception e) {
continue;
}
try {
// only the first class is loaded ,as spec says, not the same as
// we do before.
while ((className = br.readLine()) != null) {
className = className.trim();
int siteComment = className.indexOf(SYMBOL_COMMENT);
className = (-1 == siteComment) ? className : className
.substring(0, siteComment);
if (0 < className.length()) {
return (SelectorProvider) classLoader.loadClass(
className).newInstance();
}
}
} catch (Exception e) {
throw new Error(e);
// BEGIN android-added
// copied from a newer version of harmony
} finally {
try {
br.close();
} catch (IOException ioe) {
// Ignore
}
// END android-added
}
}
return null;
|
static java.nio.channels.spi.SelectorProvider | loadProviderByProperty()
return AccessController.doPrivileged(
new PrivilegedAction<SelectorProvider>() {
public SelectorProvider run() {
try {
final String className =
System.getProperty(PROVIDER_IN_SYSTEM_PROPERTY);
if (null != className) {
Class<?> spClass = ClassLoader
.getSystemClassLoader().loadClass(
className);
return (SelectorProvider)spClass.newInstance();
}
return null;
} catch (Exception e) {
throw new Error(e);
}
}
});
|
public abstract java.nio.channels.DatagramChannel | openDatagramChannel()Creates a new open {@code DatagramChannel}.
|
public abstract java.nio.channels.Pipe | openPipe()Creates a new {@code Pipe}.
|
public abstract java.nio.channels.spi.AbstractSelector | openSelector()Creates a new selector.
|
public abstract java.nio.channels.ServerSocketChannel | openServerSocketChannel()Creates a new open {@code ServerSocketChannel}.
|
public abstract java.nio.channels.SocketChannel | openSocketChannel()Create a new open {@code SocketChannel}.
|
public static synchronized java.nio.channels.spi.SelectorProvider | provider()Gets a provider instance by executing the following steps when called for
the first time:
- if the system property "java.nio.channels.spi.SelectorProvider" is
set, the value of this property is the class name of the provider
returned;
- if there is a provider-configuration file named
"java.nio.channels.spi.SelectorProvider" in META-INF/services of a jar
file valid in the system class loader, the first class name is the
provider's class name;
- otherwise, a system default provider will be returned.
if (null == provider) {
provider = loadProviderByProperty();
if (null == provider) {
provider = loadProviderByJar();
}
if (null == provider) {
provider = AccessController
.doPrivileged(new PrivilegedAction<SelectorProvider>() {
public SelectorProvider run() {
return new SelectorProviderImpl();
}
});
}
}
return provider;
|