Initializing a Component

For each component, you must implement the global function ostcInitialize(), which provides any initialization required before operations can be executed. Typical tasks for ostcInitialize() include opening databases and retrieving database roots.

The Component Server calls ostcInitialize() when the Server first starts up.

Example

void ostcInitialize()
{
      OS_ESTABLISH_FAULT_HANDLER

      _db = os_database::open(dbname,  0, 0664);

      OS_BEGIN_TXN(intialize,0,os_transaction::update)
      {
      // Look up the Account extent root
      os_database_root * root = _db->find_root("Account_root");
      
      ...

      OS_END_TXN(intialize)

      OS_END_FAULT_HANDLER
}

Click here for the example in context.



[previous] [next]