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 specificIndexablerepository 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
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected <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.ObjectMappergetObjectMapper()abstract String[]getSupportedSimpleTypeNames()The simple originatingBatchIndexableTypenames supported by this handler.protected com.broadleafcommerce.common.extension.TypeFactorygetTypeFactory()voidhandle(String batchIndexRequest)Entry point for the handler.abstract voidhook(String batchIndexRequest)Hook point for message listeners to bind to the input channel with@StreamListener.booleanisValidType(String reportedType)Determine if the reported type (i.e.abstract voidprocessBatchIndexRequest(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 expectedbatchIndexableTypeparameter in the JSON against the generic type of the handler implementation.voidsetTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
-
Method Detail
-
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 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@InputannotatedSubscribableChannelinstance 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 thegetSupportedSimpleTypeNames()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 chunkindexables- The indexables that were foundbatchIndexableType- The type of the indexable batch
-
getSupportedSimpleTypeNames
public abstract String[] getSupportedSimpleTypeNames()
The simple originatingBatchIndexableTypenames supported by this handler.- Returns:
- The array of simple type names supported by this handler
- See Also:
isValidType(String)
-
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 expectedbatchIndexableTypeparameter 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()
-
-