org.tm4j.topicmap.index
Class ConfigurableIndexProvider

java.lang.Object
  extended byorg.tm4j.topicmap.index.ConfigurableIndexProvider
All Implemented Interfaces:
IndexProvider

public abstract class ConfigurableIndexProvider
extends java.lang.Object
implements IndexProvider

An abstract implementation of an IndexProvider that provides access to one or more topic map indexes which require configuration information to be correctly initialised.

The lifecycle for a ConfigurableIndexProvider is as follows:

  1. Application creates new ConfigurableIndexProvider instance, optionally specifying the index configuration properties for the indexes.
  2. Application registers ConfigurableIndexProvider instance with the IndexManager
  3. IndexManager invokes the initialise() method of the ConfigurableIndexProvider passing the TopicMap being indexed as a parameter.
  4. Since:
    0.9.0
    Author:
    Kal

    Constructor Summary
    ConfigurableIndexProvider()
              Create a new ConfigurableIndexProvider instance with no index configuration properties set.
    ConfigurableIndexProvider(java.util.Properties p)
              Create a new ConfigurableIndexProvider instance with the index configuration properties contained in p.
     
    Method Summary
     Index getIndex(java.lang.String interfaceName)
              Returns the index named interfaceName.
     void initialise(TopicMap tm)
              The initialisation hook called by the IndexManager that manages this provider.
    abstract  Index newIndex(java.lang.String interfaceName, TopicMap tm)
              SPI for the ConfigurableIndexProvider class.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     
    Methods inherited from interface org.tm4j.topicmap.index.IndexProvider
    getIndexMeta, getIndexNames
     

    Constructor Detail

    ConfigurableIndexProvider

    public ConfigurableIndexProvider()
    Create a new ConfigurableIndexProvider instance with no index configuration properties set.


    ConfigurableIndexProvider

    public ConfigurableIndexProvider(java.util.Properties p)
    Create a new ConfigurableIndexProvider instance with the index configuration properties contained in p.

    Parameters:
    p - the index configuration properties to be passed to indexes provided by this provider.
    Method Detail

    initialise

    public void initialise(TopicMap tm)
                    throws IndexProviderException
    The initialisation hook called by the IndexManager that manages this provider. When this method is invoked, each of the indexes provided by this provider will be initialised the properties configured for the provider.

    Specified by:
    initialise in interface IndexProvider
    Parameters:
    tm - The topic map which this IndexManager will be handling indexes for
    Throws:
    IndexProviderException - If an error prevents initialisation.

    getIndex

    public final Index getIndex(java.lang.String interfaceName)
                         throws UnsupportedIndexException,
                                IndexProviderException
    Returns the index named interfaceName. If this interface has not been previously configured and it implements the ConfigurableIndex interface, then the configure() method of that interface will be invoked before returning the Index to the caller.

    Specified by:
    getIndex in interface IndexProvider
    Parameters:
    interfaceName - the name of the index to return.
    Returns:
    The Index object which implements the named interface
    Throws:
    UnsupportedIndexException - if no index with the specified name is provided by this IndexProvider.
    IndexProviderException - if the index instance cannot be initialised for some reason or if some configuration properties required by the index are invalid or not present.

    newIndex

    public abstract Index newIndex(java.lang.String interfaceName,
                                   TopicMap tm)
                            throws UnsupportedIndexException
    SPI for the ConfigurableIndexProvider class. Concrete implementations of this class must implement this method to return a new instance of the index which implements the interface with the name interfaceName. The ConfigurableIndexProvider class will handle the caching of instances.

    Parameters:
    interfaceName - the name of the interface that the new index instance must implement.
    tm - the TopicMap to be indexed by the new instance
    Returns:
    a new instance of the index which implements the specified interface.
    Throws:
    UnsupportedIndexException