Overview | Package | Class | Tree | Index | Help

Oracle® Coherence Java API Reference
v3.5.3
E15583-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.tangosol.util
Interface MapTrigger

All Superinterfaces:
  java.io.Serializable

All Known Implementing Classes:
  FilterTrigger

    public interface MapTrigger

extends java.io.Serializable

MapTrigger represents a functional agent that allows to validate, reject or modify mutating operations against an underlying map. The trigger operates on an `MapTrigger.Entry` object that represents a pending mutation that is about to be committed to the underlying map. A MapTrigger could be registered with any ObservableMap using the `MapTriggerListener` class:

       NamedCache cache = CacheFactory.getCache(sCacheName);
       MapTrigger trigger = new MyCustomTrigger();
       cache.addMapListener(new MapTriggerListener(trigger));

Note: In a clustered environment, MapTrigger registration process requires triggers to be serializable and providing a non-default implementation of the hashCode() and equals() methods. Failure to do so may result in duplicate registration and a redundant entry processing by equivalent, but "not equal" MapTrigger objects.

Since:
  Coherence 3.4
Author:
  cp/gg 2008.03.11
See Also:
  `FilterTrigger`

Nested Class Summary
`static interface` | `MapTrigger.Entry` A MapTrigger Entry represents a pending change to an Entry that is about to committed to the underlying Map.

Method Summary
`void` | `process(MapTrigger.Entry entry)` This method is called before the result of a mutating operation represented by the specified Entry object is committed into the underlying map.

Method Detail

### process

    void process(MapTrigger.Entry entry)

  This method is called before the result of a mutating operation represented by the specified Entry object is committed into the underlying map.

  An implementation of this method can evaluate the change by analyzing the original and the new value, and can perform any of the following:
  - override the requested change by calling `InvocableMap.Entry.setValue(java.lang.Object)` with a different value;
  - undo the pending change by resetting the entry value to the original value obtained from `MapTrigger.Entry.getOriginalValue()`;
  - remove the entry from the underlying map by calling `InvocableMap.Entry.remove(boolean)`;
  - reject the pending change by throwing a RuntimeException, which will prevent any changes from being committed, and will result in the exception being thrown from the operation that attempted to modify the map; or
  - do nothing, thus allowing the pending change to be committed to the underlying map.

  Parameters:
    `entry` - a `MapTrigger.Entry` object that represents the pending change to be committed to the map, as well as the original state of the Entry

Overview | Package | Class | Tree | Index | Help

Oracle® Coherence Java API Reference
v3.5.3
E15583-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2010, Oracle. All rights reserved.