[Java programming language only]

Configuring Java clients with an XML configuration

You can use an ObjectGrid configuration XML file to override settings on the client side.

About this task

To change the settings on a WebSphere® eXtreme Scale client, create an ObjectGrid XML file.

For a list of the plug-ins and attributes that you can override on the client, see Java client overrides.

Procedure

  1. Create an ObjectGrid configuration XML file for the client.

    The client-side configuration file must specify either the default map name that corresponds to your data grid name or one of the template map names. For more information about the template map names, see Dynamic map configuration options.

    companyGridClientSide.xml
    
    <?xml version="1.0" encoding="UTF-8"?>
    <objectGridConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://ibm.com/ws/objectgrid/config ../objectGrid.xsd"
        xmlns="http://ibm.com/ws/objectgrid/config">
    
        <objectGrids>
            <objectGrid name="CompanyGrid">
                <bean id="TransactionCallback"
                    className="com.company.MyClientTxCallback" />
                <bean id="ObjectGridEventListener" className="" />
                <backingMap name=".*\.NONE\.NCI" nearCacheEnabled="true"                 
                     pluginCollectionRef="customerPlugins" />                    
            </objectGrid>
        </objectGrids>
    
        <backingMapPluginCollections>
            <backingMapPluginCollection id="customerPlugins">
                <bean id="Evictor"
                    className="com.ibm.websphere.objectGrid.plugins.builtins.LRUEvictor" />
                <bean id="MapEventListener" className="" />
            </backingMapPluginCollection>
            <backingMapPluginCollection id="orderPlugins">
                <bean id="MapIndexPlugin"
                    className="com.company.MyMapIndexPlugin" />
            </backingMapPluginCollection>
        </backingMapPluginCollections>
    </objectGridConfig>
    The XML file defines the following overrides:
    • The TransactionCallback bean on the client is com.company.MyClientTxCallback instead of the server-side setting of com.company.MyTxCallback.
    • The client does not have an ObjectGridEventListener plug-in because the className value is the empty string.
    • The client enables a near cache for the Customer backingMap, retains its Evictor plug-in, and removes the MapEventListener plug-in.
    • Although a different lockStrategy attribute is specified, there is no effect because the lockStrategy attribute is not supported for a client override.
  2. Create the client with the XML file.

    To create the CompanyGrid client with the companyGridClientSide.xml file, pass the ObjectGrid XML file as a URL to one of the connect methods on the ObjectGridManager interface:

    ObjectGridManager ogManager = 
    	ObjectGridManagerFactory.ObjectGridManager();
    ClientClusterContext clientClusterContext = 
    	ogManager.connect("MyServer1.company.com:2809", null, new URL(
                    "file:xml/companyGridClientSide.xml"));