|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.data.gemfire.listener.adapter.ContinuousQueryListenerAdapter
public class ContinuousQueryListenerAdapter
Event listener adapter that delegates the handling of messages to target listener methods via reflection, with flexible event type conversion. Allows listener methods to operate on event content types, completely independent from the GemFire API.
Modeled as much as possible after the JMS MessageListenerAdapter in Spring Framework.By default, the content of incoming GemFire events gets extracted before
being passed into the target listener method, to let the target method
operate on event content types such as Object or Operation instead of
the raw CqEvent
.
Find below some examples of method signatures compliant with this
adapter class. This first example handles all CqEvent
types
and gets passed the contents of each event
type as an
argument.
public interface PojoListener { void handleEvent(CqEvent event); void handleEvent(Operation baseOp); void handleEvent(Object key); void handleEvent(Object key, Object newValue); void handleEvent(Throwable th); void handleEvent(CqEvent event, Operation baseOp, byte[] deltaValue); void handleEvent(CqEvent event, Operation baseOp, Operation queryOp, Object key, Object newValue); }
MessageListenerAdapter
Field Summary | |
---|---|
protected org.apache.commons.logging.Log |
logger
Logger available to subclasses |
static String |
ORIGINAL_DEFAULT_LISTENER_METHOD
Out-of-the-box value for the default listener method: "handleEvent". |
Constructor Summary | |
---|---|
ContinuousQueryListenerAdapter()
Create a new ContinuousQueryListenerAdapter with default settings. |
|
ContinuousQueryListenerAdapter(Object delegate)
Create a new ContinuousQueryListenerAdapter for the given delegate. |
Method Summary | |
---|---|
protected String |
getDefaultListenerMethod()
Return the name of the default listener method to delegate to. |
Object |
getDelegate()
Returns the target object to delegate event listening to. |
protected String |
getListenerMethodName(com.gemstone.gemfire.cache.query.CqEvent event)
Determine the name of the listener method that is supposed to handle the given event. |
protected void |
handleListenerException(Throwable ex)
Handle the given exception that arose during listener execution. |
protected void |
invokeListenerMethod(com.gemstone.gemfire.cache.query.CqEvent event,
String methodName)
Invoke the specified listener method. |
void |
onEvent(com.gemstone.gemfire.cache.query.CqEvent event)
Standard ContinuousQueryListener entry point. |
void |
setDefaultListenerMethod(String defaultListenerMethod)
Specify the name of the default listener method to delegate to, for the case where no specific listener method has been determined. |
void |
setDelegate(Object delegate)
Set a target object to delegate events listening to. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ORIGINAL_DEFAULT_LISTENER_METHOD
protected final org.apache.commons.logging.Log logger
Constructor Detail |
---|
public ContinuousQueryListenerAdapter()
ContinuousQueryListenerAdapter
with default settings.
public ContinuousQueryListenerAdapter(Object delegate)
ContinuousQueryListenerAdapter
for the given delegate.
delegate
- the delegate objectMethod Detail |
---|
public void setDelegate(Object delegate)
If no explicit delegate object has been specified, listener methods are expected to present on this adapter instance, that is, on a custom subclass of this adapter, defining listener methods.
delegate
- delegate objectpublic Object getDelegate()
public void setDefaultListenerMethod(String defaultListenerMethod)
"handleEvent
.
getListenerMethodName(com.gemstone.gemfire.cache.query.CqEvent)
protected String getDefaultListenerMethod()
public void onEvent(com.gemstone.gemfire.cache.query.CqEvent event)
ContinuousQueryListener
entry point.
Delegates the event to the target listener method, with appropriate
conversion of the event argument. In case of an exception, the
handleListenerException(Throwable)
method will be invoked.
onEvent
in interface ContinuousQueryListener
event
- the incoming GemFire eventhandleListenerException(java.lang.Throwable)
protected void handleListenerException(Throwable ex)
ex
- the exception to handleprotected String getListenerMethodName(com.gemstone.gemfire.cache.query.CqEvent event)
The default implementation simply returns the configured default listener method, if any.
event
- the GemFire event
null
)setDefaultListenerMethod(java.lang.String)
protected void invokeListenerMethod(com.gemstone.gemfire.cache.query.CqEvent event, String methodName)
event
- the event arguments to be passed inmethodName
- the method to invokegetListenerMethodName(com.gemstone.gemfire.cache.query.CqEvent)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |