GemFire 5.7

com.gemstone.gemfire.cache
Interface CacheListener

All Superinterfaces:
CacheCallback
All Known Subinterfaces:
RegionMembershipListener, RegionRoleListener
All Known Implementing Classes:
CacheListenerAdapter, RegionMembershipListenerAdapter, RegionRoleListenerAdapter

public interface CacheListener
extends CacheCallback

A listener that can be implemented to handle region- or entry-related events. The methods on a CacheListener are invoked synchronously. If the listener method takes a long time to execute then it will cause the operation that caused it to be invoked to take a long time. Listener code should not call the Regionmethods. Doing so could result in a deadlock. Instead the listener should cause some other thread to access the region and the listener must not wait for that thread to complete the task. Multiple events, on different entries, can cause concurrent invocation of CacheListener methods. Any exceptions thrown by the listener are caught by GemFire and logged.

Instead of implementing this interface it is recommended that you extend the CacheListenerAdapter class.

Since:
3.0
See Also:
AttributesFactory.addCacheListener(com.gemstone.gemfire.cache.CacheListener), AttributesFactory.initCacheListeners(com.gemstone.gemfire.cache.CacheListener[]), RegionAttributes.getCacheListeners(), AttributesMutator.addCacheListener(com.gemstone.gemfire.cache.CacheListener), AttributesMutator.removeCacheListener(com.gemstone.gemfire.cache.CacheListener), AttributesMutator.initCacheListeners(com.gemstone.gemfire.cache.CacheListener[])

Method Summary
 void afterCreate(EntryEvent event)
          Handles the event of new key being added to a region.
 void afterDestroy(EntryEvent event)
          Handles the event of an entry being destroyed.
 void afterInvalidate(EntryEvent event)
          Handles the event of an entry's value being invalidated.
 void afterRegionClear(RegionEvent event)
          Handles the event of a region being cleared.
 void afterRegionCreate(RegionEvent event)
          Handles the event of a region being created.
 void afterRegionDestroy(RegionEvent event)
          Handles the event of a region being destroyed.
 void afterRegionInvalidate(RegionEvent event)
          Handles the event of a region being invalidated.
 void afterRegionLive(RegionEvent event)
          Handles the event of a region being live after receiving the marker from the server.
 void afterUpdate(EntryEvent event)
          Handles the event of an entry's value being modified in a region.
 
Methods inherited from interface com.gemstone.gemfire.cache.CacheCallback
close
 

Method Detail

afterCreate

void afterCreate(EntryEvent event)
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).

Parameters:
event - the EntryEvent
See Also:
Region.create(Object, Object), Region.put(Object, Object), Region.get(Object)

afterUpdate

void afterUpdate(EntryEvent event)
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.

Parameters:
event - the EntryEvent
See Also:
Region.put(Object, Object)

afterInvalidate

void afterInvalidate(EntryEvent event)
Handles the event of an entry's value being invalidated.

Parameters:
event - the EntryEvent
See Also:
Region.invalidate(Object)

afterDestroy

void afterDestroy(EntryEvent event)
Handles the event of an entry being destroyed.

Parameters:
event - the EntryEvent
See Also:
Region.destroy(Object)

afterRegionInvalidate

void afterRegionInvalidate(RegionEvent event)
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.

Parameters:
event - the RegionEvent
See Also:
Region.invalidateRegion(), Region.localInvalidateRegion()

afterRegionDestroy

void afterRegionDestroy(RegionEvent event)
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.

Parameters:
event - the RegionEvent
See Also:
Region.destroyRegion(), Region.localDestroyRegion(), Region.close(), Cache.close()

afterRegionClear

void afterRegionClear(RegionEvent event)
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.

Parameters:
event - the RegionEvent
Since:
5.0
See Also:
Region.clear()

afterRegionCreate

void afterRegionCreate(RegionEvent event)
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).

Parameters:
event - the RegionEvent
Since:
5.0
See Also:
Cache.createRegion(java.lang.String, com.gemstone.gemfire.cache.RegionAttributes), Region.createSubregion(java.lang.String, com.gemstone.gemfire.cache.RegionAttributes)

afterRegionLive

void afterRegionLive(RegionEvent event)
Handles the event of a region being live after receiving the marker from the server.

Parameters:
event - the RegionEvent
Since:
5.5
See Also:
Cache.readyForEvents()

GemFire 5.7

Copyright © 2002-2008 GemStone Systems, Inc. All Rights Reserved.