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 ofIndexerBatchContext
.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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description T
createContext(long indexOperationId, IndexOperation indexOperation, boolean externalIndexOperation, FacetSearchConfig facetSearchConfig, IndexedType indexedType, java.util.Collection<IndexedProperty> indexedProperties)
Creates a new indexer batch context and sets it as current one.void
destroyContext()
Destroys the current context.void
destroyContext(java.lang.Exception exception)
Destroys the current context because an exception occurred.T
getContext()
Returns the current context.void
initializeContext()
Initializes the current context and executes the before batch listeners (seeIndexerBatchListener.beforeBatch(IndexerBatchContext)
).void
prepareContext()
Prepares the context and executes the after prepare context listeners (seeExtendedIndexerBatchListener.afterPrepareContext(IndexerBatchContext)
).
-
-
-
Method Detail
-
createContext
T createContext(long indexOperationId, IndexOperation indexOperation, boolean externalIndexOperation, FacetSearchConfig facetSearchConfig, IndexedType indexedType, java.util.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
void prepareContext() throws IndexerException
Prepares the context and executes the after prepare context listeners (seeExtendedIndexerBatchListener.afterPrepareContext(IndexerBatchContext)
).- Throws:
IndexerException
- if an error occurs during the listeners execution
-
initializeContext
void initializeContext() throws IndexerException
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
void destroyContext() throws IndexerException
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
void destroyContext(java.lang.Exception exception)
Destroys the current context because an exception occurred. Before destroying an active context it executes the after batch error listeners (seeIndexerBatchListener.afterBatchError(IndexerBatchContext)
).
-
-