GemFire 6.6

com.gemstone.gemfire.cache.util
Class CacheListenerAdapter<K,V>

java.lang.Object
  extended by com.gemstone.gemfire.cache.util.CacheListenerAdapter<K,V>
All Implemented Interfaces:
CacheCallback, CacheListener<K,V>
Direct Known Subclasses:
RegionMembershipListenerAdapter

public abstract class CacheListenerAdapter<K,V>
extends Object
implements CacheListener<K,V>

Utility class that implements all methods in CacheListener with empty implementations. Applications can subclass this class and only override the methods for the events of interest.

Subclasses declared in a Cache XML file, it must also implement Declarable

Since:
3.0

Constructor Summary
CacheListenerAdapter()
           
 
Method Summary
 void afterCreate(EntryEvent<K,V> event)
          Handles the event of new key being added to a region.
 void afterDestroy(EntryEvent<K,V> event)
          Handles the event of an entry being destroyed.
 void afterInvalidate(EntryEvent<K,V> event)
          Handles the event of an entry's value being invalidated.
 void afterRegionClear(RegionEvent<K,V> event)
          Handles the event of a region being cleared.
 void afterRegionCreate(RegionEvent<K,V> event)
          Handles the event of a region being created.
 void afterRegionDestroy(RegionEvent<K,V> event)
          Handles the event of a region being destroyed.
 void afterRegionInvalidate(RegionEvent<K,V> event)
          Handles the event of a region being invalidated.
 void afterRegionLive(RegionEvent<K,V> event)
          Handles the event of a region being live after receiving the marker from the server.
 void afterUpdate(EntryEvent<K,V> event)
          Handles the event of an entry's value being modified in a region.
 void close()
          Called when the region containing this callback is closed or destroyed, when the cache is closed, or when a callback is removed from a region using an AttributesMutator.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheListenerAdapter

public CacheListenerAdapter()
Method Detail

afterCreate

public void afterCreate(EntryEvent<K,V> event)
Description copied from interface: CacheListener
Handles the event of new key being added to a region. The entry did not previously exist in this region in the local cache (even with a null value).

Specified by:
afterCreate in interface CacheListener<K,V>
Parameters:
event - the EntryEvent
See Also:
Region.create(Object, Object), Region.put(Object, Object), Region.get(Object)

afterDestroy

public void afterDestroy(EntryEvent<K,V> event)
Description copied from interface: CacheListener
Handles the event of an entry being destroyed.

Specified by:
afterDestroy in interface CacheListener<K,V>
Parameters:
event - the EntryEvent
See Also:
Region.destroy(Object)

afterInvalidate

public void afterInvalidate(EntryEvent<K,V> event)
Description copied from interface: CacheListener
Handles the event of an entry's value being invalidated.

Specified by:
afterInvalidate in interface CacheListener<K,V>
Parameters:
event - the EntryEvent
See Also:
Region.invalidate(Object)

afterRegionDestroy

public void afterRegionDestroy(RegionEvent<K,V> event)
Description copied from interface: CacheListener
Handles the event of a region being destroyed. Events are not invoked for each individual entry that is destroyed as a result of the region being destroyed. Each subregion, however, gets its own afterRegionDestroyed event invoked on its listener.

Specified by:
afterRegionDestroy in interface CacheListener<K,V>
Parameters:
event - the RegionEvent
See Also:
Region.destroyRegion(), Region.localDestroyRegion(), Region.close(), RegionService.close()

afterRegionCreate

public void afterRegionCreate(RegionEvent<K,V> event)
Description copied from interface: CacheListener
Handles the event of a region being created. Events are invoked for each individual region that is created.

Note that this method is only called for creates done in the local vm. To be notified of creates done in remote vms use RegionMembershipListener.afterRemoteRegionCreate(com.gemstone.gemfire.cache.RegionEvent).

Specified by:
afterRegionCreate in interface CacheListener<K,V>
Parameters:
event - the RegionEvent
See Also:
Cache.createRegion(java.lang.String, com.gemstone.gemfire.cache.RegionAttributes), Region.createSubregion(java.lang.String, com.gemstone.gemfire.cache.RegionAttributes)

afterRegionInvalidate

public void afterRegionInvalidate(RegionEvent<K,V> event)
Description copied from interface: CacheListener
Handles the event of a region being invalidated. Events are not invoked for each individual value that is invalidated as a result of the region being invalidated. Each subregion, however, gets its own regionInvalidated event invoked on its listener.

Specified by:
afterRegionInvalidate in interface CacheListener<K,V>
Parameters:
event - the RegionEvent
See Also:
Region.invalidateRegion(), Region.localInvalidateRegion()

afterUpdate

public void afterUpdate(EntryEvent<K,V> event)
Description copied from interface: CacheListener
Handles the event of an entry's value being modified in a region. This entry previously existed in this region in the local cache, but its previous value may have been null.

Specified by:
afterUpdate in interface CacheListener<K,V>
Parameters:
event - the EntryEvent
See Also:
Region.put(Object, Object)

afterRegionClear

public void afterRegionClear(RegionEvent<K,V> event)
Description copied from interface: CacheListener
Handles the event of a region being cleared. Events are not invoked for each individual entry that is removed as a result of the region being cleared.

Specified by:
afterRegionClear in interface CacheListener<K,V>
Parameters:
event - the RegionEvent
See Also:
Region.clear()

afterRegionLive

public void afterRegionLive(RegionEvent<K,V> event)
Description copied from interface: CacheListener
Handles the event of a region being live after receiving the marker from the server.

Specified by:
afterRegionLive in interface CacheListener<K,V>
Parameters:
event - the RegionEvent
See Also:
Cache.readyForEvents()

close

public void close()
Description copied from interface: CacheCallback
Called when the region containing this callback is closed or destroyed, when the cache is closed, or when a callback is removed from a region using an AttributesMutator.

Implementations should cleanup any external resources such as database connections. Any runtime exceptions this method throws will be logged.

It is possible for this method to be called multiple times on a single callback instance, so implementations must be tolerant of this.

Specified by:
close in interface CacheCallback
See Also:
RegionService.close(), Region.close(), Region.localDestroyRegion(), Region.destroyRegion(), AttributesMutator

GemFire 6.6

Copyright © 1997-2011 VMware, Inc. All rights reserved.