Class AbstractBatchIndexRequestHandler

java.lang.Object
com.broadleafcommerce.search.index.common.messaging.handler.AbstractBatchIndexRequestHandler

public abstract class AbstractBatchIndexRequestHandler extends Object
BatchIndexRequestHandlers are responsible for listening for channel events (BatchIndexRequest) associated with a specific Indexable repository domain type. These events are emitted in response to completion of bulk change operations, such as an import of product records.
Author:
Jeff Fischer
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractBatchIndexRequestHandler(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected <T extends com.broadleafcommerce.search.api.domain.Indexable<?>>
    void
    addNotFoundIndexables(List<?> chunk, List<T> indexables, String batchIndexableType)
    Add any indexables that were not found to the supplied list of indexables.
    protected com.fasterxml.jackson.databind.ObjectMapper
     
    abstract String[]
    The simple originating BatchIndexableType names supported by this handler.
    protected com.broadleafcommerce.common.extension.TypeFactory
     
    void
    handle(String batchIndexRequest)
    Entry point for the handler.
    abstract void
    hook(String batchIndexRequest)
    Hook point for message listeners to bind to the input channel with @StreamListener.
    boolean
    isValidType(String reportedType)
    Determine if the reported type (i.e.
    abstract void
    processBatchIndexRequest(com.fasterxml.jackson.databind.JsonNode batchIndexRequest)
    Handle the JSON representation of the BatchIndexRequest message that has been deemed appropriate for this handler based on comparing the expected batchIndexableType parameter in the JSON against the generic type of the handler implementation.
    void
    setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractBatchIndexRequestHandler

      public AbstractBatchIndexRequestHandler(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
  • Method Details

    • hook

      public abstract void hook(String batchIndexRequest)
      Hook point for message listeners to bind to the input channel with @StreamListener. Implementations of this method generally delegate to handle(String). It is generally important that each input channel name is unique in order to guarantee other listeners will still process the persistence message, even if one or more other listeners throw exceptions. As a corollary, there will also generally be a unique @Input annotated SubscribableChannel instance per listener tied to the unique input channel.
      Parameters:
      batchIndexRequest - The JSON representation of the request
    • handle

      public void handle(String batchIndexRequest)
      Entry point for the handler. This method will review the json representation and evaluate suitability against the getSupportedSimpleTypeNames() types. If appropriate, processBatchIndexRequest(JsonNode) is called.
      Parameters:
      batchIndexRequest - The JSON representation of the single index request
    • isValidType

      public boolean isValidType(String reportedType)
      Determine if the reported type (i.e. BatchIndexableType) of the incoming message is appropriate for this handler.
      Parameters:
      reportedType - the reported type of the originating entity on the incoming message
      Returns:
      Whether or not the type is supported by this handler
      See Also:
      • BatchIndexRequest.getBatchIndexableType()
    • addNotFoundIndexables

      protected <T extends com.broadleafcommerce.search.api.domain.Indexable<?>> void addNotFoundIndexables(List<?> chunk, List<T> indexables, String batchIndexableType)
      Add any indexables that were not found to the supplied list of indexables. This allows these not found indexables to be deleted in the reindex flow.
      Parameters:
      chunk - The ID chunk
      indexables - The indexables that were found
      batchIndexableType - The type of the indexable batch
    • getSupportedSimpleTypeNames

      public abstract String[] getSupportedSimpleTypeNames()
      The simple originating BatchIndexableType names supported by this handler.
      Returns:
      The array of simple type names supported by this handler
      See Also:
    • processBatchIndexRequest

      public abstract void processBatchIndexRequest(com.fasterxml.jackson.databind.JsonNode batchIndexRequest)
      Handle the JSON representation of the BatchIndexRequest message that has been deemed appropriate for this handler based on comparing the expected batchIndexableType parameter in the JSON against the generic type of the handler implementation.
      Parameters:
      batchIndexRequest - The JSON representation of the batch index request
      Throws:
      com.broadleafcommerce.search.api.SearchIndexException - thrown if the reindexing process is unsuccessful
    • setTypeFactory

      @Autowired public void setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
    • getObjectMapper

      protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()