dsto.dfc.net
Class DfcStreamHandlerFactory

java.lang.Object
  extended by dsto.dfc.net.DfcStreamHandlerFactory
All Implemented Interfaces:
URLStreamHandlerFactory

public class DfcStreamHandlerFactory
extends Object
implements URLStreamHandlerFactory

Generic implementation of URLStreamHandlerFactory that supports dynamic registration of protocol handlers.

Version:
$Revision$
Author:
Matthew Phillips

Method Summary
 URLStreamHandler createURLStreamHandler(String protocol)
           
static DfcStreamHandlerFactory getInstance()
          Get the singleton instance of this class.
protected static void maybeRegisterFactory()
          Register the singleton instance of this class as the system-wide URL handler factory.
 void registerHandler(String protocol, URLStreamHandler handler)
          Register a handler for a given protocol.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static DfcStreamHandlerFactory getInstance()
Get the singleton instance of this class.


registerHandler

public void registerHandler(String protocol,
                            URLStreamHandler handler)
                     throws UnsupportedOperationException
Register a handler for a given protocol.

Parameters:
protocol - The protocol to handle (ie the "xxx:" part of the URL).
handler - The instance that will be returned as the handler for the protocol.
Throws:
UnsupportedOperationException - if registration fails (probably because something else has already registered itself as a handler factory).

createURLStreamHandler

public URLStreamHandler createURLStreamHandler(String protocol)
Specified by:
createURLStreamHandler in interface URLStreamHandlerFactory

maybeRegisterFactory

protected static void maybeRegisterFactory()
                                    throws UnsupportedOperationException
Register the singleton instance of this class as the system-wide URL handler factory.

Throws:
UnsupportedOperationException - if another factory is already registered.


Copyright © 2008 Commonwealth of Australia