実装クラスは、ビジネスメソッドによって呼び出される非公開メソッド (IDL に宣言されない) を 持つこともできます。 CORBA テンプレートを使用してサーバープログラムを生成した場合は、 実装クラスを手作業でコーディングする必要があります。
// add code to instantiate your object implementation here
HelloImpl helloServant = new HelloImpl();
orb.connect (/* add your object implementation here */);
orb.connect (helloServant);
System.out.println (orb.object_to_string (/* place your object implementation here */));
System.out.println (orb.object_to_string (helloServant));
String ior = orb.object_to_string (/* place your object implementation here */);
try {
FileWriter file = new java.io.FileWriter("<file_name>");
...
String ior = orb.object_to_string (helloServant);
try {
FileWriter file =
new java.io.FileWriter("helloServant.ior");
...
新しいネーミングコンテキストを作成するには、次の手順を実行します。
小さいダイアログが開きます。
新しいサブノードが、JDK ネームサービスのノードの下に表示されます。 これで、サーバントインスタンスを登録するネーミングコンテキストが作成されました。
この手順で使用した名前は便宜上のものです。内容を示す名前として選択しました。
// paste code retrieved using the Copy Server Code
action (on a context node in the Naming Service Browser)
ペーストしたコードは、ネームサービス、およびネームサービスブラウザで選択したネーミングコンテキストにオブジェクトを登録します。
<name of server>
変数を見つけて、サーバント名を " " で囲んだ文字列で置換します。 <kind of server>
変数を見つけて、サーバーの種類を示す demo
で置換します。
(この名前は便宜上のものであり、アプリケーションを説明する名前として選択しました。)
nc.bind(aName, /* place here name of servant variable */);
hImpl
で置換します。この行は次のようになります。
nc.bind (aName, hImpl);
最後の手順では、サーバーに関連するすべてのクラスを、IDL も含めてコンパイルします。 パッケージのノードを右クリックして、コンテキストメニューから「コンパイル」を選択します。