There are a number of ways that you can initialize a GPO system.
To get started with GPO you need to get access to an IObjectManager,
and there are a number of implementations.
The reason for the different implementations is that, depending on what kind of store
they utilise, a few aspects of their behaviour has to be implemented differently. But all
Object Managers inherit 99% of their behaviour from a common base class.
Rather than creating specific Object Managers directly, a utility class is
used - OMClient.
import cutthecrap.gpo.client.OMClient; OMClient client = new OMClient(); IObjectManager om = client.getObjectManager();
The default OMClient object will create and return a TransientObjectMgr.
It is Transient because it does not interface with a persistent IStore
implementation, but is completely in-memory.
A TransientObjectMgr can however export and import portable
external representations of the objects at any time.
import cutthecrap.gpo.client.OMClient;
OMClient client = new OMClient(
"cutthecrap.oms.ObjectManager",
"/ctc/db/mystore.rw" );
IObjectManager om = client.getObjectManager();
This 2 argument form of the OMClient constructor specify the class
of the Object Manager and the name of the store file to be used.
If the first argument is "" or null then the class cutthecrap.oms.ObjectManager
is assumed.
The write-once manager class is cutthecrap.oms.worm.ObjectManager.
import cutthecrap.gpo.client.OMClient; OMClient client = new OMClient(true); IObjectManager om = client.getObjectManager();
or
import cutthecrap.gpo.client.OMClient;
OMClient client = new OMClient(
"cutthecrap.oms.ObjectManager",
true );
IObjectManager om = client.getObjectManager();
This 2 argument form of the OMClient constructor specify the class
of the Object Manager and indicates whether a temporary file should be used.
This is the recommended method, since it is easy to modify the file without any system rebuild.
Here is an example file :
<desc>
<gpo objectmanager="cutthecrap.oms.ObjectManager"
storefile="/ctc/db/testDesc.rw"/>
</desc>
Since xml processing is CasE senSitive, all tags and attributes
are 'lower case' to avoid any confusion.
If this file was called "/ctc/desc/test.xml" it would be used as follows :
OMClient client = new OMClient("/ctc/desc/test.xml");
IObjectManager om = client.getObjectManager();
It is strongly recommended that you use this initialization method.