Interface IndexerBatchContextFactory<T extends IndexerBatchContext>
- Type Parameters:
T- - the indexer batch context type
- All Known Implementing Classes:
DefaultIndexerBatchContextFactory
public interface IndexerBatchContextFactory<T extends IndexerBatchContext>
Implementations of this interface are responsible for creating and destroying instances of
IndexerBatchContext.
Code creating/destroying contexts should normally use the following pattern:
try
{
final IndexerBatchContext batchContext = indexerBatchContextFactory.createContext(externalIndexOperation, indexerOperation,
facetSearchConfig, indexedType, indexedProperties, items);
// call additional setters on the context object
indexerContextFactory.prepareContext();
// call the setter for the PKs.
indexerBatchContextFactory.initializeContext();
// put your logic here
indexerBatchContextFactory.destroyContext();
}
catch (final IndexerException | ... | RuntimeException e)
{
indexerBatchContextFactory.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 batch context and sets it as 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 batch listeners (seeIndexerBatchListener.beforeBatch(IndexerBatchContext)).voidPrepares the context and executes the after prepare context listeners (seeExtendedIndexerBatchListener.afterPrepareContext(IndexerBatchContext)).
-
Method Details
-
createContext
T createContext(long indexOperationId, IndexOperation indexOperation, boolean externalIndexOperation, FacetSearchConfig facetSearchConfig, IndexedType indexedType, Collection<IndexedProperty> indexedProperties) Creates a new indexer batch context and sets it as 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 (seeExtendedIndexerBatchListener.afterPrepareContext(IndexerBatchContext)).- Throws:
IndexerException- if an error occurs during the listeners execution
-
initializeContext
Initializes the current context and executes the before batch listeners (seeIndexerBatchListener.beforeBatch(IndexerBatchContext)).- 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 batch listeners (seeIndexerBatchListener.afterBatch(IndexerBatchContext)).- 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 batch error listeners (seeIndexerBatchListener.afterBatchError(IndexerBatchContext)).
-