Observer ExampleObserverExample demonstrates how to use a MapListener to monitor cache events such as when cache data has been inserted, updated, and removed. A subset of the code is shown below. Java Observer Example
cache.addMapListener(new ContactChangeListener());
ContactChangeListener is a class that implements the MapListener interface. .NET Observer Example
cache.AddCacheListener(new ContactChangeListener());
ContactChangeListener is a class that implements the ICacheListener interface. C++ Observer Example
ContactChangeListener::Handle hListener = ContactChangeListener::create(); hCache->addFilterListener(hListener); ContactChangeListener is a class that extends the MapListener type using Coherence extend macro. class ContactChangeListener : public class_spec<ContactChangeListener, extends <MapListener> > There is no immediate output when this example is run. The registered listener outputs the entry when it is inserted, updated, and deleted. For an update, it outputs both the old value and the new value. The changes to entries are caused by running the Basic Data Access Example and the Processor Example, so the output happens when those examples are run.
|