org.apache.ignite.cache

## Class CacheInterceptorAdapter<K,V>

- java.lang.Object
- - org.apache.ignite.cache.CacheInterceptorAdapter<K,V>

- All Implemented Interfaces:
    Serializable, CacheInterceptor<K,V>

      public class CacheInterceptorAdapter<K,V>
      extends Object
      implements CacheInterceptor<K,V>

  Cache interceptor convenience adapter. It provides no-op implementations for all interceptor callbacks.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CacheInterceptorAdapter()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `onAfterPut(javax.cache.Cache.Entry<K,V> entry)` This method is called after new value has been stored.
    `void` | `onAfterRemove(javax.cache.Cache.Entry<K,V> entry)` This method is called after value has been removed.
    `V` | `onBeforePut(javax.cache.Cache.Entry<K,V> entry, V newVal)` This method is called within `IgniteCache.put(Object, Object)` and similar operations before new value is stored in cache.
    `@Nullable IgniteBiTuple<Boolean,V>` | `onBeforeRemove(javax.cache.Cache.Entry<K,V> entry)` This method is called within `IgniteCache.remove(Object)` and similar operations to provide control over returned value.
    `V` | `onGet(K key, V val)` This method is called within `IgniteCache.get(Object)` and similar operations to provide control over returned value.

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

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

- - ### Constructor Detail

    - #### CacheInterceptorAdapter

          public CacheInterceptorAdapter()

  - ### Method Detail

    - #### onGet

          @Nullable
          public V onGet(K key,
                                   V val)

      This method is called within `IgniteCache.get(Object)` and similar operations to provide control over returned value.

      If this method returns `null`, then `get()` operation results in `null` as well.

      This method should not throw any exception.

      Specified by:
        `onGet` in interface `CacheInterceptor<K,V>`
      Parameters:
        `key` - Key.
        `val` - Value mapped to `key` at the moment of `get()` operation.
      Returns:
        The new value to be returned as result of `get()` operation.
      See Also:
        `Cache.get(Object)`

    - #### onBeforePut

          @Nullable
          public V onBeforePut(javax.cache.Cache.Entry<K,V> entry,
                                         V newVal)

      This method is called within `IgniteCache.put(Object, Object)` and similar operations before new value is stored in cache.

      Implementations should not execute any complex logic, including locking, networking or cache operations, as it may lead to deadlock, since this method is called from sensitive synchronization blocks.

      This method should not throw any exception.

      IMPORTANT: for this method to take affect, `newVal` and the returned value have to be different instances. I.e., you should not mutate `newVal` directly, but instead create a copy, update it and then return from the interceptor.

      Specified by:
        `onBeforePut` in interface `CacheInterceptor<K,V>`
      Parameters:
        `entry` - Old entry. If `CacheConfiguration.isCopyOnRead()` is `true`, then is copy.
        `newVal` - New value.
      Returns:
        Value to be put to cache. Returning `null` cancels the update.
      See Also:
        `IgniteCache.put(Object, Object)`

    - #### onAfterPut

          public void onAfterPut(javax.cache.Cache.Entry<K,V> entry)

      This method is called after new value has been stored.

      Implementations should not execute any complex logic, including locking, networking or cache operations, as it may lead to deadlock, since this method is called from sensitive synchronization blocks.

      This method should not throw any exception.

      Specified by:
        `onAfterPut` in interface `CacheInterceptor<K,V>`
      Parameters:
        `entry` - Current entry. If `CacheConfiguration.isCopyOnRead()` is `true` then entry is a copy.

    - #### onBeforeRemove

          @Nullable
          public @Nullable IgniteBiTuple<Boolean,V> onBeforeRemove(javax.cache.Cache.Entry<K,V> entry)

      This method is called within `IgniteCache.remove(Object)` and similar operations to provide control over returned value.

      Implementations should not execute any complex logic, including locking, networking or cache operations, as it may lead to deadlock, since this method is called from sensitive synchronization blocks.

      This method should not throw any exception.

      Specified by:
        `onBeforeRemove` in interface `CacheInterceptor<K,V>`
      Parameters:
        `entry` - Old entry. If `CacheConfiguration.isCopyOnRead()` is `true` then entry is a copy.
      Returns:
        Tuple. The first value is the flag whether remove should be cancelled or not. The second is the value to be returned as result of `remove()` operation, may be `null`.
      See Also:
        `IgniteCache.remove(Object)`

    - #### onAfterRemove

          public void onAfterRemove(javax.cache.Cache.Entry<K,V> entry)

      This method is called after value has been removed.

      Implementations should not execute any complex logic, including locking, networking or cache operations, as it may lead to deadlock, since this method is called from sensitive synchronization blocks.

      This method should not throw any exception.

      Specified by:
        `onAfterRemove` in interface `CacheInterceptor<K,V>`
      Parameters:
        `entry` - Removed entry. If `CacheConfiguration.isCopyOnRead()` is `true` then entry is a copy.

2022 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.12.0
Release Date | : January 10 2022