org.compass.core
Interface Compass

All Superinterfaces:
Referenceable, Serializable
All Known Subinterfaces:
InternalCompass
All Known Implementing Classes:
DefaultCompass, RefreshableCompass

public interface Compass
extends Referenceable, Serializable

Creates a CompassSession. Usually an application has a single Compass object. Threads servicing client requests obtain sessions from Compass.

Implementors must be threadsafe.

CompassSessions are immutable. The behaviour of a Compass is controlled by settings supplied at configuration time through CompassConfiguration. These settings are defined on the web site.

Compass also provides operations that are on a higher level than a session, like create/delete operations on index data files and manages the index optimiser lifecycle.

Author:
kimchy
See Also:
CompassSession, CompassConfiguration

Method Summary
 Compass clone(CompassSettings addedSettings)
          Clones the current Compass instance.
 void close()
          Closes Compass and releases any resources that are assoicated with it.
 CompassConfiguration getConfig()
          Allows to get the configuraion object.
 ResourceFactory getResourceFactory()
          Returns a resource factory allowing to create resources and properties.
 SearchEngineIndexManager getSearchEngineIndexManager()
          Return the search engine index manager.
 SearchEngineOptimizer getSearchEngineOptimizer()
          Retruns the search engine optimizer.
 CompassSettings getSettings()
          Returns the settings Compass was started with.
 SearchEngineSpellCheckManager getSpellCheckManager()
          Returns the spell check manager.
 boolean isClosed()
          Returns true if the Compass instance is already closed
 CompassSession openSession()
          If there is a transaction bound session, will return it.
 void rebuild()
          Rebuilds Compass.
 
Methods inherited from interface javax.naming.Referenceable
getReference
 

Method Detail

openSession

CompassSession openSession()
                           throws CompassException
If there is a transaction bound session, will return it. Otherwise returns a new session.

A transactional bound session is bounded to the transaction when calling the CompassSession.beginTransaction() or if Compass tries to automatically join an already running transaction (see next paragraph).

If creating a new session, will try to automatically join an existing outer transaction. An outer transaction might be an already running Compass local transaction, or an external transaciton (JTA or Spring for example). In such cases, there is no need to perform any transaction managment code (begin or commit/rollback transaction) or closing the opened session. Compass will also bind the session to the same transaction if an outer transaction exists. Note, when doing so, the mentioned code will have to always be excuted within an already running transaction.

Returns:
CompassSession The compass session
Throws:
CompassException

close

void close()
           throws CompassException
Closes Compass and releases any resources that are assoicated with it. It is very importnat to close an unused Compass instance since it might hold resources (such as file descriptor when storing the index within the file system) that will not be released otherwise.

Throws:
CompassException

clone

Compass clone(CompassSettings addedSettings)
Clones the current Compass instance. The added settings will merged with the current compass settings, and control the creation of the new Compass.

Note, that the new instance will not be registered with JNDI, as well as not start the optimizer.

Parameters:
addedSettings - The settings to be added.
Returns:
the cloned compass instance.

getResourceFactory

ResourceFactory getResourceFactory()
Returns a resource factory allowing to create resources and properties.


getSearchEngineOptimizer

SearchEngineOptimizer getSearchEngineOptimizer()
Retruns the search engine optimizer. You can controll the state of the optimizer (by calling stop or start), you can check if the index need optimization, and you can optimize the index.

Returns:
the search engine optimizer

getSearchEngineIndexManager

SearchEngineIndexManager getSearchEngineIndexManager()
Return the search engine index manager. You can control the index using it.

Returns:
the search engine index manager

getSpellCheckManager

SearchEngineSpellCheckManager getSpellCheckManager()
Returns the spell check manager. Returns null if the spell check is not enabled.


getSettings

CompassSettings getSettings()
Returns the settings Compass was started with.


isClosed

boolean isClosed()
Returns true if the Compass instance is already closed


getConfig

CompassConfiguration getConfig()
Allows to get the configuraion object. One can add settings, and remove or add mappings. Once changes are done, rebuild() should be called.


rebuild

void rebuild()
Rebuilds Compass. Taking into account any changes done on the configuration object since the current Compass instance was created.

If the rebuild fails, the Compass instance can still work and it will be based on the latest valid Compass instance that was rebuilt.



Copyright (c) 2004-2008 The Compass Project.