Initializing the server's ImplementationDef

Next, the server program is responsible for initializing its implementationDef, referred to by the global variable SOMD_ImplDefObject. It is initialized to NULL by SOMD_Init. (For client programs it should be left as NULL.) If the server implementation was registered with the Implementation Repository before the server program was activated (as will be the case for all servers that are activated automatically by somdd), then the ImplementationDef can be retrieved from the Implementation Repository. Otherwise, the server program can register its implementation with the Implementation Repository dynamically (as shown in section 6.6, "Configuring DSOM applications").

The server can retrieve its ImplementationDef from the Implementation Repository by invoking the find_impldef method on SOMD_ImplRepObject. It supplies, as a key, the implementation ID of the desired ImplementationDef.

The following code shows how a server program might initialize the DSOM run-time environment and retrieve its ImplementationDef from the Implementation Repository.

#include <somd.h> /* needed by all servers */
main(int argc, char **argv)
{
   Environment ev;
   SOM_InitEnvironment(&ev);

/* Initialize the DSOM run-time environment */
   SOMD_Init(&ev);

/* Retrieve its ImplementationDef from the Implementation
   Repository by passing its implementation ID as a key */
   SOMD_ImplDefObject =
      _find_impldef(SOMD_ImplRepObject, &ev, argv[1]);
...
}


[Back: Initializing the DSOM run-time environment]
[Next: Initializing the SOM Object Adapter]