Methods Summary |
---|
protected int | getDefaultPort()Returns the default HTTP port.
return DEFAULT_HTTP_PORT;
|
private static java.net.URLStreamHandler | getDefaultStreamHandler(java.lang.String protocol)
synchronized (PROTOCOL_HANDLERS) {
URLStreamHandler handler = (URLStreamHandler)
PROTOCOL_HANDLERS.get(protocol);
if (handler != null) return handler;
if (factory != null) {
handler = factory.createURLStreamHandler(protocol);
}
if (handler == null) {
String path = System.getProperty(HANDLER_PKGS_PROPERTY);
StringTokenizer tokenizer = new StringTokenizer(path, "|");
while (tokenizer.hasMoreTokens()) {
String provider = tokenizer.nextToken().trim();
if (provider.equals("jcifs")) continue;
String className = provider + "." + protocol + ".Handler";
try {
Class handlerClass = null;
try {
handlerClass = Class.forName(className);
} catch (Exception ex) { }
if (handlerClass == null) {
handlerClass = ClassLoader.getSystemClassLoader(
).loadClass(className);
}
handler = (URLStreamHandler) handlerClass.newInstance();
break;
} catch (Exception ex) { }
}
}
if (handler == null) {
for (int i = 0; i < JVM_VENDOR_DEFAULT_PKGS.length; i++) {
String className = JVM_VENDOR_DEFAULT_PKGS[i] + "." +
protocol + ".Handler";
try {
Class handlerClass = null;
try {
handlerClass = Class.forName(className);
} catch (Exception ex) { }
if (handlerClass == null) {
handlerClass = ClassLoader.getSystemClassLoader(
).loadClass(className);
}
handler = (URLStreamHandler) handlerClass.newInstance();
} catch (Exception ex) { }
if (handler != null) break;
}
}
if (handler == null) {
throw new IOException(
"Unable to find default handler for protocol: " +
protocol);
}
PROTOCOL_HANDLERS.put(protocol, handler);
return handler;
}
|
protected java.net.URLConnection | openConnection(java.net.URL url)
url = new URL(url, url.toExternalForm(),
getDefaultStreamHandler(url.getProtocol()));
return new NtlmHttpURLConnection((HttpURLConnection)
url.openConnection());
|
public static void | setURLStreamHandlerFactory(java.net.URLStreamHandlerFactory factory)Sets the URL stream handler factory for the environment. This
allows specification of the factory used in creating underlying
stream handlers. This can be called once per JVM instance.
synchronized (PROTOCOL_HANDLERS) {
if (Handler.factory != null) {
throw new IllegalStateException(
"URLStreamHandlerFactory already set.");
}
PROTOCOL_HANDLERS.clear();
Handler.factory = factory;
}
|