Spring Boot for VMware GemFire
Package org.springframework.geode.cache
Class RepositoryAsyncEventListener.AbstractAsyncEventOperationRepositoryFunction<T,ID>
java.lang.Object
org.springframework.geode.cache.RepositoryAsyncEventListener.AbstractAsyncEventOperationRepositoryFunction<T,ID>
- Type Parameters:
T-typeof the entity tied to the event.ID-typeof the identifier of the entity.
- All Implemented Interfaces:
Function<org.apache.geode.cache.asyncqueue.AsyncEvent<ID,,T>, Boolean> RepositoryAsyncEventListener.AsyncEventOperationRepositoryFunction<T,ID>
- Direct Known Subclasses:
RepositoryAsyncEventListener.CreateUpdateAsyncEventRepositoryFunction,RepositoryAsyncEventListener.RemoveAsyncEventRepositoryFunction
- Enclosing class:
- RepositoryAsyncEventListener<T,
ID>
public abstract static class RepositoryAsyncEventListener.AbstractAsyncEventOperationRepositoryFunction<T,ID>
extends Object
implements RepositoryAsyncEventListener.AsyncEventOperationRepositoryFunction<T,ID>
RepositoryAsyncEventListener.AbstractAsyncEventOperationRepositoryFunction is an abstract base class implementing the
RepositoryAsyncEventListener.AsyncEventOperationRepositoryFunction interface to provided a default template implementation
of the Function.apply(Object) method.-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an new instance ofRepositoryAsyncEventListener.AbstractAsyncEventOperationRepositoryFunctioninitialized with the given, requiredRepositoryAsyncEventListenerto which this function is associated. -
Method Summary
Modifier and TypeMethodDescriptionProcesses the givenAsyncEventby first determining whether the event can be processed by thisFunction, and then proceeds to extract theentityassociated with the event to invoke the appropriate Spring DataCrudRepositorydata access operation determined by theAsyncEventOperation.protected abstract <R> RdoRepositoryOp(T entity) Invokes the appropriate Spring DataCrudRepositorydata access operation based on theAsyncEventOperationas determined byGatewayQueueEvent.getOperation().protected RepositoryAsyncEventListener<T,ID> Returns a reference to the associatedRepositoryAsyncEventListener.protected TresolveEntity(org.apache.geode.cache.asyncqueue.AsyncEvent<ID, T> event) Resolves theentityassociated with theAsyncEvent.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.geode.cache.RepositoryAsyncEventListener.AsyncEventOperationRepositoryFunction
canProcess
-
Constructor Details
-
AbstractAsyncEventOperationRepositoryFunction
public AbstractAsyncEventOperationRepositoryFunction(@NonNull RepositoryAsyncEventListener<T, ID> listener) Constructs an new instance ofRepositoryAsyncEventListener.AbstractAsyncEventOperationRepositoryFunctioninitialized with the given, requiredRepositoryAsyncEventListenerto which this function is associated.- Parameters:
listener-RepositoryAsyncEventListenerprocessingAsyncEventsby invoking thisFunctionto handle them.- Throws:
IllegalArgumentException- ifRepositoryAsyncEventListeneris null.- See Also:
-
-
Method Details
-
getErrorHandler
Alias to theconfiguredRepositoryAsyncEventListenerRepositoryAsyncEventListener.AsyncEventErrorHandler.- Returns:
- the configured
RepositoryAsyncEventListener.AsyncEventErrorHandler; never null. - See Also:
-
getListener
Returns a reference to the associatedRepositoryAsyncEventListener.- Returns:
- a reference to the associated
RepositoryAsyncEventListener; never null. - See Also:
-
getRepository
- Returns:
- the configured
CrudRepository; never null. - See Also:
-
CrudRepositoryRepositoryAsyncEventListener.getRepository()getListener()
-
apply
Processes the givenAsyncEventby first determining whether the event can be processed by thisFunction, and then proceeds to extract theentityassociated with the event to invoke the appropriate Spring DataCrudRepositorydata access operation determined by theAsyncEventOperation. If anerroris thrown while processing theAsyncEvent, then theRepositoryAsyncEventListener.AsyncEventErrorHandleris called to handle the error and perform any necessary/required post-processing actions.RepositoryAsyncEventListener.AsyncEventErrorHandlercan be implemented to retry the operation with incremental backoff, based on count or time, record the failure, perform resource cleanup actions, whatever is necessary and appropriate to the application use case.- Specified by:
applyin interfaceFunction<T,ID> - Parameters:
event-AsyncEventto process.- Returns:
- a boolean value indicating whether the event was successfully processed.
- Throws:
IllegalStateException- if the resolve entity is null.- See Also:
-
doRepositoryOp
Invokes the appropriate Spring DataCrudRepositorydata access operation based on theAsyncEventOperationas determined byGatewayQueueEvent.getOperation().- Type Parameters:
R-typeof the Spring DataCrudRepositorydata access operation return value.- Parameters:
entity- entity to process.- Returns:
- the result of invoking the Spring Data
CrudRepositorydata access operation. - See Also:
-
CrudRepository
-
resolveEntity
Resolves theentityassociated with theAsyncEvent.- Parameters:
event-AsyncEventfrom which to resolve the entity.- Returns:
- the resolve entity from the
AsyncEvent. - Throws:
IllegalArgumentException- ifAsyncEventis null.IllegalStateException- if the resolvedentityis null.- See Also:
-
GatewayQueueEvent.getDeserializedValue()AsyncEvent
-