org.apache.geode.cache30

## Class TestCacheListener<K,V>

- java.lang.Object
- - org.apache.geode.cache30.TestCacheCallback
  - - org.apache.geode.cache30.TestCacheListener<K,V>

- All Implemented Interfaces:
    CacheCallback, CacheListener<K,V>, Declarable
  Direct Known Subclasses:
    CertifiableTestCacheListener

      public abstract class TestCacheListener<K,V>
      extends TestCacheCallback
      implements CacheListener<K,V>

  A `CacheListener` used in testing. Its callback methods are implemented to thrown `UnsupportedOperationException` unless the user overrides the "2" methods.
  Since:
    GemFire 3.0
  See Also:
    `TestCacheCallback.wasInvoked()`

- - ### Field Summary

    - ### Fields inherited from class org.apache.geode.cache30.TestCacheCallback

      `callbackError`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TestCacheListener()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterCreate(EntryEvent<K,V> event)` Handles the event of new key being added to a region.
    `void` | `afterCreate2(EntryEvent<K,V> event)`
    `void` | `afterDestroy(EntryEvent<K,V> event)` Handles the event of an entry being destroyed.
    `void` | `afterDestroy2(EntryEvent<K,V> event)`
    `void` | `afterDestroyBeforeAddEvent(EntryEvent<K,V> event)`
    `void` | `afterInvalidate(EntryEvent<K,V> event)` Handles the event of an entry's value being invalidated.
    `void` | `afterInvalidate2(EntryEvent<K,V> event)`
    `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` | `afterRegionDestroy2(RegionEvent<K,V> event)`
    `void` | `afterRegionDestroyBeforeAddEvent(RegionEvent<K,V> ignored)`
    `void` | `afterRegionInvalidate(RegionEvent<K,V> event)` Handles the event of a region being invalidated.
    `void` | `afterRegionInvalidate2(RegionEvent<K,V> event)`
    `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` | `afterUpdate2(EntryEvent<K,V> event)`
    `void` | `disableEventHistory()` Disables collection of events.
    `void` | `enableEventHistory()` Enables collection of event history.
    `java.util.List<CacheEvent<K,V>>` | `getEventHistory()` Returns a copy of the list of events collected in this listener's history.

    - ### Methods inherited from class org.apache.geode.cache30.TestCacheCallback

      `close, close2, isClosed, waitForInvocation, waitForInvocation, wasInvoked`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.geode.cache.CacheCallback

      `close`

    - ### Methods inherited from interface org.apache.geode.cache.Declarable

      `init, initialize`

- - ### Constructor Detail

    - #### TestCacheListener

          public TestCacheListener()

  - ### Method Detail

    - #### enableEventHistory

          public void enableEventHistory()

      Enables collection of event history.
      Since:
        GemFire 5.0

    - #### disableEventHistory

          public void disableEventHistory()

      Disables collection of events.
      Since:
        GemFire 5.0

    - #### getEventHistory

          public java.util.List<CacheEvent<K,V>> getEventHistory()

      Returns a copy of the list of events collected in this listener's history. Also clears the current history.
      Since:
        GemFire 5.0

    - #### 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)`

    - #### afterCreate2

          public void afterCreate2(EntryEvent<K,V> event)

    - #### 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)`

    - #### afterUpdate2

          public void afterUpdate2(EntryEvent<K,V> event)

    - #### 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)`

    - #### afterInvalidate2

          public void afterInvalidate2(EntryEvent<K,V> event)

    - #### 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)`

    - #### afterDestroyBeforeAddEvent

          public void afterDestroyBeforeAddEvent(EntryEvent<K,V> event)

    - #### afterDestroy2

          public void afterDestroy2(EntryEvent<K,V> event)

    - #### 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()`

    - #### afterRegionInvalidate2

          public void afterRegionInvalidate2(RegionEvent<K,V> event)

    - #### 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()`

    - #### afterRegionDestroyBeforeAddEvent

          public void afterRegionDestroyBeforeAddEvent(RegionEvent<K,V> ignored)

    - #### afterRegionDestroy2

          public void afterRegionDestroy2(RegionEvent<K,V> event)

    - #### 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()`

    - #### 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(org.apache.geode.cache.RegionEvent<K, V>)`.

      Specified by:
        `afterRegionCreate` in interface `CacheListener<K,V>`
      Parameters:
        `event` - the RegionEvent
      See Also:
        `Cache.createRegion(java.lang.String, org.apache.geode.cache.RegionAttributes<K, V>)`, `Region.createSubregion(java.lang.String, org.apache.geode.cache.RegionAttributes<SK, SV>)`

    - #### 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()`