Adding Operations to a Server Session

For each component you must implement the global function ostcConnect(). Use the operation subtype constructors to construct each operation the component supports. Use ostc_ServerSession::addOperation() to register each operation. The Component Server calls ostcConnect() after ostcInitialize(), when the Server first starts up.

Note that for every Server running a given service, you must register every operation the service supports, even if the operation has a different transaction type from that of the Server. Note also that for each type of transaction used by operations in a given service, you must start at least one Server running the service and using that transaction type.

Example

void ostcConnect(ostc_ServerSession * session)
{
      session->addOperation(new txfer_operation());
      session->addOperation(new AddAccount());
      session->addOperation(new withdraw());
      session->addOperation(new deposit());
      session->addOperation(new balance());
}

txfer_operation() is a call to the operation subtype constructor for the operation being specified. You pass a pointer to an instance of the class. Include one call to addOperation() for each operation you want the component to support.

Click here for the example in context.

Declaration of Global Functions

A source or header file for your component must include the following declaration of the global functions you are responsible for implementing (including ostcConnect()):

extern "C" { 

#ifdef WIN32
__declspec( dllexport )  void ostcInitialize();
__declspec( dllexport )  void ostcConnect(ostc_ServerSession *);
__declspec( dllexport )  void ostcDisconnect(void);
#else
void ostcInitialize();
void ostcConnect(ostc_ServerSession *);
void ostcDisconnect(void);
#endif
}

Note that you must use C linkage when declaring these functions..

This use of _declspec is required for Windows platforms.



[previous] [next]