org.modeshape.graph.search
Class AbstractSearchEngine<WorkspaceType extends SearchEngineWorkspace,ProcessorType extends SearchEngineProcessor>

java.lang.Object
  extended by org.modeshape.graph.search.AbstractSearchEngine<WorkspaceType,ProcessorType>
Type Parameters:
WorkspaceType - the workspace type
ProcessorType - the processor type
All Implemented Interfaces:
SearchEngine

@ThreadSafe
public abstract class AbstractSearchEngine<WorkspaceType extends SearchEngineWorkspace,ProcessorType extends SearchEngineProcessor>
extends Object
implements SearchEngine

A component that acts as a search engine for the content within a single RepositorySource. This engine manages a set of indexes and provides search functionality for each of the workspaces within the source, and provides various methods to (re)index the content contained with source's workspaces and keep the indexes up-to-date via changes.


Nested Class Summary
protected  class AbstractSearchEngine.SearchWorkspaces
           
static interface AbstractSearchEngine.Workspaces<WorkspaceType extends SearchEngineWorkspace>
           
 
Field Summary
static boolean DEFAULT_VERIFY_WORKSPACE_IN_SOURCE
           
 
Constructor Summary
protected AbstractSearchEngine(String sourceName, RepositoryConnectionFactory connectionFactory)
          Create a new provider instance that can be used to manage the indexes for the workspaces in a single source.
protected AbstractSearchEngine(String sourceName, RepositoryConnectionFactory connectionFactory, boolean verifyWorkspaceInSource)
          Create a new provider instance that can be used to manage the indexes for the workspaces in a single source.
 
Method Summary
protected abstract  ProcessorType createProcessor(ExecutionContext context, AbstractSearchEngine.Workspaces<WorkspaceType> workspaces, Observer observer, boolean readOnly)
          Create the SearchEngineProcessor implementation that can be used to operate against the SearchEngineWorkspace instances.
 SearchEngineProcessor createProcessor(ExecutionContext context, Observer observer, boolean readOnly)
          Create the SearchEngineProcessor implementation that can be used to operate against the SearchEngineWorkspace instances.
protected abstract  WorkspaceType createWorkspace(ExecutionContext context, String workspaceName)
          Create the index(es) required for the named workspace.
protected  RepositoryConnectionFactory getConnectionFactory()
           
 String getSourceName()
          Get the name of the source that can be searched with an engine that uses this provider.
protected  Graph graph(ExecutionContext context)
          Obtain a graph to the source for which this engine exists.
 boolean isVerifyWorkspaceInSource()
          Determine whether the workspaces should be verified with the original source before creating indexes for them.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.modeshape.graph.search.SearchEngine
index
 

Field Detail

DEFAULT_VERIFY_WORKSPACE_IN_SOURCE

public static final boolean DEFAULT_VERIFY_WORKSPACE_IN_SOURCE
See Also:
Constant Field Values
Constructor Detail

AbstractSearchEngine

protected AbstractSearchEngine(String sourceName,
                               RepositoryConnectionFactory connectionFactory)
Create a new provider instance that can be used to manage the indexes for the workspaces in a single source.

Parameters:
sourceName - the name of the source that can be searched; never null
connectionFactory - the connection factory; may be null if the engine can operate without connecting to the source

AbstractSearchEngine

protected AbstractSearchEngine(String sourceName,
                               RepositoryConnectionFactory connectionFactory,
                               boolean verifyWorkspaceInSource)
Create a new provider instance that can be used to manage the indexes for the workspaces in a single source.

Parameters:
sourceName - the name of the source that can be searched; never null
connectionFactory - the connection factory; may be null if the engine can operate without connecting to the source
verifyWorkspaceInSource - true if the workspaces are to be verified by checking the original source
Throws:
IllegalArgumentException - if any of the parameters are null
Method Detail

getConnectionFactory

protected RepositoryConnectionFactory getConnectionFactory()
Returns:
connectionFactory

getSourceName

public String getSourceName()
Get the name of the source that can be searched with an engine that uses this provider.

Specified by:
getSourceName in interface SearchEngine
Returns:
the name of the source that is to be searchable; never null
See Also:
SearchEngine.getSourceName()

isVerifyWorkspaceInSource

public boolean isVerifyWorkspaceInSource()
Determine whether the workspaces should be verified with the original source before creating indexes for them.

Returns:
true if verification should be performed, or false otherwise

graph

protected Graph graph(ExecutionContext context)
Obtain a graph to the source for which this engine exists.

Parameters:
context - the context in which the graph operations should be performed; never null
Returns:
the graph; never null
Throws:
RepositorySourceException - if a connection to the source cannot be established

createWorkspace

protected abstract WorkspaceType createWorkspace(ExecutionContext context,
                                                 String workspaceName)
                                                                        throws SearchEngineException
Create the index(es) required for the named workspace.

Parameters:
context - the context in which the operation is to be performed; may not be null
workspaceName - the name of the workspace; may not be null
Returns:
the workspace; never null
Throws:
SearchEngineException - if there is a problem creating the workspace.

createProcessor

protected abstract ProcessorType createProcessor(ExecutionContext context,
                                                 AbstractSearchEngine.Workspaces<WorkspaceType> workspaces,
                                                 Observer observer,
                                                 boolean readOnly)
Create the SearchEngineProcessor implementation that can be used to operate against the SearchEngineWorkspace instances.

Note that the resulting processor must be closed by the caller when completed.

Parameters:
context - the context in which the processor is to be used; never null
workspaces - the set of existing search workspaces; never null
observer - the observer of any events created by the processor; may be null
readOnly - true if the processor will only be reading or searching, or false if the processor will be used to update the workspaces
Returns:
the processor; may not be null

createProcessor

public SearchEngineProcessor createProcessor(ExecutionContext context,
                                             Observer observer,
                                             boolean readOnly)
Create the SearchEngineProcessor implementation that can be used to operate against the SearchEngineWorkspace instances.

Note that the resulting processor must be closed by the caller when completed.

Specified by:
createProcessor in interface SearchEngine
Parameters:
context - the context in which the processor is to be used; never null
observer - the observer of any events created by the processor; may be null
readOnly - true if the processor will only be reading or searching, or false if the processor will be used to update the workspaces
Returns:
the processor; may not be null
See Also:
SearchEngine.createProcessor(org.modeshape.graph.ExecutionContext, org.modeshape.graph.observe.Observer, boolean)


Copyright © 2008-2011 JBoss, a division of Red Hat. All Rights Reserved.