org.compass.core.impl
Class DefaultCompass

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

public class DefaultCompass
extends Object
implements InternalCompass

Author:
kimchy
See Also:
Serialized Form

Field Summary
protected  CompassSettings settings
           
 
Constructor Summary
DefaultCompass(CompassMapping mapping, ConverterLookup converterLookup, CompassMetaData compassMetaData, PropertyNamingStrategy propertyNamingStrategy, CompassSettings settings, LuceneSearchEngineFactory searchEngineFactory)
           
DefaultCompass(CompassMapping mapping, ConverterLookup converterLookup, CompassMetaData compassMetaData, PropertyNamingStrategy propertyNamingStrategy, ExecutorManager executorManager, CompassSettings settings)
           
DefaultCompass(CompassMapping mapping, ConverterLookup converterLookup, CompassMetaData compassMetaData, PropertyNamingStrategy propertyNamingStrategy, ExecutorManager executorManager, CompassSettings settings, boolean duplicate)
           
DefaultCompass(CompassMapping mapping, ConverterLookup converterLookup, CompassMetaData compassMetaData, PropertyNamingStrategy propertyNamingStrategy, ExecutorManager executorManager, CompassSettings settings, boolean duplicate, LuceneSearchEngineFactory searchEngineFactory)
           
 
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.
protected  void finalize()
           
 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
 CompassSession openSession()
          If there is a transaction bound session, will return it.
 CompassSession openSession(boolean allowCreate)
           
 CompassSession openSession(boolean allowCreate, boolean checkClosed)
           
 void rebuild()
          Rebuilds Compass.
 void removeRebuildEventListener(RebuildEventListener eventListener)
           
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

settings

protected CompassSettings settings
Constructor Detail

DefaultCompass

public DefaultCompass(CompassMapping mapping,
                      ConverterLookup converterLookup,
                      CompassMetaData compassMetaData,
                      PropertyNamingStrategy propertyNamingStrategy,
                      ExecutorManager executorManager,
                      CompassSettings settings)
               throws CompassException
Throws:
CompassException

DefaultCompass

public DefaultCompass(CompassMapping mapping,
                      ConverterLookup converterLookup,
                      CompassMetaData compassMetaData,
                      PropertyNamingStrategy propertyNamingStrategy,
                      ExecutorManager executorManager,
                      CompassSettings settings,
                      boolean duplicate)
               throws CompassException
Throws:
CompassException

DefaultCompass

public DefaultCompass(CompassMapping mapping,
                      ConverterLookup converterLookup,
                      CompassMetaData compassMetaData,
                      PropertyNamingStrategy propertyNamingStrategy,
                      CompassSettings settings,
                      LuceneSearchEngineFactory searchEngineFactory)
               throws CompassException
Throws:
CompassException

DefaultCompass

public DefaultCompass(CompassMapping mapping,
                      ConverterLookup converterLookup,
                      CompassMetaData compassMetaData,
                      PropertyNamingStrategy propertyNamingStrategy,
                      ExecutorManager executorManager,
                      CompassSettings settings,
                      boolean duplicate,
                      LuceneSearchEngineFactory searchEngineFactory)
               throws CompassException
Throws:
CompassException
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()
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

addRebuildEventListener

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

removeRebuildEventListener

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

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.

getName

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

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

getMapping

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

getExecutorManager

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

getEventManager

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

openSession

public CompassSession openSession()
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

openSession

public CompassSession openSession(boolean allowCreate)

openSession

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

start

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

stop

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

close

public void close()
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

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

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

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

getSearchEngineFactory

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

getMetaData

public CompassMetaData getMetaData()
Specified by:
getMetaData 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

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable


Copyright (c) 2004-2008 The Compass Project.