Interstage Application Server アプリケーション作成ガイド (CORBAサービス編) |
目次
索引
![]() ![]() |
第5章 アプリケーションの開発(C++言語) | > 5.3 サーバアプリケーションのプログラミング(Portable Object Adapter:POA) | > 5.3.6 サーバアプリケーションの実装アプローチ |
継承方式によるServantは、以下のような継承関係となります。サーバアプリケーションのメイン部では、このServantをPOAに登録します。
上図のとおり、継承方式ではServantは以下のようにスケルトンクラスを継承する形式で実装します。
【IDL定義】
module ODsample{ interface intf{ long add(in long a, in long b); }; };
【スケルトン】
class POA_ODsample_intf : public virtual PortableServer::ServantBase { : }; class ODsample_intf_impl : public virtual POA_ODsample_intf{ : CORBA::Long add( CORBA::Long a CORBA::Longint b CORBA::Environment& = CORBA::Environment() ) throw( CORBA::Exception ); : };
【サーバアプリケーションでの実装例】
CORBA::Long ODsample_intf_impl::add{ return( a + b ); }
メイン処理部では、スケルトンクラスをPOAに登録します。以下の例ではDefault Servantとして登録しています。
【メイン部の例】
// Servantの生成 ODsample_intf_impl* svt = new ODsample_intf_impl(); // Default Servantに設定 aPOA->set_servant( svt );
注) aPOAはPOAクラスのインスタンス
目次
索引
![]() ![]() |