Class AbstractSingleIndexRequestHandler
- java.lang.Object
-
- com.broadleafcommerce.search.index.common.messaging.handler.AbstractSingleIndexRequestHandler
-
public abstract class AbstractSingleIndexRequestHandler extends Object
SingleIndexRequestHandlers are responsible for listening for channel events (SingleIndexRequest
) associated with a specificIndexable
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 correspondingSingleIndexRequestMessageBuilder
.- Author:
- Samarth Dhruva (samarthd)
-
-
Constructor Summary
Constructors Constructor Description AbstractSingleIndexRequestHandler(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected com.fasterxml.jackson.databind.ObjectMapper
getObjectMapper()
abstract String[]
getSupportedSimpleTypeNames()
The simple originating entity type names supported by this handler.void
handle(String singleIndexRequest)
Entry point for the handler.abstract void
hook(String singleIndexRequest)
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
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.
-
-
-
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 tohandle(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
annotatedSubscribableChannel
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 thegetSupportedSimpleTypeNames()
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 byClass.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()
-
-