Class AbstractSingleIndexRequestHandler


  • public abstract class AbstractSingleIndexRequestHandler
    extends Object
    SingleIndexRequestHandlers are responsible for listening for channel events (SingleIndexRequest) associated with a specific Indexable repository domain type. These events are emitted in response to persistence state change for entities and are delivered in the form of a JSON representation built by the corresponding SingleIndexRequestMessageBuilder.
    Author:
    Samarth Dhruva (samarthd)
    • Constructor Detail

      • AbstractSingleIndexRequestHandler

        public AbstractSingleIndexRequestHandler​(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
    • Method Detail

      • hook

        public abstract void hook​(String singleIndexRequest)
        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:
        singleIndexRequest - The JSON representation of the request
      • handle

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

        public boolean isValidType​(String reportedType)
        Determine if the reported type (i.e. class name of the originating entity) 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:
        SingleIndexRequest.get_class()
      • getSupportedSimpleTypeNames

        public abstract String[] getSupportedSimpleTypeNames()
        The simple originating entity type names supported by this handler. This is not the fully qualified classname, rather the simple name - similar to what is returned by Class.getSimpleName().
        Returns:
        The array of simple type names supported by this handler
        See Also:
        isValidType(String)
      • processSingleIndexRequest

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

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