Administration guide > Configure the deployment environment > Configuring Spring integration

Start a container server with Spring

You can start a container server using Spring managed extension beans and namespace support.

With several XML files configured for Spring, you can start basic eXtreme Scale container servers.


  1. ObjectGrid XML file:

    First of all, define a very simple ObjectGrid XML file which contains one ObjectGrid "Grid" and one map "Test". The ObjectGrid has an ObjectGridEventListener plug-in called "partitionListener", and the map "Test" has an Evictor plugged in called "testLRUEvictor". Notice both the ObjectGridEventListener plug-in and Evictor plug-in are configured using Spring as their names contain "{spring}".

    <?xml version="1.0" encoding="UTF-8"?>
    <objectGridConfig xmlns:xsi=""
     xsi:schemaLocation=" ../objectGrid.xsd"
    <objectGrid name="Grid">
    <bean id="ObjectGridEventListener" className="{spring}partitionListener" />
    <backingMap name="Test" pluginCollectionRef="test" />
    <backingMapPluginCollection id="test">
    <bean id="Evictor" className="{spring}testLRUEvictor"/>

  2. ObjectGrid deployment XML file:

    Now, create a simple ObjectGrid deployment XML file as follows. It partitions the ObjectGrid into 5 partitions, and no replica is required.

    <?xml version="1.0" encoding="UTF-8"?>
    <deploymentPolicy xmlns:xsi=""
     xsi:schemaLocation=" ../deploymentPolicy.xsd"
    <objectgridDeployment objectgridName="Grid">
    <mapSet name="mapSet" numInitialContainers="1" numberOfPartitions="5" minSyncReplicas="0" 
                maxSyncReplicas="1" maxAsyncReplicas="0">
    <map ref="Test"/>

  3. ObjectGrid Spring XML file:

    Now we will use both ObjectGrid Spring managed extension beans and namespace support features to configure the ObjectGrid beans. The spring xml file is named Grid_spring.xml. Notice two schemas are included in the XML file: spring-beans-2.0.xsd is for using the Spring managed beans, and objectgrid.xsd is for using the beans predefined in the objectgrid namespace.

    <beans xmlns=""
    <objectgrid:register id="ogregister" gridname="Grid"/>
    <objectgrid:server id="server" isCatalog="true" name="server">
    <objectgrid:catalog host="localhost" port="2809"/>
    <objectgrid:container id="container" 
    <objectgrid:LRUEvictor id="testLRUEvictor" numberOfLRUQueues="31"/>
    <bean id="partitionListener" 
                class="" scope="shard"/>

    There were six beans defined in this spring XML file:

    1. objectgrid:register: This register the default bean factory for the ObjectGrid "Grid".

    2. objectgrid:server: This defines an ObjectGrid server with name "server". This server will also provide catalog service since it has an objectgrid:catalog bean nested in it.

    3. objectgrid:catalog: This defines an ObjectGrid catalog service endpoint, which is set to "localhost:2809".

    4. objectgrid:container: This defines an ObjectGrid container with specified objectgrid XML file and deployment XML file as we discussed before. The server property specifies which server this container is hosted in.

    5. objectgrid:LRUEvictor: This defines an LRUEvictor with the number of LRU queues to use set to 31.

    6. bean partitionListener: This defines a ShardListener plug-in. You must provide an implementation for this plug-in, so it cannot use the pre-defined beans. Also this scope of the bean is set to "shard", which means there is only one instance of this ShardListener per ObjectGrid shard.

  4. Start the server:

    The snippet below starts the ObjectGrid server, which hosts both the container service and the catalog service. As we can see, the only method we need to call to start the server is to get a bean "container" from the bean factory. This simplifies the programming complexity by moving most of the logic into Spring configuration.

    public class ShardServer extends TestCase
        Container container;
        org.springframework.beans.factory.BeanFactory bf;
        public void startServer(String cep) 
                bf = new
                    "/com/ibm/ws/objectgrid/test/springshard/Grid_spring.xml", ShardServer.class);
                container = (Container)bf.getBean("container");
            catch(Exception e)
                throw new ObjectGridRuntimeException("Cannot start OG container", e);
        public void stopServer() 
            if(container != null)

Parent topic:

Configure Spring integration

Related concepts

Spring extension beans and namespace support

Related reference

Spring descriptor XML file

Spring objectgrid.xsd file


Search Tips   |   Advanced Search