com.hazelcast.map
Interface MapInterceptor

All Superinterfaces:
Serializable

public interface MapInterceptor
extends Serializable

MapInterceptor is used to intercept changes to the map, allowing access to the values before and after adding it to the map MapInterceptors are chained when added to the map, which means that when an interceptor is added on node initialization it could be added twice. To prevent this make sure to implement the hashCode method to return the same value for every instance of the class.


Method Summary
 void afterGet(Object value)
          Called after get(..) operation is completed.
 void afterPut(Object value)
          Called after put(..) operation is completed.
 void afterRemove(Object value)
          Called after remove(..) operation is completed.
 Object interceptGet(Object value)
          Intercept get operation before returning value.
 Object interceptPut(Object oldValue, Object newValue)
          Intercept put operation before modifying map data.
 Object interceptRemove(Object removedValue)
          Intercept remove operation before removing the data.
 

Method Detail

interceptGet

Object interceptGet(Object value)
Intercept get operation before returning value. Return another object to change the return value of get(..) Returning null will cause the get(..) operation return original value, namely return null if you do not want to change anything.

Mutations made to value do not affect the stored value. They do affect the returned value.

Parameters:
value - the original value to be returned as the result of get(..) operation
Returns:
the new value that will be returned by get(..) operation

afterGet

void afterGet(Object value)
Called after get(..) operation is completed.

Mutations made to value do not affect the stored value.

Parameters:
value - the value returned as the result of get(..) operation

interceptPut

Object interceptPut(Object oldValue,
                    Object newValue)
Intercept put operation before modifying map data. Return the object to be put into the map. Returning null will cause the put(..) operation to operate as expected, namely no interception. Throwing an exception will cancel the put operation.

Parameters:
oldValue - the value currently in map
newValue - the new value to be put
Returns:
new value after intercept operation

afterPut

void afterPut(Object value)
Called after put(..) operation is completed.

Parameters:
value - the value returned as the result of put(..) operation

interceptRemove

Object interceptRemove(Object removedValue)
Intercept remove operation before removing the data. Return the object to be returned as the result of remove operation. Throwing an exception will cancel the remove operation.

Parameters:
removedValue - the existing value to be removed
Returns:
the value to be returned as the result of remove operation

afterRemove

void afterRemove(Object value)
Called after remove(..) operation is completed.

Parameters:
value - the value returned as the result of remove(..) operation


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.