Configuring the REST gateway with an XML configuration

You can use a wxsRestGateway.properties file to override data grid settings on the client side.

About this task

To override data grid settings on the client side, create an wxsRestGateway.properties file in the REST gateway for WebSphere® Application Server and other WebSphere servers to override default behavior.

Procedure

  1. Create an ObjectGrid configuration file for the client that is similar in structure to the file for the container server.

    Assume that the following XML file was paired with a deployment policy XML file, and these files were used to start a container server.

    companyGridServerSide.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.MyTxCallback" />
                <bean id="ObjectGridEventListener"
                    className="com.company.MyOgEventListener" />
                <backingMap name="Customer"
                    pluginCollectionRef="customerPlugins" />
                <backingMap name="Item" />
                <backingMap name="OrderLine" nearCacheEnabled="true"
                    timeToLive="1600" ttlEvictorType="LAST_ACCESS_TIME" />
                <backingMap name="Order" lockStrategy="PESSIMISTIC"
                    pluginCollectionRef="orderPlugins" />
            </objectGrid>
        </objectGrids>
    
        <backingMapPluginCollections>
            <backingMapPluginCollection id="customerPlugins">
                <bean id="Evictor"
                    className="com.ibm.websphere.objectGrid.plugins.builtins.LRUEvictor" />
                <bean id="MapEventListener"
                    className="com.company.MyMapEventListener" />
            </backingMapPluginCollection>
            <backingMapPluginCollection id="orderPlugins">
                <bean id="MapIndexPlugin"
                    className="com.company.MyMapIndexPlugin" />
            </backingMapPluginCollection>
        </backingMapPluginCollections>
    </objectGridConfig>

    On a container server, the ObjectGrid instance named CompanyGrid behaves as defined by the companyGridServerSide.xml file. By default, the CompanyGrid client has the same settings as the CompanyGrid instance that is running on the server.

    The following ObjectGrid XML file can be used to specify some of the attributes and plug-ins on the CompanyGrid client.

    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="Customer" nearCacheEnabled="true"
                    pluginCollectionRef="customerPlugins" />
                <backingMap name="Item" />
                <backingMap name="OrderLine" nearCacheEnabled="true"
                    timeToLive="800" ttlEvictorType="LAST_ACCESS_TIME" />
                <backingMap name="Order" lockStrategy="PESSIMISTIC"
                    pluginCollectionRef="orderPlugins" />
            </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.
    • The timeToLive attribute of the OrderLine backingMap changed.
    • Although a different lockStrategy attribute is specified, there is no effect because the lockStrategy attribute is not supported for a client override.
  2. Create a wxsRestGateway.properties file.

    In this properties file, specify the client-side data grid configuration file, companyGridClientSide.xml, from step 1. See the following example of a wxsRestGateway.properties file:

    objectGridClientXML=D:\\wxsRestConfig\\companyGridClientSide.xml
  3. In either a stand-alone or WebSphere Application Server configuration, use the system properties, wxs.restgateway.props to specify the wxsRestGateway.properties file; for example:
    -Dwxs.restgateway.props=D:\wxsRestConfig\wxsRestGateway.properties