|
GigaSpaces XAP 7.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.openspaces.events.adapter.AbstractResultEventListenerAdapter org.openspaces.events.adapter.AbstractReflectionEventListenerAdapter
public abstract class AbstractReflectionEventListenerAdapter
Base class for reflection driven invocation of event listener methods. Handles cases where a
single event listener method is configured, or several method event listeners are configured (all
must have the same name). The event listener methods are found and delegated to an object
configured using setDelegate(Object)
.
Subclasses must implement the doGetListenerMethods()
in order to list all the possible
event listener methods. If more than one event listener method is found, all event listener
methods must have the same name.
For best performance a single event listener method should be used. If a single event listener is found (by subclasses), caching of the method can be done in order to perform the reflection execution faster. If more than one event listener method is found - dynamic discovery of the appropriate method is done for each listener invocation.
Event listening methods can have no parameters or one or more parameters mapping to
SpaceDataEventListener.onEvent(Object,org.openspaces.core.GigaSpace,org.springframework.transaction.TransactionStatus,Object)
parameters order. If the method has a return value it will be handled thanks to
AbstractResultEventListenerAdapter
.
Having more than one event listening method allows for writing specific listener methods handling
different data event types (usually different types within the same inheritance tree). This
allows to remove the need for instanceof
checks within the listener code. If a
single listening method is used, it can still have a specific class type for the event data
object thanks to Java reflection, though if the event listener will be invoked with a different
type a reflection exception will be thrown.
Field Summary | |
---|---|
protected Log |
logger
Logger available to subclasses |
Constructor Summary | |
---|---|
AbstractReflectionEventListenerAdapter()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
|
protected abstract Method[] |
doGetListenerMethods()
Subclasses should implement this in order to provide a list of all the possible event listener delegate methods. |
Object |
getActualEventListener()
|
protected Object |
getDelegate()
Returns the event listener delegate. |
protected Object |
onEventWithResult(Object data,
GigaSpace gigaSpace,
TransactionStatus txStatus,
Object source)
Delegates the event listener invocation to the appropriate method of the configured setDelegate(Object) . |
void |
setDelegate(Object delegate)
The event listener delegate that will be searched for event listening methods and will have its method executed. |
void |
setUseFastRefelction(boolean useFastRefelction)
Controls if the listener will be invoked using fast reflection or not. |
Methods inherited from class org.openspaces.events.adapter.AbstractResultEventListenerAdapter |
---|
handleResult, onEvent, setUpdateOrWrite, setUpdateTimeout, setWriteLease |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final Log logger
Constructor Detail |
---|
public AbstractReflectionEventListenerAdapter()
Method Detail |
---|
public void setDelegate(Object delegate)
protected Object getDelegate()
public void setUseFastRefelction(boolean useFastRefelction)
true
.
public void afterPropertiesSet()
afterPropertiesSet
in interface InitializingBean
protected Object onEventWithResult(Object data, GigaSpace gigaSpace, TransactionStatus txStatus, Object source)
setDelegate(Object)
. If a single event listener delegate method is found, uses the
cached reflection Method. If more than one event listener delegate method is configured uses
reflection to dynamically find the relevant event listener method.
onEventWithResult
in class AbstractResultEventListenerAdapter
data
- The event data objectgigaSpace
- A GigaSpace instance that can be used to perform additional operations against the
spacetxStatus
- An optional transaction status allowing to rollback a transaction programmaticallysource
- Optional additional data or the actual source event data object (where relevant)
public Object getActualEventListener()
getActualEventListener
in interface EventListenerAdapter
protected abstract Method[] doGetListenerMethods()
|
GigaSpaces XAP 7.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |