Class AbstractBatchIndexRequestHandler
java.lang.Object
com.broadleafcommerce.search.index.common.messaging.handler.AbstractBatchIndexRequestHandler
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
ConstructorsConstructorDescriptionAbstractBatchIndexRequestHandler
(com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptionprotected <T extends com.broadleafcommerce.search.api.domain.Indexable<?>>
voidaddNotFoundIndexables
(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 originatingBatchIndexableType
names supported by this handler.protected com.broadleafcommerce.common.extension.TypeFactory
void
Entry point for the handler.abstract void
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 expectedbatchIndexableType
parameter in the JSON against the generic type of the handler implementation.void
setTypeFactory
(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
Constructor Details
-
AbstractBatchIndexRequestHandler
public AbstractBatchIndexRequestHandler(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
hook
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:
batchIndexRequest
- The JSON representation of the request
-
handle
Entry point for the handler. This method will review the json representation and evaluate suitability against thegetSupportedSimpleTypeNames()
types. If appropriate,processBatchIndexRequest(JsonNode)
is called.- Parameters:
batchIndexRequest
- The JSON representation of the single index request
-
isValidType
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 chunkindexables
- The indexables that were foundbatchIndexableType
- The type of the indexable batch
-
getSupportedSimpleTypeNames
The simple originatingBatchIndexableType
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 expectedbatchIndexableType
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()
-