Interface IndexerContextFactory<T extends IndexerContext>
- All Known Implementing Classes:
DefaultIndexerContextFactory
public interface IndexerContextFactory<T extends IndexerContext>
Implementations of this interface are responsible for creating and destroying instances of
IndexerContext.
Code creating/destroying contexts should normally use the following pattern:
try
{
final IndexerContext context = indexerContextFactory.createContext(externalIndexOperation, indexerOperation,
facetSearchConfig, indexedType, indexedProperties, pks);
// call additional setters on the context object
indexerContextFactory.prepareContext();
// call the setter for the PKs.
indexerContextFactory.initializeContext();
// put your logic here
indexerContextFactory.destroyContext();
}
catch (final IndexerException | ... | RuntimeException e)
{
indexerContextFactory.destroyContext(e);
throw e;
}
-
Method Summary
Modifier and TypeMethodDescriptioncreateContext(long indexOperationId, IndexOperation indexOperation, boolean externalIndexOperation, FacetSearchConfig facetSearchConfig, IndexedType indexedType, Collection<IndexedProperty> indexedProperties) Creates a new indexer context and sets it as the current one.voidDestroys the current context.voiddestroyContext(Exception exception) Destroys the current context because an exception occurred.Returns the current context.voidInitializes the current context and executes the before index listeners (seeIndexerListener.beforeIndex(IndexerContext)).voidPrepares the context and executes the after prepare context listeners (seeExtendedIndexerListener.afterPrepareContext(IndexerContext)).
-
Method Details
-
createContext
T createContext(long indexOperationId, IndexOperation indexOperation, boolean externalIndexOperation, FacetSearchConfig facetSearchConfig, IndexedType indexedType, Collection<IndexedProperty> indexedProperties) Creates a new indexer context and sets it as the current one.- Parameters:
indexOperationId- - the index operation idindexOperation- - the index operationexternalIndexOperation- - indicates if the index operation is externalfacetSearchConfig- - the facet search configurationindexedType- - the indexed typeindexedProperties- - the properties to index- Returns:
- the new context
-
prepareContext
Prepares the context and executes the after prepare context listeners (seeExtendedIndexerListener.afterPrepareContext(IndexerContext)).- Throws:
IndexerException- if an error occurs during the listeners execution
-
initializeContext
Initializes the current context and executes the before index listeners (seeIndexerListener.beforeIndex(IndexerContext)).- Throws:
IndexerException- if an error occurs during the listeners execution
-
getContext
T getContext()Returns the current context.- Returns:
- the current context
-
destroyContext
Destroys the current context. Before destroying an active context it executes the after index listeners (seeIndexerListener.afterIndex(IndexerContext)).- Throws:
IndexerException- if an error occurs during the listeners execution
-
destroyContext
Destroys the current context because an exception occurred. Before destroying an active context it executes the after index error listeners (seeIndexerListener.afterIndexError(IndexerContext)).
-