GigaSpaces XAP 10.0.1 API

org.openspaces.events.adapter
Class AbstractResultEventListenerAdapter

java.lang.Object
  extended by org.openspaces.events.adapter.AbstractResultEventListenerAdapter
All Implemented Interfaces:
SpaceDataEventListener
Direct Known Subclasses:
AbstractReflectionEventListenerAdapter

public abstract class AbstractResultEventListenerAdapter
extends Object
implements SpaceDataEventListener

A base class event listener allowing for event listeners result handling by writing it back to the space. Subclasses should implement onEventWithResult(Object,GigaSpace,TransactionStatus,Object) with the result being writing to back to the space. The write lease can be controlled using setWriteLease(long).

Author:
kimchy

Constructor Summary
AbstractResultEventListenerAdapter()
           
 
Method Summary
protected  void handleResult(Object result, GigaSpace gigaSpace)
          Writes the result back to the space (if not null) under the configured write lease.
 void onEvent(Object data, GigaSpace gigaSpace, TransactionStatus txStatus, Object source)
          Implements the SpaceDataEventListener by delegating to onEventWithResult(Object,org.openspaces.core.GigaSpace,org.springframework.transaction.TransactionStatus,Object) and writing the result back to the space (if it is not null) using handleResult(Object,org.openspaces.core.GigaSpace).
protected abstract  Object onEventWithResult(Object data, GigaSpace gigaSpace, TransactionStatus txStatus, Object source)
          An event listener callback allowing to return a result that will be written back to the space.
 void setUpdateOrWrite(boolean updateOrWrite)
          Sets if the write operation will perform an update in case the entry result already exists in the space.
 void setUpdateTimeout(long updateTimeout)
          Sets the update timeout (im milliseconds) in case the flag setUpdateOrWrite(boolean) is set to true.
 void setWriteLease(long writeLease)
          The lease time the result will be written under (in milliseconds).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractResultEventListenerAdapter

public AbstractResultEventListenerAdapter()
Method Detail

setWriteLease

public void setWriteLease(long writeLease)
The lease time the result will be written under (in milliseconds). Defaults to Lease.FOREVER.

Parameters:
writeLease - The lease time the result will be written under

setUpdateOrWrite

public void setUpdateOrWrite(boolean updateOrWrite)
Sets if the write operation will perform an update in case the entry result already exists in the space. Default to true.


setUpdateTimeout

public void setUpdateTimeout(long updateTimeout)
Sets the update timeout (im milliseconds) in case the flag setUpdateOrWrite(boolean) is set to true.


onEvent

public void onEvent(Object data,
                    GigaSpace gigaSpace,
                    TransactionStatus txStatus,
                    Object source)
Implements the SpaceDataEventListener by delegating to onEventWithResult(Object,org.openspaces.core.GigaSpace,org.springframework.transaction.TransactionStatus,Object) and writing the result back to the space (if it is not null) using handleResult(Object,org.openspaces.core.GigaSpace).

Specified by:
onEvent in interface SpaceDataEventListener
Parameters:
data - The actual data object of the event
gigaSpace - A GigaSpace instance that can be used to perform additional operations against the space
txStatus - An optional transaction status allowing to rollback a transaction programmatically
source - Optional additional data or the actual source event data object (where relevant)

handleResult

protected void handleResult(Object result,
                            GigaSpace gigaSpace)
                     throws DataAccessException
Writes the result back to the space (if not null) under the configured write lease. Allows to be overridden in order to implement more advance result handling.

By default handles both single object and array of objects. Takes into account the 'updateOrWrite' flag when writing/updating the result back to the space.

Parameters:
result - The result to write back to the space
gigaSpace - The GigaSpace instance to operate against the space
Throws:
DataAccessException

onEventWithResult

protected abstract Object onEventWithResult(Object data,
                                            GigaSpace gigaSpace,
                                            TransactionStatus txStatus,
                                            Object source)
An event listener callback allowing to return a result that will be written back to the space.

Parameters:
data - The event data object
gigaSpace - A GigaSpace instance that can be used to perform additional operations against the space
txStatus - An optional transaction status allowing to rollback a transaction programmatically
source - Optional additional data or the actual source event data object (where relevant)
Returns:
A result object that will be written back to the space

GigaSpaces XAP 10.0.1 API

Copyright © GigaSpaces.