org.sakaiproject.search.component.service.impl
Class SearchIndexBuilderImpl

java.lang.Object
  extended byorg.sakaiproject.search.component.service.impl.SearchIndexBuilderImpl
All Implemented Interfaces:
SearchIndexBuilder

public class SearchIndexBuilderImpl
extends Object
implements SearchIndexBuilder

Search index builder is expected to be registered in spring as org.sakaiproject.search.SearchIndexBuilder as a singleton. It receives resources which it adds to its list of pending documents to be indexed. A seperate thread then runs thtough the list of entities to be indexed, updating the index. Each time the index is updates an event is posted to force the Search components that are using the index to reload. Incremental updates to the Lucene index require that the searchers reload the index once the idex writer has been built.

Author:
ieb

Constructor Summary
SearchIndexBuilderImpl()
           
 
Method Summary
 void addResource(Notification notification, Event event)
          Add a resource to the indexing queue Adds a resource to the index builder
 void destroy()
          Close down the entire search infrastructure
 List getContentProducers()
          get all the producers registerd, as a clone to avoid concurrent modification exceptions
 Logger getLogger()
           
 int getPendingDocuments()
          get the number of pending documents
 SearchBuilderItemDao getSearchBuilderItemDao()
           
 SearchIndexBuilderWorker getSearchIndexBuilderWorker()
           
 void init()
           
 boolean isBuildQueueEmpty()
          return true if the queue is empty
protected  EntityContentProducer newEntityContentProducer(Event event)
          get hold of an entity content producer using the event
protected  EntityContentProducer newEntityContentProducer(Reference ref)
          Generates a SearchableEntityProducer
 void rebuildIndex()
          Rebuild the index from the entities own stored state rebuild the index completely from scratch
 void refreshIndex()
          refresh the index from the current stored state Refresh the index based on the registered entities
 void registerEntityContentProducer(EntityContentProducer ecp)
          register an entity content producer to provide content to the search engine EntityProducers that want their content indexed on full text must register an EntityContentProducer with the SearchIndexBuilder
 void setLogger(Logger logger)
           
 void setSearchBuilderItemDao(SearchBuilderItemDao searchBuilderItemDao)
           
 void setSearchIndexBuilderWorker(SearchIndexBuilderWorker searchIndexBuilderWorker)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SearchIndexBuilderImpl

public SearchIndexBuilderImpl()
Method Detail

init

public void init()

registerEntityContentProducer

public void registerEntityContentProducer(EntityContentProducer ecp)
register an entity content producer to provide content to the search engine EntityProducers that want their content indexed on full text must register an EntityContentProducer with the SearchIndexBuilder

Specified by:
registerEntityContentProducer in interface SearchIndexBuilder
Parameters:
ecp -

addResource

public void addResource(Notification notification,
                        Event event)
Add a resource to the indexing queue Adds a resource to the index builder

Specified by:
addResource in interface SearchIndexBuilder
Parameters:
notification -
event -

refreshIndex

public void refreshIndex()
refresh the index from the current stored state Refresh the index based on the registered entities

Specified by:
refreshIndex in interface SearchIndexBuilder

destroy

public void destroy()
Description copied from interface: SearchIndexBuilder
Close down the entire search infrastructure

Specified by:
destroy in interface SearchIndexBuilder

rebuildIndex

public void rebuildIndex()
Rebuild the index from the entities own stored state rebuild the index completely from scratch

Specified by:
rebuildIndex in interface SearchIndexBuilder

newEntityContentProducer

protected EntityContentProducer newEntityContentProducer(Reference ref)
Generates a SearchableEntityProducer

Parameters:
ref -
Returns:
Throws:
PermissionException
IdUnusedException
TypeException

newEntityContentProducer

protected EntityContentProducer newEntityContentProducer(Event event)
get hold of an entity content producer using the event

Parameters:
event -
Returns:

getLogger

public Logger getLogger()
Returns:
Returns the logger.

setLogger

public void setLogger(Logger logger)
Parameters:
logger - The logger to set.

getSearchBuilderItemDao

public SearchBuilderItemDao getSearchBuilderItemDao()
Returns:
Returns the searchBuilderItemDao.

setSearchBuilderItemDao

public void setSearchBuilderItemDao(SearchBuilderItemDao searchBuilderItemDao)
Parameters:
searchBuilderItemDao - The searchBuilderItemDao to set.

isBuildQueueEmpty

public boolean isBuildQueueEmpty()
return true if the queue is empty

Specified by:
isBuildQueueEmpty in interface SearchIndexBuilder
Returns:

getSearchIndexBuilderWorker

public SearchIndexBuilderWorker getSearchIndexBuilderWorker()
Returns:
Returns the searchIndexBuilderWorker.

setSearchIndexBuilderWorker

public void setSearchIndexBuilderWorker(SearchIndexBuilderWorker searchIndexBuilderWorker)
Parameters:
searchIndexBuilderWorker - The searchIndexBuilderWorker to set.

getContentProducers

public List getContentProducers()
get all the producers registerd, as a clone to avoid concurrent modification exceptions

Specified by:
getContentProducers in interface SearchIndexBuilder
Returns:

getPendingDocuments

public int getPendingDocuments()
Description copied from interface: SearchIndexBuilder
get the number of pending documents

Specified by:
getPendingDocuments in interface SearchIndexBuilder
Returns: