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 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 id
        indexOperation - - the index operation
        externalIndexOperation - - indicates if the index operation is external
        facetSearchConfig - - the facet search configuration
        indexedType - - the indexed type
        indexedProperties - - the properties to index
        Returns:
        the new context
      • getContext

        T getContext()
        Returns the current context.
        Returns:
        the current context
      • 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 (see IndexerListener.afterIndexError(IndexerContext)).