| com.jofti.api.IndexManager
All known Subclasses: com.jofti.manager.IndexManagerImpl,
IndexManager | public interface IndexManager (Code) | | The manager is responsible for providing access to indexes. This class is not a singleton
and is not intended to be used in that manner.
The usage for the IndexCache manager is either to retrieve an indexed cache that has been configured via a configuration file:
e.g.
IndexManager manager = new IndexManagerImpl();
manager.setConfigFile("configFile");
manager.init();
Index index = manager.getIndexCache("name");
or:
IndexManager manager = new IndexManagerImpl();
manager.init(inputStream);
IndexCache index = (IndexCache)manager.getIndexCache("name");
or by using one the addIndex methods:
IndexManager manager = new IndexManagerImpl();
manager.init();
IndexCache index = (IndexCache)manager.addIndexCache(indexConfig, "fileName");
or
IndexManager manager = new IndexManagerImpl();
manager.init();
Index index = manager.addIndex(indexConfig, cacheImpl);
The recommended usage for pre-existing Caches is to use the addIndex method and use a
Listener adapter so all Index updates are managed using the listener callback methods.
NameSpaced caches such as JBossCache are obtained using:
IndexManager manager = new IndexManagerImpl();
manager.init(configFile);
NameSpacedIndex index = manager.getNameSpacedIndex("name");
author: Steve Woodcock
version: 1.10 |
Method Summary | |
abstract public Index | addIndex(IndexConfig config, Object cache, String classesFileName) This method allows cache instances to be added to the manager
programatically rather than at start-up. | public Index | addIndex(IndexConfig config, Object cache, InputStream stream) This method allows cache instances to be added to the manager
programatically rather than at start-up.
Any type of cache can be added in this manner, providing a CacheAdapter
exists for it and the correct adapter has been configured in the
IndexConfig class. Note: The cache implementations must be started correctly before they arepassed into this method. | abstract public Index | addIndex(IndexConfig config, Object cache) This method allows cache instances to be added to the manager
programatically rather than at start-up. | abstract public Index | addIndexCache(IndexConfig config, String classesFileName) This method allows cache instances to be added to the manager
programatically rather than at start-up. | abstract public Index | addIndexCache(IndexConfig config) This method allows cache instances to be added to the manager
programatically rather than at start-up.
Any type of cache can be added in this manner, providing a CacheAdapter
exists for it and the correct adapter has been configured in the
IndexConfig class. | abstract public void | destroy() Used to shutdown and remove all indexed caches from the manager. | abstract public void | destroyIndex(Object cache) Used to shutdown and remove an indexed cache from the manager. | abstract public Index | getIndexCache(String indexName) Retrieves an indexed cache from the manager. | abstract public NameSpacedIndex | getNameSpacedIndex(String indexName) Retrieves a name spaced indexed cache from the manager. | abstract public void | init(String configFileName) Initialisation method that takes a config file name. | abstract public void | init() Initialisation method that takes no parameters. | abstract public void | init(InputStream configStream) Initialise method that takes an inputstream. | abstract public Object | removeIndex(Object cache) Used to only remove an indexed cache from the manager and return the cache instance. | abstract public void | setConfigFile(String configFile) Sets a config file to use in the Manager. |
addIndex | abstract public Index addIndex(IndexConfig config, Object cache, String classesFileName) throws JoftiException(Code) | | This method allows cache instances to be added to the manager
programatically rather than at start-up. The usage is for example:
DefaultIndexConfig config = new DefaultIndexConfig();
config.setName("test");
Index index = manager.addIndex(config, cacheImpl,
xml-filename-with-classes-in-it);
any type of cache can be added in this manner, providing a CacheAdapter
exists for it and the correct adapter has been configured in the
IndexConfig class. If you are using a nameSpaced cache like JBossCache then the usage wouldbe: DefaultIndexConfig config = new DefaultIndexConfig(); config.setName("test"); NameSpacedIndex index = (NameSpacedIndex)manager.addIndex(config, cacheImpl, xml-filename-with-classes-in-it); Note: The cache implementations must be started correctly before they arepassed into this method. Added caches are assumed to have been startedand the manager will NOT attempt to initialise the actual cacheimplementation. Parameters: config - -the config class containing definitions of the adapter, indextype and parser to use.
Parameters: cache - -the cache implementation.
Parameters: classesFileName - -the xml file containing the classes definitions for the cache.This file must be available on the classpath. The added cache.
throws: JoftiException - an exception detailing a failure to initialise the cache. |
addIndex | public Index addIndex(IndexConfig config, Object cache, InputStream stream) throws JoftiException(Code) | | This method allows cache instances to be added to the manager
programatically rather than at start-up.
Any type of cache can be added in this manner, providing a CacheAdapter
exists for it and the correct adapter has been configured in the
IndexConfig class. Note: The cache implementations must be started correctly before they arepassed into this method. Added caches are assumed to have been startedand the manager will NOT attempt to initialise the actual cacheimplementation. Parameters: config - -the config class containing definitions of the adapter, indextype and parser to use.
Parameters: cache - -the cache implementation.
Parameters: stream - -the inputstream containing the classes definitions for thecache loaded from the config xml file. The added Index.
throws: JoftiException - an exception detailing a failure to initialise the cache. |
addIndex | abstract public Index addIndex(IndexConfig config, Object cache) throws JoftiException(Code) | | This method allows cache instances to be added to the manager
programatically rather than at start-up. The usage is for example:
DefaultIndexConfig config = new DefaultIndexConfig();
config.setName("test");
Index index = manager.addIndex(config, cacheImpl,
xml-filename-with-classes-in-it);
any type of cache can be added in this manner, providing a CacheAdapter
exists for it and the correct adapter has been configured in the
IndexConfig class. If you are using a nameSpaced cache like JBossCache then the usage wouldbe: DefaultIndexConfig config = new DefaultIndexConfig(); config.setName("test"); NameSpacedIndex index = (NameSpacedIndex)manager.addIndexedCache(config, cacheImpl); Note: The cache implementations must be started correctly before they arepassed into this method. Added caches are assumed to have been startedand the manager will NOT attempt to initialise the actual cacheimplementation. Parameters: config - -the config class containing definitions of the adapter, indextype and parser to use.
Parameters: cache - -the cache implementation. The added cache.
throws: JoftiException - an exception detailing a failure to initialise the cache.
|
addIndexCache | abstract public Index addIndexCache(IndexConfig config, String classesFileName) throws JoftiException(Code) | | This method allows cache instances to be added to the manager
programatically rather than at start-up.
Any type of cache can be added in this manner, providing a CacheAdapter
exists for it and the correct adapter has been configured in the
IndexConfig class. Note: This method is the equivalent of an index entry in theconfiguration file. The manager will atttempt to construct and initialisea new indexed cache based on the attributes in the IndexConfig class andthe class definition file. This method cannot be used with Listener type adapters and an attempt to do so will thow an exception. Parameters: config - -the config class containing definitions of the adapter, indextype and parser to use.
Parameters: classesFileName - -the xml file containing the classes definitions for thecache. This file must be available on the classpath. The added cache.
throws: JoftiException - an exception detailing a failure to initialise the cache.
|
addIndexCache | abstract public Index addIndexCache(IndexConfig config) throws JoftiException(Code) | | This method allows cache instances to be added to the manager
programatically rather than at start-up.
Any type of cache can be added in this manner, providing a CacheAdapter
exists for it and the correct adapter has been configured in the
IndexConfig class. This method will result in theadapter used creating a new instance of its cache type. Note: This method is the equivalent of an index entry in theconfiguration file. The manager will atttempt to construct and initialisea new indexed cache based solely on the attributes in the IndexConfigclass. This method cannot be used with Listener type adapters and an attempt to do so will thow an exception. Class definitions can be added using attribute classMappings in theIndexConfig class. See this class for details on how to configure these. Parameters: config - -the config class containing definitions of the adapter, indextype and parser to use. The added Index. throws: JoftiException - an exception detailing a failure to initialise the cache.
|
destroy | abstract public void destroy()(Code) | | Used to shutdown and remove all indexed caches from the manager. You should always use this method
to stop the manager - as some cache implementations explicitly require a
shutdown phase to be run before they can be removed.
|
destroyIndex | abstract public void destroyIndex(Object cache)(Code) | | Used to shutdown and remove an indexed cache from the manager. You should use this method
to remove an indexed cache from the manager and shutdown the cache instance- as some cache implementations explicitly require a
shutdown phase to be run before they can be removed.
Parameters: cache - - the cache to be destroyed. |
getIndexCache | abstract public Index getIndexCache(String indexName) throws JoftiException(Code) | | Retrieves an indexed cache from the manager. If the cache does not exist in the manager the
method returns NULL, rather than throw an exception.
Attempting to retrieve a name spaced indexed cache using this method will result in an
exception.
Use this method for Map, EHCache and OSCache types.
Parameters: indexName - - the key name to retrive the indexed cache. This set in the config as the Name. - the cache or NULL if no cache can be found under that name.
throws: JoftiException - an exception detailing a failure to retrieve the indexed cache. |
getNameSpacedIndex | abstract public NameSpacedIndex getNameSpacedIndex(String indexName) throws JoftiException(Code) | | Retrieves a name spaced indexed cache from the manager. If the index does not exist in the manager the
method returns NULL, rather than throw an exception.
Use this method for JBossCache
Attempting to retrieve a non-name spaced indexed cache using this method will result in an
exception.
Parameters: indexName - - the key name to retrive the indexed cache. This set in the config as the Name. - the cache or NULL if no cache can be found under that name.
throws: JoftiException - an exception detailing a failure to retrieve the indexed cache. |
init | abstract public void init(String configFileName) throws JoftiException(Code) | | Initialisation method that takes a config file name. This over-rides the
fileName (if any) set in the setConfigFile() method.This method (or one of the other init
methods) must be called BEFORE any other method is called on the manager.
Parameters: configFileName - - the filename containing the config - relative to the classpath. throws: JoftiException - - an exception detailing a failure to initialise the cache. |
init | abstract public void init() throws JoftiException(Code) | | Initialisation method that takes no parameters. This configures the cache with the
fileName set in the setConfigFile() method. This method (or one of the other init
methods) must be called BEFORE any other method is called on the manager.
throws: JoftiException - - an exception detailing a failure to initialise the cache. |
init | abstract public void init(InputStream configStream) throws JoftiException(Code) | | Initialise method that takes an inputstream. This over-rides the fileName
(if any) set in the setConfigFile() method.This method (or one of the other init
methods must be called BEFORE any other method is called on the manager.
Parameters: configStream - a stream containing the loaded file. throws: JoftiException - - an exception detailing a failure to initialise the cache. |
removeIndex | abstract public Object removeIndex(Object cache)(Code) | | Used to only remove an indexed cache from the manager and return the cache instance. You should use this method
when you want to remive the index but keep the cache. This is the opposite of the addIndex method.
Once this method has been called the index becomes unusable and behaviour if you retain a reference is indeterminate.
Parameters: cache - - the cache to be removed. |
setConfigFile | abstract public void setConfigFile(String configFile)(Code) | | Sets a config file to use in the Manager. This file must be on the
classpath.
Parameters: configFile - - the filename containing the config - relative to the classpath. |
|
|