In DSOM, the process that manages a target object is called the object's server. Servers are implemented as programs that use SOM classes. Server implementations are registered with DSOM in an Implementation Repository. The Implementation Repository is a database queried by clients in order to find desired servers, and queried by DSOM in order to activate those servers upon demand.
The example above placed no constraints on the DSOM Object Manager as to where the remote "Stack" object should be created. The somdNewObject call creates a remote object of a specified class in an arbitrary server that implements that class. However, the DSOM Object Manager provides methods for finding specific servers.
For example, the client program above can be modified slightly to find a specific server named "StackServer", which has already been registered in DSOM's Implementation Repository. (Note that the programmer knew or discovered that the "StackServer" server implementation supports the "Stack" class.) The highlighted lines below show the changes that were made:
#include <somd.h> #include <stack.h> int main(int argc, char *argv[]) { Stack stk; Environment e; SOMDServer server; SOM_InitEnvironment(&e); SOMD_Init(&e); server = _somdFindServerByName(SOMD_ObjectMgr, &e, "StackServer"); stk = _somdCreateObj(server, &e, "Stack", ""); _push(stk,&e,100); _push(stk,&e,200); _pop(stk,&e); if (!_empty(stk,&e)) somPrintf("Top: %d\n", _top(stk,&e)); _somdDeleteObj(server, &e, stk); _somdReleaseObject(SOMD_ObjectMgr, &e, stk); _somdReleaseObject(SOMD_ObjectMgr, &e, server); SOMD_Uninit(&e); SOM_UninitEnvironment(&e); return(0); }
This version of the program replaces the somdNewObject operation with calls to somdFindServerByName and somdCreateObj. The somdFindServerByName method consults the Implementation Repository to find the DSOM server implementation whose name is "StackServer", and creates a server proxy, which provides a connection to that server. Every DSOM server process has a server object that defines methods to assist in the creation and management of objects in that server. Server objects must be instances of SOMDServer or one of its subclasses. The somdFindServerByName returns a proxy to the SOMDServer object in the named server.
Once the client has the server proxy, it can create and destroy objects in that server. The somdCreateObj call creates an object of the class "Stack" in the server named "StackServer".
To free the remote "Stack" object, the example shows a somdDeleteObj request on the stack object's server. Next, somdReleaseObject requests are made on the DSOM Object Manager, to free the stack proxy and the server proxy in the client. (Note that these three calls are equivalent to the somdDestroyObject call in the previous example.)