T
- type
of the entity tied to the event.ID
- type
of the identifier of the entity.public abstract static class RepositoryAsyncEventListener.AbstractAsyncEventOperationRepositoryFunction<T,ID> extends java.lang.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 and Description |
---|
AbstractAsyncEventOperationRepositoryFunction(RepositoryAsyncEventListener<T,ID> listener)
Constructs an new instance of
RepositoryAsyncEventListener.AbstractAsyncEventOperationRepositoryFunction initialized with
the given, required RepositoryAsyncEventListener to which this function is associated. |
Modifier and Type | Method and Description |
---|---|
java.lang.Boolean |
apply(org.apache.geode.cache.asyncqueue.AsyncEvent<ID,T> event)
Processes the given
AsyncEvent by first determining whether the event can be processed by this
Function , and then proceeds to extract the entity
associated with the event to invoke the appropriate Spring Data CrudRepository data access operation
determined by the AsyncEvent Operation . |
protected abstract <R> R |
doRepositoryOp(T entity)
Invokes the appropriate Spring Data
CrudRepository data access operation based on the
AsyncEvent Operation as determined by GatewayQueueEvent.getOperation() . |
protected RepositoryAsyncEventListener.AsyncEventErrorHandler |
getErrorHandler()
|
protected RepositoryAsyncEventListener<T,ID> |
getListener()
Returns a reference to the associated
RepositoryAsyncEventListener . |
protected org.springframework.data.repository.CrudRepository<T,ID> |
getRepository()
|
protected T |
resolveEntity(org.apache.geode.cache.asyncqueue.AsyncEvent<ID,T> event)
Resolves the
entity associated with the AsyncEvent . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canProcess
public AbstractAsyncEventOperationRepositoryFunction(@NonNull RepositoryAsyncEventListener<T,ID> listener)
RepositoryAsyncEventListener.AbstractAsyncEventOperationRepositoryFunction
initialized with
the given, required RepositoryAsyncEventListener
to which this function is associated.listener
- RepositoryAsyncEventListener
processing AsyncEvents
by invoking this Function
to handle them.java.lang.IllegalArgumentException
- if RepositoryAsyncEventListener
is null.RepositoryAsyncEventListener
protected RepositoryAsyncEventListener.AsyncEventErrorHandler getErrorHandler()
configured
RepositoryAsyncEventListener
RepositoryAsyncEventListener.AsyncEventErrorHandler
.RepositoryAsyncEventListener.AsyncEventErrorHandler
; never null.RepositoryAsyncEventListener.getAsyncEventErrorHandler()
,
RepositoryAsyncEventListener.AsyncEventErrorHandler
,
getListener()
@NonNull protected RepositoryAsyncEventListener<T,ID> getListener()
RepositoryAsyncEventListener
.RepositoryAsyncEventListener
; never null.RepositoryAsyncEventListener
@NonNull protected org.springframework.data.repository.CrudRepository<T,ID> getRepository()
CrudRepository
; never null.CrudRepository
,
RepositoryAsyncEventListener.getRepository()
,
getListener()
public java.lang.Boolean apply(@Nullable org.apache.geode.cache.asyncqueue.AsyncEvent<ID,T> event)
AsyncEvent
by first determining whether the event can be processed by this
Function
, and then proceeds to extract the entity
associated with the event to invoke the appropriate Spring Data CrudRepository
data access operation
determined by the AsyncEvent
Operation
.
If an error
is thrown while processing the AsyncEvent
, then the
RepositoryAsyncEventListener.AsyncEventErrorHandler
is called to handle the error and perform any necessary/required
post-processing actions.
RepositoryAsyncEventListener.AsyncEventErrorHandler
can 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.apply
in interface java.util.function.Function<org.apache.geode.cache.asyncqueue.AsyncEvent<ID,T>,java.lang.Boolean>
event
- AsyncEvent
to process.java.lang.IllegalStateException
- if the resolve entity is null.AsyncEvent
,
RepositoryAsyncEventListener.AsyncEventErrorHandler
,
RepositoryAsyncEventListener.AsyncEventOperationRepositoryFunction.canProcess(AsyncEvent)
,
doRepositoryOp(Object)
,
resolveEntity(AsyncEvent)
,
getErrorHandler()
protected abstract <R> R doRepositoryOp(@NonNull T entity)
CrudRepository
data access operation based on the
AsyncEvent
Operation
as determined by GatewayQueueEvent.getOperation()
.R
- type
of the Spring Data CrudRepository
data access operation return value.entity
- entity to process.CrudRepository
data access operation.CrudRepository
protected T resolveEntity(@NonNull org.apache.geode.cache.asyncqueue.AsyncEvent<ID,T> event)
entity
associated with the AsyncEvent
.event
- AsyncEvent
from which to resolve the entity.AsyncEvent
.java.lang.IllegalArgumentException
- if AsyncEvent
is null.java.lang.IllegalStateException
- if the resolved entity
is null.GatewayQueueEvent.getDeserializedValue()
,
AsyncEvent