Interstage Application Server アプリケーション作成ガイド (イベントサービス編)
目次 索引 前ページ次ページ

第6章 アプリケーションの開発(C++言語)

6.6 コンシューマとサプライヤのオブジェクトリファレンスの獲得

 イベントチャネルに接続する際、自身のオブジェクトを登録します。このオブジェクトの生成方法(コンシューマのオブジェクトの作成例)を以下に示します。

イベントサービスの場合

[Pushモデルのコンシューマのオブジェクト]

  CORBA::ORB_ptr                      orb;
  CORBA::BOA_ptr                      boa;
  CORBA::Repository_ptr               intf_rep;
  CORBA::InterfaceDef_ptr             intf;
  CORBA::ImplementationDef_ptr        impl;
  CORBA::ReferenceData                refid;
  CORBA::Object_ptr                   obj;
  CosEventComm::PushConsumer          my_object;
  
  obj = orb->resolve_initial_references(
          CORBA_ORB_ObjectId_LightInterfaceRepository, env );
  intf_rep = CORBA::Repository::_narrow( obj );
  CORBA::release( obj );
  
  obj = LightIntf->lookup_id(
          _INTF_CosEventComm_PushConsumer, env );
  intf = CORBA::InterfaceDef::_narrow( obj );
  CORBA::release( obj );
  
  obj = boa->create( refid, intf, impl, env );
  my_object = CosEventComm::PushConsumer::_narrow( obj );
  CORBA::release( obj );

ノーティフィケーションサービスの場合

[Mixedモデルのコンシューマのオブジェクト]

  CORBA::ORB_ptr                      orb;
  CORBA::BOA_ptr                      boa;
  CORBA::Repository_ptr               intf_rep;
  CORBA::InterfaceDef_ptr             intf;
  CORBA::ImplementationDef_ptr        impl;
  CORBA::ReferenceData                refid;
  CORBA::Object_ptr                   obj;
  CosNotifyComm::PullConsumer         my_object;
  
  obj = orb->resolve_initial_references(
          CORBA_ORB_ObjectId_LightInterfaceRepository, env );
  intf_rep = CORBA::Repository::_narrow( obj );
  CORBA::release( obj );
  
  obj = LightIntf->lookup_id(
          _INTF_CosEventComm_PullConsumer, env );
  intf = CORBA::InterfaceDef::_narrow( obj );
  CORBA::release( obj );
  
  obj = boa->create( refid, intf, impl, env );
  my_object = CosEventComm::PullConsumer::_narrow( obj );
  CORBA::release( obj );

 オブジェクトはCORBA::BOA::createで作成します。CORBA::BOA::createに指定するパラメタのインタフェースリポジトリIDには自身が実装するインタフェースリポジトリID(イベントサービスの場合は_INTF_CosEventComm_PushConsumer、ノーティフィケーションサービスの場合は_INTF_CosEventComm_PullConsumer)、インプリメンテーション情報には自身のインプリメンテーションリポジトリIDを指定します。
 各アプリケーションが実装するインタフェースを以下の表に示します。アプリケーションはインタフェースリポジトリIDをCORBA::Repository::lookup_idに以下のパラメタを指定して獲得します。

 

通信モデル

サプライヤ

コンシューマ

イベントサービス

Push

_INTF_CosEventComm_PushSupplier

_INTF_CosEventComm_PushConsumer

Pull

_INTF_CosEventComm_PullSupplier

_INTF_CosEventComm_PullConsumer

Mixed

_INTF_CosEventComm_PushSupplier

_INTF_CosEventComm_PullConsumer

ノーティフィケーションサービス

Mixed
(any)

_INTF_CosEventComm_PushSupplier

_INTF_CosEventComm_PullConsumer

Mixed
(StructuredEvent)

_INTF_CosNotifyComm_StructuredPushSupplier

_INTF_CosNotifyComm_StructuredPullConsumer


目次 索引 前ページ次ページ

All Rights Reserved, Copyright(C) 富士通株式会社 2005