Class OortMap<K,V>

Type Parameters:
K - the key type
V - the value type
All Implemented Interfaces:
Iterable<OortObject.Info<ConcurrentMap<K,V>>>, EventListener, ConfigurableServerChannel.Initializer, Oort.CometListener, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.component.LifeCycle
Direct Known Subclasses:
OortLongMap, OortStringMap

public abstract class OortMap<K,V> extends OortContainer<ConcurrentMap<K,V>>

A specialized oort object whose entity is a ConcurrentMap.

OortMap specializes OortObject and allows optimized replication of map entries across the cluster: instead of replicating the whole map, that may be contain a lot of entries, only entries that are modified are replicated.

Applications can use putAndShare(Object, Object, Result) and removeAndShare(Object, Result) to broadcast changes related to single entries, as well as OortObject.setAndShare(Object, Result) to change the whole map.

When a single entry is changed, OortMap.EntryListeners are notified. OortMap.DeltaListener converts whole map updates triggered by OortObject.setAndShare(Object, Result) into events for OortMap.EntryListeners, giving applications a single listener type to implement their business logic.

The type parameter for keys, K, must be a String to be able to use this class as-is, although usage of OortStringMap is preferred. This is due to the fact that a Map<Long,Object> containing an entry {13:"foo"} is serialized in JSON as {"13":"foo"} because JSON field names must always be strings. When deserialized, it is restored as a Map<String,Object>, which is incompatible with the original type parameter for keys. To overcome this issue, subclasses may override OortObject.serialize(Object) and OortObject.deserialize(Object). Method OortObject.serialize(Object) should convert the entity object to a format that retains enough type information for OortObject.deserialize(Object) to convert the JSON-deserialized entity object that has the wrong key type to an entity object that has the right key type, like OortLongMap does.