org.compass.core
Interface CompassSession

All Superinterfaces:
CompassOperations
All Known Subinterfaces:
InternalCompassSession
All Known Implementing Classes:
DefaultCompassSession

public interface CompassSession
extends CompassOperations

The main interface between a Java application and Compass.

Provides the basic operations with semantic mapped objects (save, delete, and load/get). The session provides operations on both the objects levels and Resource levels (indexed object model). The CompassSession operations are delegated to the underlying SearchEngine, so no direct access to the SearchEngine is needed.

Implementations will not be thread safe, Instead each thread/transaction should obtain its own instance from a Compass.

If the CompassSession throws an exception, the transaction must be rolled back and the session discarded. The internal state of the CompassSession might not be consistent with the search engine if discarded.

Please see the CompassTemplate class for easier programmatic control using the template design pattern.

Author:
kimchy
See Also:
Resource, Compass

Method Summary
 CompassAnalyzerHelper analyzerHelper()
          Returns an Analyzer helper.
 CompassTransaction beginLocalTransaction()
          Begins a unit of work using a Compass local transaction.
 CompassTransaction beginTransaction()
          Begin a unit of work and return the associated CompassTranscation object.
 CompassTransaction beginTransaction(CompassTransaction.TransactionIsolation transactionIsolation)
          Begin a unit of work and return the associated CompassTranscation object.
 void close()
          Closes the CompassSession.
 CompassSettings getSettings()
          Runtimes settings that apply on the session level.
 boolean isClosed()
          Returns true if the session is closed.
 CompassQueryBuilder queryBuilder()
          Creats a new query builder, used to build queries programmatically.
 CompassQueryFilterBuilder queryFilterBuilder()
          Creats a new query filter builder, used to build filters of queries programmatically.
 ResourceFactory resourceFactory()
          Returns a resource factory allowing to create resources and properties.
 CompassTermFreqsBuilder termFreqsBuilder(String... names)
          Creates a new terms frequencies builder used to get terms names and freqs for a list of property names.
 
Methods inherited from interface org.compass.core.CompassOperations
create, create, delete, delete, delete, delete, delete, delete, delete, evict, evict, evict, evictAll, find, get, get, get, get, getResource, getResource, getResource, getResource, load, load, load, load, loadResource, loadResource, loadResource, loadResource, save, save
 

Method Detail

resourceFactory

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


getSettings

CompassSettings getSettings()
Runtimes settings that apply on the session level.

Returns:
Runtime settings applies on the session level
See Also:
RuntimeCompassEnvironment, RuntimeLuceneEnvironment

beginTransaction

CompassTransaction beginTransaction()
                                    throws CompassException
Begin a unit of work and return the associated CompassTranscation object. If a new underlying transaction is required, begin the transaction. Otherwise continue the new work in the context of the existing underlying transaction. The class of the returned CompassTransaction object is determined by the property compass.transaction.factory.

Returns:
a CompassTransaction instance
Throws:
CompassException
See Also:
CompassTransaction

beginTransaction

CompassTransaction beginTransaction(CompassTransaction.TransactionIsolation transactionIsolation)
                                    throws CompassException
Begin a unit of work and return the associated CompassTranscation object. If a new underlying transaction is required, begin the transaction. Otherwise continue the new work in the context of the existing underlying transaction. The class of the returned CompassTransaction object is determined by the property compass.transaction.factory.

Also accepts the transcation isolation of the transaction.

Parameters:
transactionIsolation -
Returns:
a CompassTransaction instance
Throws:
CompassException
See Also:
CompassTransaction

beginLocalTransaction

CompassTransaction beginLocalTransaction()
                                         throws CompassException
Begins a unit of work using a Compass local transaction. Very handy when using transaction strategy other than local transaction factory but still wish to use a local one for example to perform serach (which will be faster as it won't start and externa transaction).

Throws:
CompassException

queryBuilder

CompassQueryBuilder queryBuilder()
                                 throws CompassException
Creats a new query builder, used to build queries programmatically.

Returns:
The query builder.
Throws:
CompassException

queryFilterBuilder

CompassQueryFilterBuilder queryFilterBuilder()
                                             throws CompassException
Creats a new query filter builder, used to build filters of queries programmatically.

Returns:
The query filter builder.
Throws:
CompassException

termFreqsBuilder

CompassTermFreqsBuilder termFreqsBuilder(String... names)
                                         throws CompassException
Creates a new terms frequencies builder used to get terms names and freqs for a list of property names.

Note, term frequencies are updated to reflect latest changes to the index only after an optimization as take place (note, calling optimize might not cause optimization).

Parameters:
names - The property names
Returns:
A term freqs builder
Throws:
CompassException

analyzerHelper

CompassAnalyzerHelper analyzerHelper()
                                     throws CompassException
Returns an Analyzer helper. Can be used to help analyze given texts.

Returns:
the analyzer helper
Throws:
CompassException

close

void close()
           throws CompassException
Closes the CompassSession. Note, if this session is "contained" within another session, it won't actually be closed, and defer closing the session to the other session.

Throws:
CompassException
See Also:
Compass.openSession()

isClosed

boolean isClosed()
Returns true if the session is closed. Note, if this session "joined" another session, it won't actually be closed, and defer closing the session to the outer session.



Copyright (c) 2004-2008 The Compass Project.