106 WebSphere eXtreme Scale Best Practices for Operation and Management
throws IOException {
Date date = (Date)value;
The final step is to configure our ExampleOptimisticCallbackImpl class so that WebSphere
eXtreme Scale knows to use it. Example 5-18 shows how we can change an objectgrid.xml
to achieve this configuration (the parts in italics are the changes).
Example 5-18 ExampleOptimisticCallbackImpl class
<objectGrid name="MyGrid">
<backingMap name="MyBackingMap" readOnly="false" lockStrategy="OPTIMISTIC"
<backingMapPluginCollection id="MyBackingMapPlugins">
<bean id="OptimisticCallback"
5.4.3 MapEventListener plug-ins
A MapEventListener is a plug-in that allows you to execute custom logic when certain events
happen. If you want to be notified whenever an entry is evicted (for whatever reason, such as
if the time-to-live value that you configured has expired), you can write a MapEventListener
implementation that will be called when an entry is evicted.
Example 5-19 shows an example of a simple MapEventListener, which logs to SystemOut.log
when various methods are called.
Example 5-19 Example MapEventListener
import java.util.Date;
import com.ibm.websphere.objectgrid.plugins.MapEventListener;
public class ExampleMapEventListener implements MapEventListener {
public void entryEvicted(Object key, Object value) {
System.out.println("ExampleMapEventListener: At " + new Date() + " an entry
with key " + key + " and value " + value + " has been evicted.");
public void preloadCompleted(Throwable arg0) {
// Not much interesting to do here
To configure your grid so that this MapEventListener is used, you must modify your
ObjectGrid descriptor XML file (the deployment XML file does not have to be modified) to
resemble Example 5-20 on page 107 (the changes are in italics).

Get WebSphere eXtreme Scale Best Practices for Operation and Management now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.