org.apache.slide.store
Class DefaultIndexer

java.lang.Object
  extended byorg.apache.commons.transaction.util.xa.AbstractXAResource
      extended byorg.apache.slide.common.AbstractXAServiceBase
          extended byorg.apache.slide.common.XAServiceBase
              extended byorg.apache.slide.store.DefaultIndexer
All Implemented Interfaces:
IBasicExpressionFactoryProvider, Indexer, IndexStore, Service, javax.transaction.Status, javax.transaction.xa.XAResource

public class DefaultIndexer
extends XAServiceBase
implements IndexStore

DefaultIndexer is loaded, when no Indexer was explicitly configured for a store (content or properties). Initilializes with the store specific indexer if store implements IBasicExpressionFactoryProvider, else with null, which means, no search possible on store (unless generic search). Fakes two phase commit.

Version:
$Revision: 1.5 $

Nested Class Summary
 
Nested classes inherited from class org.apache.slide.common.XAServiceBase
XAServiceBase.DummyTxResource
 
Field Summary
 
Fields inherited from class org.apache.slide.common.AbstractXAServiceBase
LOG_CHANNEL, loggerFacade, namespace, scope
 
Fields inherited from interface javax.transaction.xa.XAResource
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY
 
Fields inherited from interface javax.transaction.Status
STATUS_ACTIVE, STATUS_COMMITTED, STATUS_COMMITTING, STATUS_MARKED_ROLLBACK, STATUS_NO_TRANSACTION, STATUS_PREPARED, STATUS_PREPARING, STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, STATUS_UNKNOWN
 
Constructor Summary
DefaultIndexer(java.lang.Object associatedStore)
          Uses the ExpressionFactory of associated store (if applicable)
 
Method Summary
 void connect()
          Connects to the underlying data source (if any is needed).
 void createIndex(Uri uri, NodeRevisionDescriptor revisionDescriptor, NodeRevisionContent revisionContent)
          Index an object content.
 void disconnect()
          Disconnects from the underlying data source.
 void dropIndex(Uri uri, NodeRevisionNumber number)
          Drop an object revision from the index.
 IBasicExpressionFactory getBasicExpressionFactory()
          As defined in IBasicExpressionFactoryProvider
 boolean isConnected()
          This function tells whether or not the service is connected.
 void reset()
          Deletes service underlying data source, if possible (and meaningful).
 void setParameters(java.util.Hashtable parameters)
          Initializes the service with a set of parameters.
 void updateIndex(Uri uri, NodeRevisionDescriptor revisionDescriptor, NodeRevisionContent revisionContent)
          updates an index for a resource
 
Methods inherited from class org.apache.slide.common.XAServiceBase
createTransactionResource, getTransactionTimeout, includeBranchInXid, isSameRM, recover, setTransactionTimeout
 
Methods inherited from class org.apache.slide.common.AbstractXAServiceBase
cacheResults, connect, connectIfNeeded, connectIfNeeded, getLogger, getLoggerFacade, initialize, setNamespace, setScope
 
Methods inherited from class org.apache.commons.transaction.util.xa.AbstractXAResource
addAcitveTransactionalResource, addSuspendedTransactionalResource, commit, end, forget, getActiveTransactionalResource, getCurrentlyActiveTransactionalResource, getSuspendedTransactionalResource, getTransactionalResource, prepare, removeActiveTransactionalResource, removeSuspendedTransactionalResource, rollback, setCurrentlyActiveTransactionalResource, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.slide.common.Service
cacheResults, connect, connectIfNeeded, connectIfNeeded, getLogger, initialize, setNamespace, setScope
 
Methods inherited from interface javax.transaction.xa.XAResource
commit, end, forget, getTransactionTimeout, isSameRM, prepare, recover, rollback, setTransactionTimeout, start
 

Constructor Detail

DefaultIndexer

public DefaultIndexer(java.lang.Object associatedStore)
Uses the ExpressionFactory of associated store (if applicable)

Parameters:
associatedStore - a properties- or content store
Method Detail

getBasicExpressionFactory

public IBasicExpressionFactory getBasicExpressionFactory()
As defined in IBasicExpressionFactoryProvider

Specified by:
getBasicExpressionFactory in interface IBasicExpressionFactoryProvider
Returns:
an IBasicExpressionFactory

createIndex

public void createIndex(Uri uri,
                        NodeRevisionDescriptor revisionDescriptor,
                        NodeRevisionContent revisionContent)
                 throws IndexException
Index an object content. Do nothing.

Specified by:
createIndex in interface Indexer
Parameters:
uri - Uri
revisionContent - the content of the resource
Throws:
IndexException - Error accessing the Data Source

updateIndex

public void updateIndex(Uri uri,
                        NodeRevisionDescriptor revisionDescriptor,
                        NodeRevisionContent revisionContent)
                 throws IndexException
updates an index for a resource

Specified by:
updateIndex in interface Indexer
Parameters:
uri - uri of the resource
revisionContent - the content of the resource
Throws:
IndexException

dropIndex

public void dropIndex(Uri uri,
                      NodeRevisionNumber number)
               throws IndexException
Drop an object revision from the index. Do nothing

Specified by:
dropIndex in interface Indexer
Parameters:
uri - Uri
number - nodeRevisionNumber of the resource
Throws:
IndexException - Error accessing the Data Source

connect

public void connect()
             throws ServiceConnectionFailedException
Connects to the underlying data source (if any is needed).

Specified by:
connect in interface Service
Overrides:
connect in class XAServiceBase
Throws:
ServiceConnectionFailedException - Connection failed

isConnected

public boolean isConnected()
                    throws ServiceAccessException
This function tells whether or not the service is connected.

Specified by:
isConnected in interface Service
Overrides:
isConnected in class XAServiceBase
Returns:
boolean true if we are connected
Throws:
ServiceAccessException - Service access error

setParameters

public void setParameters(java.util.Hashtable parameters)
                   throws ServiceParameterErrorException,
                          ServiceParameterMissingException
Initializes the service with a set of parameters. Those could be :
  • User name, login info
  • Host name on which to connect
  • Remote port
  • JDBC driver whoich is to be used :-)
  • Anything else ...

    Specified by:
    setParameters in interface Service
    Overrides:
    setParameters in class XAServiceBase
    Parameters:
    parameters - Hashtable containing the parameters' names and associated values
    Throws:
    ServiceParameterErrorException - Incorrect service parameter
    ServiceParameterMissingException - Service parameter missing

  • disconnect

    public void disconnect()
                    throws ServiceDisconnectionFailedException
    Disconnects from the underlying data source.

    Specified by:
    disconnect in interface Service
    Overrides:
    disconnect in class XAServiceBase
    Throws:
    ServiceDisconnectionFailedException - Disconnection failed

    reset

    public void reset()
               throws ServiceResetFailedException
    Deletes service underlying data source, if possible (and meaningful).

    Specified by:
    reset in interface Service
    Overrides:
    reset in class XAServiceBase
    Throws:
    ServiceResetFailedException - Reset failed