These are the main application APIs for the ObjectGrid. The main interface here is the ObjectGrid interface. A JVM needs to create
at least one instance.
Introduction
The WebSphere ObjectGrid is designed as a data caching tier that can be used to hold
data from multiple sources and then make it available to the clients of the ObjectGrid.
The clients access the data through the ObjectGrid APIs. The ObjectGrid is designed to
be able to store large quantities of data.
Programming Tutorial
The following sections show snippets on the usage of the ObjectGrid APIs.
Obtaining a ObjectGrid instance.
The application needs to construct an ObjectGrid reference first. An application can choose
to make several ObjectGrid instances. Each instance is independent, however, and has it's
own configuration file. For now, use the following code and programmatically initialize
it using the setter methods on the ObjectGrid.
ObjectGrid objectGrid = new ObjectGridImpl();
The instance can then have a Map defined on it using the following snippet:
BackingMap bm = objectGrid.defineMap("TABLE1");
Again, setter methods on BackingMap allow it to be configured once it's defined.
Working with an ObjectGrid, Sessions
Each thread that wants to access the ObjectGrid must have its own Session instance. The
ObjectGrid class has a getSession method that returns one. Once the thread has a Session
then it can obtain ObjectMap instances for manipulating data in the ObjectGrid as well as use
the begin/commit/rollback methods on the Session to handle transactions.
Session session = objectGrid.getSession();
ObjectMap table1 = session.getMap("TABLE1");
session.begin();
MyData d = (MyData)table1.get("key1");
session.commit();