Class OortMap<K,​V>

java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.cometd.oort.OortObject<T>
org.cometd.oort.OortContainer<ConcurrentMap<K,​V>>
org.cometd.oort.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.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&lt;Long,Object&gt; 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&lt;String,Object&gt;, 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.