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

|
6.5 イベントチャネルのオブジェクトリファレンスの獲得
イベントチャネルのメソッドを呼び出すために、アプリケーションはイベントチャネルのオブジェクトリファレンスを獲得します。イベントチャネルのオブジェクトリファレンスは静的生成と動的生成により獲得の方法が異なります。
- 静的生成
- イベントチャネル生成コマンド(esmkchnlコマンド)によりオブジェクトリファレンスがネーミングサービスに登録されています。アプリケーションからネーミングサービスを使用して獲得します。
- 動的生成(イベントサービスの場合)
- イベントファクトリのcreateメソッドの復帰値としてオブジェクトリファレンスを獲得します。
- 動的生成(ノーティフィケーションサービスの場合)
- イベントチャネルを新規に生成する場合は、イベントファクトリのcreate_channelメソッドの復帰値としてオブジェクトリファレンスを獲得します。すでに生成されている場合は、イベントファクトリのget_event_channelメソッドの復帰値としてオブジェクトリファレンスを獲得します。
静的生成によりネーミングサービスに格納されているオブジェクトリファレンスの獲得の例を図に示します。アプリケーションはネーミングサービスにチャネル名を問い合わせ、イベントチャネルを獲得します。例ではネーミングサービスから登録名「Group::Channel」のオブジェクトリファレンスを獲得します。
イベントサービスの場合
CORBA::Environment env;
CosNaming::NamingContext_ptr naming_context;
CosNaming::Name_ptr name;
CosNaming::NameComponent_var *name_component;
CosEventChannelAdmin::EventChannel_ptr event_ch;
try {
name_component = CosNaming::Name::allocbuf( 1 );
name_component[0]->id = (const CORBA::Char *)"Group::Channel";
name_component[0]->kind = (const CORBA::Char *)"";
name = new CosNaming::Name( 1, 1, name_component, CORBA_TRUE );
obj = naming_context->resolve( *name, env );
event_ch = CosEventChannelAdmin::EventChannel::_narrow( obj );
CORBA::release( obj );
} catch( CORBA::Exception &e ) {
...
}
ノーティフィケーションサービスの場合
CORBA::Environment env;
CosNaming::NamingContext_ptr naming_context;
CosNaming::Name_ptr name;
CosNaming::NameComponent_var *name_component;
CosNotifyChannelAdmin::EventChannel_ptr event_ch;
try {
name_component = CosNaming::Name::allocbuf( 1 );
name_component[0]->id = (const CORBA::Char *)"Group::Channel";
name_component[0]->kind = (const CORBA::Char *)"";
name = new CosNaming::Name( 1, 1, name_component, CORBA_TRUE );
obj = naming_context->resolve( *name, env );
event_ch = CosNotifyChannelAdmin::EventChannel::_narrow( obj );
CORBA::release( obj );
} catch( CORBA::Exception &e ) {
...
}
All Rights Reserved, Copyright(C) 富士通株式会社 2005