ページの先頭行へ戻る
Interstage Application Server アプリケーション作成ガイド(CORBAサービス編)

E.2.1 初期化

  CORBAの初期化メソッドCORBA::ORB_init()を呼び出して、初期化処理を行います。結果として、ORBのオブジェクトリファレンスが返されます。このオブジェクトリファレンスは、以降で呼び出すORBインタフェースを使用する場合に指定します。

  main ( int argc, char *argv[] ) 
  {
      CORBA::ORB_ptr          orb;    // ORBのオブジェクトリファレンス
      CORBA::Environment_ptr  env;    // 例外情報
      int                     current_argc = argc; 

      env = new CORBA::Environment; 
      orb = CORBA::ORB_init( current_argc, argv, FJ_OM_ORBid, *env );

  また、CORBA::ORB::BOA_init()の呼出しにより、基本オブジェクトアダプタの初期化処理を行います。

      CORBA::BOA_ptr  boa;                // BOA用オブジェクトリファレンス  
      boa = orb->BOA_init( current_argc, argv, CORBA_BOA_OAid, *env );

  また、セション継続用のオブジェクトリファレンスの生成処理のため、CORBA::Repository::lookup_id()の呼出しにより、セション継続用インタフェースのオブジェクトリファレンスを取得します。

  CORBA::InterfaceDef_ptr      intf;     // インタフェース情報検索用
  CORBA::Repository_ptr        intf_rep; // Repositoryオブジェクトリファレンス
  CORBA::Object_ptr            o;        // オブジェクトリファレンスのポインタ

  // インタフェース情報のオブジェクトリファレンス検索
  o = orb->resolve_initial_references(
      CORBA_ORB_ObjectId_LightInterfaceRepository, *env );

  // CORBA::Repositoryクラスへの変換
  intf_rep = CORBA::Repository::_narrow(o); 

  // セション継続用のインタフェースオブジェクトの検索
  o = intf_rep->lookup_id( _INTF_ODsample_ssnintf, *env );

  // CORBA::InterfaceDefクラスへの変換
  intf = CORBA::InterfaceDef::_narrow(o); 

  なお、必要であればサーバアプリケーションの初期化処理も行います。