org.compass.core.impl
Class RefreshableCompass

java.lang.Object
  extended by org.compass.core.impl.RefreshableCompass
All Implemented Interfaces:
Serializable, Referenceable, Compass, InternalCompass

public class RefreshableCompass
extends Object
implements InternalCompass

A wrapper around an actual implemenation of Compass that allows to rebuild it after changes that are perfomed on the getConfig() configuration.

Author:
kimchy
See Also:
Serialized Form

Constructor Summary
RefreshableCompass(CompassConfiguration config, InternalCompass compass)
           
 
Method Summary
 void addRebuildEventListener(RebuildEventListener eventListener)
           
 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.
 ConverterLookup getConverterLookup()
           
 CompassEventManager getEventManager()
           
 ExecutorManager getExecutorManager()
           
 LocalTransactionFactory getLocalTransactionFactory()
           
 CompassMapping getMapping()
           
 CompassMetaData getMetaData()
           
 String getName()
           
 PropertyNamingStrategy getPropertyNamingStrategy()
           
 Reference getReference()
           
 ResourceFactory getResourceFactory()
          Returns a resource factory allowing to create resources and properties.
 SearchEngineFactory getSearchEngineFactory()
           
 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.
 TransactionFactory getTransactionFactory()
           
 boolean isClosed()
          Returns true if the Compass instance is already closed
 CompassIndexSession openIndexSession()
          If there is a transaction bound session, will return it.
 CompassSearchSession openSearchSession()
          If there is a transaction bound session, will return it.
 CompassSession openSession()
          If there is a transaction bound session, will return it.
 CompassSession openSession(boolean allowCreate, boolean checkClosed)
           
 CompassQueryBuilder queryBuilder()
          Creats a new query builder, used to build queries programmatically.
 CompassQueryFilterBuilder queryFilterBuilder()
          Creates a new query filter builder that can create CompassQueryFilters that can later be added to CompassQuery.setFilter(CompassQueryFilter).
 void rebuild()
          Rebuilds Compass.
 void removeRebuildEventListener(RebuildEventListener eventListener)
           
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RefreshableCompass

public RefreshableCompass(CompassConfiguration config,
                          InternalCompass compass)
Method Detail

getConfig

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

Specified by:
getConfig in interface Compass

rebuild

public void rebuild()
             throws CompassException
Description copied from interface: Compass
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.

Specified by:
rebuild in interface Compass
Throws:
CompassException

clone

public Compass clone(CompassSettings addedSettings)
Description copied from interface: Compass
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.

Specified by:
clone in interface Compass
Parameters:
addedSettings - The settings to be added.
Returns:
the cloned compass instance.

addRebuildEventListener

public void addRebuildEventListener(RebuildEventListener eventListener)
Specified by:
addRebuildEventListener in interface InternalCompass

removeRebuildEventListener

public void removeRebuildEventListener(RebuildEventListener eventListener)
Specified by:
removeRebuildEventListener in interface InternalCompass

start

public void start()
Specified by:
start in interface InternalCompass

stop

public void stop()
Specified by:
stop in interface InternalCompass

openSession

public CompassSession openSession(boolean allowCreate,
                                  boolean checkClosed)
Specified by:
openSession in interface InternalCompass

openSession

public CompassSession openSession()
                           throws CompassException
Description copied from interface: Compass
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.

Specified by:
openSession in interface Compass
Returns:
CompassSession The compass session
Throws:
CompassException

openSearchSession

public CompassSearchSession openSearchSession()
                                       throws CompassException
Description copied from interface: Compass
If there is a transaction bound session, will return it. Otherwise returns a new search 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.

Specified by:
openSearchSession in interface Compass
Returns:
CompassSession The compass session
Throws:
CompassException

openIndexSession

public CompassIndexSession openIndexSession()
                                     throws CompassException
Description copied from interface: Compass
If there is a transaction bound session, will return it. Otherwise returns a new index 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.

Specified by:
openIndexSession in interface Compass
Returns:
CompassSession The compass session
Throws:
CompassException

getName

public String getName()
Specified by:
getName in interface InternalCompass

getSettings

public CompassSettings getSettings()
Description copied from interface: Compass
Returns the settings Compass was started with.

Specified by:
getSettings in interface Compass
Specified by:
getSettings in interface InternalCompass

getMapping

public CompassMapping getMapping()
Specified by:
getMapping in interface InternalCompass

getExecutorManager

public ExecutorManager getExecutorManager()
Specified by:
getExecutorManager in interface InternalCompass

getMetaData

public CompassMetaData getMetaData()
Specified by:
getMetaData in interface InternalCompass

getSearchEngineFactory

public SearchEngineFactory getSearchEngineFactory()
Specified by:
getSearchEngineFactory in interface InternalCompass

getTransactionFactory

public TransactionFactory getTransactionFactory()
Specified by:
getTransactionFactory in interface InternalCompass

getLocalTransactionFactory

public LocalTransactionFactory getLocalTransactionFactory()
Specified by:
getLocalTransactionFactory in interface InternalCompass

getConverterLookup

public ConverterLookup getConverterLookup()
Specified by:
getConverterLookup in interface InternalCompass

getPropertyNamingStrategy

public PropertyNamingStrategy getPropertyNamingStrategy()
Specified by:
getPropertyNamingStrategy in interface InternalCompass

getEventManager

public CompassEventManager getEventManager()
Specified by:
getEventManager in interface InternalCompass

close

public void close()
           throws CompassException
Description copied from interface: Compass
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.

Specified by:
close in interface Compass
Throws:
CompassException

queryBuilder

public CompassQueryBuilder queryBuilder()
                                 throws CompassException
Description copied from interface: Compass
Creats a new query builder, used to build queries programmatically.

Specified by:
queryBuilder in interface Compass
Returns:
The query builder.
Throws:
CompassException

queryFilterBuilder

public CompassQueryFilterBuilder queryFilterBuilder()
                                             throws CompassException
Description copied from interface: Compass
Creates a new query filter builder that can create CompassQueryFilters that can later be added to CompassQuery.setFilter(CompassQueryFilter).

Specified by:
queryFilterBuilder in interface Compass
Throws:
CompassException

getResourceFactory

public ResourceFactory getResourceFactory()
Description copied from interface: Compass
Returns a resource factory allowing to create resources and properties.

Specified by:
getResourceFactory in interface Compass

getSearchEngineOptimizer

public SearchEngineOptimizer getSearchEngineOptimizer()
Description copied from interface: Compass
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.

Specified by:
getSearchEngineOptimizer in interface Compass
Returns:
the search engine optimizer

getSearchEngineIndexManager

public SearchEngineIndexManager getSearchEngineIndexManager()
Description copied from interface: Compass
Return the search engine index manager. You can control the index using it.

Specified by:
getSearchEngineIndexManager in interface Compass
Returns:
the search engine index manager

getSpellCheckManager

public SearchEngineSpellCheckManager getSpellCheckManager()
Description copied from interface: Compass
Returns the spell check manager. Returns null if the spell check is not enabled.

Specified by:
getSpellCheckManager in interface Compass

isClosed

public boolean isClosed()
Description copied from interface: Compass
Returns true if the Compass instance is already closed

Specified by:
isClosed in interface Compass

getReference

public Reference getReference()
                       throws NamingException
Specified by:
getReference in interface Referenceable
Throws:
NamingException


Copyright (c) 2004-2009 The Compass Project.