org.tm4j.net
Class LocatorFactoryBase

java.lang.Object
  extended byorg.tm4j.net.LocatorFactoryBase
All Implemented Interfaces:
LocatorFactory

public abstract class LocatorFactoryBase
extends java.lang.Object
implements LocatorFactory

A basic implementation of the LocatorFactory interface with the createLocator() method implemented.

Author:
Florian G. Haas

Constructor Summary
LocatorFactoryBase()
           
 
Method Summary
 Locator createLocator(java.lang.String notation, java.lang.String address)
          Creates a new locator.
abstract  java.lang.Class getImplementation(java.lang.String notation)
          Retrieves the implementation class associated with the specified notation.
abstract  void registerImplementation(java.lang.String notation, java.lang.Class cls)
          Registers a locator implementation.
 void registerImplementation(java.lang.String notation, java.lang.String className)
          Registers a locator implementation.
abstract  void removeImplementation(java.lang.Class cls)
          Unregisters a locator implementation.
 void removeImplementation(java.lang.String className)
          Unregisters a locator implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocatorFactoryBase

public LocatorFactoryBase()
Method Detail

registerImplementation

public abstract void registerImplementation(java.lang.String notation,
                                            java.lang.Class cls)
Description copied from interface: LocatorFactory
Registers a locator implementation. After the implementation is registered with the factory, a locator using this implementation can be created by invoking LocatorFactory.createLocator(String, String).

Specified by:
registerImplementation in interface LocatorFactory
Parameters:
notation - the notation to be associated with the implementation.
cls - the class that represents the actual locator implementation. This class must implement the Locator interface.

registerImplementation

public void registerImplementation(java.lang.String notation,
                                   java.lang.String className)
                            throws java.lang.ClassNotFoundException
Registers a locator implementation. After the implementation is registered with the factory, a locator using this implementation can be created by invoking createLocator(String, String).

Parameters:
notation - the notation to be associated with the implementation.
className - the fully-qualified name of the class that represents the actual locator implementation. That class must implement the Locator interface.
Throws:
java.lang.ClassNotFoundException - if no class with the specified name could be found.

removeImplementation

public abstract void removeImplementation(java.lang.Class cls)
Description copied from interface: LocatorFactory
Unregisters a locator implementation. After the implementation is registered with the factory, a locator using this implementation can no longer be created by invoking LocatorFactory.createLocator(String, String).

Specified by:
removeImplementation in interface LocatorFactory
Parameters:
cls - the class that represents the locator implementation to be removed. If this class has not yet been registered, it is silently ignored.

removeImplementation

public void removeImplementation(java.lang.String className)
                          throws java.lang.ClassNotFoundException
Unregisters a locator implementation. After the implementation is registered with the factory, a locator using this implementation can no longer be created by invoking createLocator(String, String).

Parameters:
className - the fully-qualified name of the class that represents the locator implementation to be removed. If this class has not yet been registered, it is silently ignored.
Throws:
java.lang.ClassNotFoundException - if no class with the specified name could be found.

getImplementation

public abstract java.lang.Class getImplementation(java.lang.String notation)
                                           throws LocatorFactoryException
Retrieves the implementation class associated with the specified notation.

Parameters:
notation - the notation whose associated implementation class is to be retrieved.
Returns:
The implementation class associated with notation.
Throws:
LocatorFactoryException - If no locator implementation class associated with notation has yet been registered.

createLocator

public Locator createLocator(java.lang.String notation,
                             java.lang.String address)
                      throws LocatorFactoryException
Creates a new locator. In order for the locator to be created correctly, its notation and implementing class must first have been registered with the factory using registerImplementation(String, Class). When creating a locator, this method performs the following steps: Provided subclasses properly override the abstract methods in this base class, this method frees them of having to worry about actual locator creation.

Specified by:
createLocator in interface LocatorFactory
Parameters:
notation - the notation to be associated with the new locator.
address - the address to be associated with the new locator.
Throws:
LocatorFactoryException - If no locator implementation class associated with notation has yet been registered, or an unexpected condition occurred during locator instantiation.