next_inactive up previous

ServiceOptions: Programming Guide



ServiceOptions is a component for handling of typical command options of CORBA Service-like program.

What it mean: usual CORBA Service export to "world" few objects: so called "Root Objects" of the service. For example, Collecion Service exports CollectionFactory and RACollectionFactory ; NamingService exports RootNamingContext. Service users obtaine access to such services via propierty mechanizme of ORB.

For standart CORBA services this is call of ORB::resolve_initial_references(name); but process of setting initial references in ORB with -ORBIntRef option require knowing IOR-s of using objects during start of the program.

Usually, "root objects" of the service are exported by

What do ServiceOptions: It's incapsulate all this work in one method call. I. e. you just point to serlet and name; after this you object is accessible via corbaloc-style IOR and optionally is published in other ways, depends from command line options of you server.

ServiceOptions is based on ProgOptions

This document is an unformal description, for full specification, please, use API reference

General Description

Programmer must perform the next steps:

  1. Create object of type ServiceOptions.
  2. Set names for provided CORBA objects by calling ServiceOptions::putServiceName
  3. Call ServiceOptions::parse for parsing options (options --help and --config <filename>, if exist, will be handled, see ProgOptions ProgrammingGuide for detail)
  4. After creating root objects call method ServiceOptions::bindServiceObject
In result, root object references will be accessible via corbaloc-style URL (corbaloc::host:port/Name) and program will understood next options: in addition to common ORB options.

Trivial example

Trivial example which illustrate ServiceOptions usage is follow:


Once the following IDL-interface exist:

interface HelloWorlder
  void hello_world();


Then we can write next programm:

#include <tao/CORBA.h>                          //
#include <tao/PortableServer/PortableServer.h>  // for TAO-1.2
#include <orbsvcs/CosNamingC.h>                 //
#include <HelloWorlderS.h>                      //

#include <iostream>
using namespace std;

#include <GradSoft/ServiceOptions.h>  // do'nt forget
using namespace GradSoft;             //

class HelloWorlder_impl:public POA_HelloWorlder           // interface
{                                                         // implementation
public:                                                   //
  void hello_world() { cout << "Hello, world" << endl; }  //
};                                                        //

int main(int argc, char** argv)
 ServiceOptions options;
 options.putServiceName("HelloService");   // set service name
 if (!options.parse(argc,argv)) return 1;  // parse options set

// use copy of ServiceOptions's internal (argument count,argument vector) pair
// to make it possible
// ORB_init() takes comand-line options in ProgOptions config file:

 ProgOptions::ArgsHolder argsHolder;
 CORBA::ORB_var orb = CORBA::ORB_init(argsHolder.argc,argsHolder.argv);

 CORBA::Object_var poaObj =                                             // standard
     orb->resolve_initial_references("RootPOA");                        // steps
 PortableServer::POA_var poa = PortableServer::POA::_narrow(poaObj);    //
 PortableServer::POAManager_var poaManager = poa->the_POAManager();     //
 poaManager->activate();                                                //

 HelloWorlder_impl helloWorlder_impl;   // create object

 HelloWorlder_var helloWorlder = helloWorlder_impl._this();

 options.bindServiceObject(     // principal call

 return 0;

This program handle next options:

  1. --with-naming, --ior-stdout, --ior-file-myName as it was described above;
  2. --help --config as it was described in Programming guide for ProgOptions package;
  3. current ORB options.

Programming Environment Conventions

  1. ProgOptions Programming Environment Conventions must be set. (see ProgOptions Programming Guide)
  2. Using ServiceOptions with TAO-1.2, you must to include header file PortableServer.h before including of ServiceOptions.h.


- example modified: run ORB_init with copy of argument vector obtained by using getArgsHolder() is accepted
- example verified
- touch before 1.4.0 public release.
- review, added formal document attributes.
- initial revision.

next_inactive up previous