29import java.net.URLStreamHandler;
30import java.net.URLStreamHandlerFactory;
31import java.security.PrivilegedAction;
32import java.util.HashMap;
35import org.jau.sec.SecurityUtil;
37public class GenericURLStreamHandlerFactory
implements URLStreamHandlerFactory {
38 private static GenericURLStreamHandlerFactory factory =
null;
40 private final Map<String, URLStreamHandler> protocolHandlers;
42 private GenericURLStreamHandlerFactory() {
43 protocolHandlers =
new HashMap<String, URLStreamHandler>();
51 public synchronized final URLStreamHandler
setHandler(
final String protocol,
final URLStreamHandler handler) {
52 return protocolHandlers.put(protocol, handler);
59 public synchronized final URLStreamHandler
getHandler(
final String protocol) {
60 return protocolHandlers.get(protocol);
75 public synchronized static GenericURLStreamHandlerFactory
register() {
79 public GenericURLStreamHandlerFactory run() {
81 final GenericURLStreamHandlerFactory f =
new GenericURLStreamHandlerFactory();
83 URL.setURLStreamHandlerFactory(f);
85 }
catch (
final Throwable e) {
86 System.err.println(
"GenericURLStreamHandlerFactory: Setting URLStreamHandlerFactory failed: "+e.getMessage());
static synchronized GenericURLStreamHandlerFactory register()
Returns the singleton instance of the registered GenericURLStreamHandlerFactory or null if registrati...
synchronized final URLStreamHandler setHandler(final String protocol, final URLStreamHandler handler)
Sets the handler for protocol.
synchronized final URLStreamHandler getHandler(final String protocol)
Returns the protocol handler previously set via setHandler(String, URLStreamHandler),...
synchronized final URLStreamHandler createURLStreamHandler(final String protocol)
static< T > T doPrivileged(final PrivilegedAction< T > o)
Call wrapper for java.security.AccessController#doPrivileged(PrivilegedAction).