IBM®
Skip to main content
    Country/region [select]      Terms of use
 
 
    
     Home      Products      Services & solutions      Support & downloads      My account     
 
developerworks > My developerWorks >  Dashboard > WebSphere eXtreme Scale V6.1 User Guide > ... > Programming the ObjectGrid > ObjectGrid core programming API
developerWorks
Log In   View a printable version of the current page.
Overview Connect Spaces Forums Wikis
ObjectGrid core programming API
Added by Chris.D.Johnson, last edited by Chris.D.Johnson on Mar 02, 2009  (view change)
Labels: 
(None)

Getting Started Examples Reference API documentation

See the WebSphere eXtreme Scale Wiki for links to eXtreme Scale Version 7.0 documentation.
If you log in with your developerWorks ID, you can leave comments and feedback for the development team.

With the core API, the fundamental interaction with the ObjectGrid cache can occur, including obtaining an ObjectGrid instance, configuring the ObjectGrid and BackingMap, and so on. The core API is used for non-transactional operations, but might be essential to support transactional operations.

Getting Started

Examples and Tutorials

The following code snippet illustrates how to obtain and configure a local ObjectGrid:

Obtaining and Configuring local ObjectGrid example
// Obtain a local ObjectGrid reference
        // you can create a new ObjectGrid, or get configured ObjectGrid defined in ObjectGrid xml file
        ObjectGridManager objectGridManager = ObjectGridManagerFactory.getObjectGridManager();
        ObjectGrid ivObjectGrid = objectGridManager.createObjectGrid("objectgridName");

        // Add a TransactionCallback into ObjectGrid
        HeapTransactionCallback tcb = new HeapTransactionCallback();
        ivObjectGrid.setTransactionCallback(tcb);

        // Define a BackingMap
        // if the BackingMap is configured in ObjectGrid xml file, you can just get it.
        BackingMap ivBackingMap = ivObjectGrid.defineMap("myMap");

        // Add a Loader into BackingMap
        Loader ivLoader = new HeapCacheLoader();
        ivBackingMap.setLoader(ivLoader);

        // initialize ObjectGrid
        ivObjectGrid.initialize();

        // Obtain a session to be used by the current thread.
        // Session can not be shared by multiple threads
        Session ivSession = ivObjectGrid.getSession();

        // Obtaining ObjectMap from ObjectGrid Session
        ObjectMap objectMap = ivSession.getMap("myMap");

The following code snippet illustrates how to obtain a catalog server-based distributed ObjectGrid:

Obtaining distributed ObjectGrid example
ObjectGridManager ogManager = ObjectGridManagerFactory.getObjectGridManager();

        // Obtain a ClientClusterContext by connecting to a catalog server based distributed ObjectGrid
        // You have to provide a connection end point in the format of hostName:endPointPort
        // The hostName is the machine where the catalog server reside.
        // The endPointPort is the catalog server listening port, the default is 2809.
        ClientClusterContext ivClientClusterContext = ogManager.connect("localhost:2809", null, null);

        // Obtain distributed ObjectGrid via ObjectGridManager by providing a ClientClusterContext
        ObjectGrid ivObjectGrid = ogManager.getObjectGrid(ivClientClusterContext, "objectgridName");

Related Information

Wiki Disclaimer and License
© Copyright IBM Corporation 2007,2009. All Rights Reserved.
Docs BackingMap interface (WebSphere eXtreme Scale V6.1 User Guide)
Docs ObjectGrid interface (WebSphere eXtreme Scale V6.1 User Guide)
Docs ObjectGridManager interface (WebSphere eXtreme Scale V6.1 User Guide)
Docs Obtaining a reference to an ObjectGrid (WebSphere eXtreme Scale V6.1 User Guide)
Docs Session interface (WebSphere eXtreme Scale V6.1 User Guide)
Docs Using Sessions to access data in the grid (WebSphere eXtreme Scale V6.1 User Guide)


 
    About IBM Privacy Contact