What is Client-Server?

For the GPO system it is all about a relationship between different IObjectManagers.

We need to create one IObjectManager to act as the central server.

And then we need to create one or more IObjectManagers that will be clients to the server.

Hooking Up

A common problem in computing is how to connect together this kind of thing. How does the client know how to contact the server?

To address this problem, the Cut The Crap server package includes a LookupServer class.

Despite the name this is not specifically to "Lookup" a "Server", but rather to act as a "Server" where any values can be "LookedUp".

Start The LookupServer

The LookupServer should be started on some known machine, and given a known port to listen to.

java cutthecrap.gpo.server.LookupServer 8045

To shutdown the lookup server open a new console and enter:

java cutthecrap.gpo.server.LookupServer -shutdown 8045

Start the Server

The IObjectManager to act as the server should then be started, and told which LookupServer to register with. The server will store a java object that encapsulates contact details to allow a future client to establish contact.

A utility Control class is provided, it requires an xml description file for the server, for example :

The Control class would then be used as follows :

java cutthecrap.gpo.server.Control -start server.xml

Later on the Control class could be used to stop the server :

java cutthecrap.gpo.server.Control -stop server.xml

Example server description file :

<desc>
  <gpo objectManager="cutthecrap.gpo.server.ObjectManager"
    url="appserver:8045#testServer"
    realOM="cutthecrap.oms.ObjectManager"
    storefile="/ctc/db/testServer.rw"
  />
</desc>

For the above file to be valid the LookupServer should be running on the machine known by appserver and you should be able to "ping" appserver from the machine where the server is running.

Start a Client

The IObjectManager to act as a client is then started, and told which LookupServer to access to find a specified server. The contact details are retrieved, then the client establishes communication with the server.

Example client description file :

<desc>
  <gpo objectManager="cutthecrap.gpo.server.ClientObjectMgr"
    url="appserver:8045#testServer"
  />
</desc>

For the above file to be valid you should be able to "ping" the machine appserver from the machine where the client is running.

The file reference is passed to the standard OMClient constructor :

OMClient client = new OMClient("/ctc/app/client.xml");

This is then used normally to retrieve the IObjectManager reference using the getObjectManager method.