public class ContinuousQueryListenerAdapter extends Object implements ContinuousQueryListener
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); }
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
logger |
static String |
ORIGINAL_DEFAULT_LISTENER_METHOD |
Constructor and Description |
---|
ContinuousQueryListenerAdapter()
Create a new
ContinuousQueryListenerAdapter with default settings. |
ContinuousQueryListenerAdapter(Object delegate)
Create a new
ContinuousQueryListenerAdapter for the given delegate. |
Modifier and Type | Method and Description |
---|---|
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 in the case where no specific listener method
has been determined.
|
void |
setDelegate(Object delegate)
Set a target object to delegate events listening to.
|
public static final String ORIGINAL_DEFAULT_LISTENER_METHOD
protected final org.apache.commons.logging.Log logger
public ContinuousQueryListenerAdapter()
ContinuousQueryListenerAdapter
with default settings.public ContinuousQueryListenerAdapter(Object delegate)
ContinuousQueryListenerAdapter
for the given delegate.delegate
- the delegate objectpublic 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
.defaultListenerMethod
- the name of the default listener method to invoke.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 String getListenerMethodName(com.gemstone.gemfire.cache.query.CqEvent event)
The default implementation simply returns the configured default listener method, if any.
event
- the GemFire eventnull
)setDefaultListenerMethod(java.lang.String)
protected void handleListenerException(Throwable ex)
ex
- the exception to handleprotected 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)