CARMA connections are established during the creation of
the root node of a CARMA hierarchy.
The root node of a CARMA hierarchy
is a
CARMA object,
which must be configured to use a CARMA transport during creation.
To create a root node for a CARMA hierarchy and configure its CARMA
transport, follow these steps:
- Use the factory class com.ibm.carma.CARMASystemFactory to
create a CARMA object with the getInstance method
as illustrated in the following example code:
String identifier = "ConnectionIdentifier";
Map connectionProperties = new TreeMap();
// insert your code to configure the connection properties here
CARMA carma = CARMASystemFactory.getInstance().getCARMAInstance(identifier, connectionProperties);
The identifier string must be unique to your CARMA hierarchy.
Currently, the only valid transport is the RSE transport service,
which is used by default (if you are using the alternate method call
that requires a backend ID to be specified, you can select the RSE
transport service by passing a backend ID value of "com.ibm.carma.client.rse.datastore").
The
connection properties map stores key-value pairs for transport configuration
options. If the required parameters for the transport you are using
are not specified in the map, the getCARMAInstance method
will throw a CARMAException. The RSE transport service
requires that you specify a value for the key "aliasName" in the connection
properties map. For the value of the key "aliasName", provide a name
for the RSE connection to use when communicating with the CARMA host.
- Store a reference to your CARMA hierarchy for later retrieval
in the CARMA registry:
CarmaRegistry.getRegistry().addCarma(carma);
The singleton CarmaRegistry object
is used by a CARMABrowser object
to maintain a list of known CARMA connections. Events are sent to
registered listeners when objects are added or removed from the CARMA
hierarchy. You can retrieve a CARMA hierarchy from the CARMA registry
by passing its identifier into the getCARMA method
of the CARMA registry.
You can now connect to your CARMA object's
CARMA host by using the connect method.