Program guide > Access data with client applications > Cache objects with no relationships involved (ObjectMap API)
ObjectMap and JavaMap
A JavaMap instance is obtained from an ObjectMap object. The JavaMap interface has the same method signatures as ObjectMap, but with different exception handling. JavaMap extends the java.util.Map interface, so all exceptions are instances of the java.lang.RuntimeException class. Because JavaMap extends the java.util.Map interface, it is easy to quickly use WebSphere eXtreme Scale with an existing application that uses a java.util.Map interface for object caching.
Obtain a JavaMap instance
An application gets a JavaMap instance from an ObjectMap object using the ObjectMap.getJavaMap method. The following code snippet demonstrates how to obtain a JavaMap instance.
ObjectGrid objectGrid = ...; BackingMap backingMap = objectGrid.defineMap("mapA"); Session sess = objectGrid.getSession(); ObjectMap objectMap = sess.getMap("mapA"); java.util.Map map = objectMap.getJavaMap(); JavaMap javaMap = (JavaMap) javaMap;A JavaMap is backed by the ObjectMap from which it was obtained. Calling the getJavaMap method multiple times using a particular ObjectMap always returns the same JavaMap instance.
Methods
The JavaMap interface only supports a subset of the methods on the java.util.Map interface. The java.util.Map interface supports the following methods:
All other methods inherited from the java.util.Map interface result in a java.lang.UnsupportedOperationException exception.
- containsKey(java.lang.Object) method
- get(java.lang.Object) method
- put(java.lang.Object, java.lang.Object) method
- putAll(java.util.Map) method
- remove(java.lang.Object) method
- clear()
Parent topic:
Cache objects with no relationships involved (ObjectMap API)
Related concepts
Related reference