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 ofIndexerContext.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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description TcreateContext(long indexOperationId, IndexOperation indexOperation, boolean externalIndexOperation, FacetSearchConfig facetSearchConfig, IndexedType indexedType, java.util.Collection<IndexedProperty> indexedProperties)Creates a new indexer context and sets it as the current one.voiddestroyContext()Destroys the current context.voiddestroyContext(java.lang.Exception exception)Destroys the current context because an exception occurred.TgetContext()Returns the current context.voidinitializeContext()Initializes the current context and executes the before index listeners (seeIndexerListener.beforeIndex(IndexerContext)).voidprepareContext()Prepares the context and executes the after prepare context listeners (seeExtendedIndexerListener.afterPrepareContext(IndexerContext)).
-
-
-
Method Detail
-
createContext
T createContext(long indexOperationId, IndexOperation indexOperation, boolean externalIndexOperation, FacetSearchConfig facetSearchConfig, IndexedType indexedType, java.util.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
void prepareContext() throws IndexerExceptionPrepares the context and executes the after prepare context listeners (seeExtendedIndexerListener.afterPrepareContext(IndexerContext)).- Throws:
IndexerException- if an error occurs during the listeners execution
-
initializeContext
void initializeContext() throws IndexerExceptionInitializes 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
void destroyContext() throws IndexerExceptionDestroys 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
void destroyContext(java.lang.Exception exception)
Destroys the current context because an exception occurred. Before destroying an active context it executes the after index error listeners (seeIndexerListener.afterIndexError(IndexerContext)).
-
-