初期サービスのリスト

この例は、ORBオブジェクトのlist_initial_servicesメソッドおよびresolve_initial_referencesメソッドを使用して、初期参照についてORBを照会する方法を示します。 また、これらのオブジェクトの一部はローカル性が制約されていますが、その他はネットワーク上のいずれかで実行中の適切なCORBAオブジェクトであることもわかります。

初期参照名 リモート 関数
ActivationSystem
yes
サーバ起動機能にアクセスします。
Authenticator
no
認証をサポートします。
CertificateManager
no
SSLの初期化をサポートします。
InitialReferencesService
no
初期オブジェクト参照を取得/設定します。
jBrokerAdmin
yes
リモートモニタ
MulticastCurrent
no
マルチキャスト要求のクライアントを判別します。
NameService
yes
ルートNamingContextオブジェクト
NameServiceFactory
no
インプロセスNameServiceインスタンスを作成します。
POACurrent
no
現在のPOAおよびオブジェクトIDを判別します。
RootPOA
no
POAを使用した最小プログラミング一時的オブジェクトをサポートします。
SecurityCurrent
no
スレッドまたはORBレベル識別を取得/設定します。
TSIdentification
no
ORBで使用するトランザクションサービスを設定します。


1 初期サービス

orb.list_initial_services()メソッドは、すべての初期サービスの名前を返します。 これらの一部はローカル性が制約されたオブジェクトを表し、その他のものはネットワーク上で実行され、ブートストラッププロトコルを使用して取得されます。 ローカル性が制約されたオブジェクトは文字列化またはマーシャルができません。
package listInitial;
                                                                           
import org.omg.CORBA.ORB;
import org.omg.CORBA.Object;
                                                                           
public class Services
{
    public static void main(String[] args)
    {
    |   try {
    |   |                                                                  
    |   |   // create the jBroker ORB
    |   |   ORB orb = ORB.init(args, null);
    |   |                                                                  
    |   |   // get the names of initial services
    |   |   String[] names = orb.list_initial_services();
    |   |                                                                  
    |   |   // print the initial services
    |   |   for (int i=0; i < names.length; i++)
    |   |       System.out.println(names[i] + (isLocalityConstrained(
    |   |           orb, names[i]) ? "" : " (remote)"));
    |   |                                                                  
    |   } catch (Exception ex) {
    |   |   ex.printStackTrace();
    |   }
    }
                                                                           
    // locality constrained objects can not be stringified or marshalled
    static boolean isLocalityConstrained(ORB orb, String name)
    {
    |   try {
    |   |   orb.object_to_string(orb.resolve_initial_references(name));
    |   |   return false;
    |   |                                                                  
    |   } catch (Exception ex) {
    |   |   return true;
    |   }
    }
}
このプログラムが実行されると、次のようなリストが得られます。
ActivationSystem (remote)
jBrokerAdmin (remote)
NameService (remote)
MulticastCurrent
CertificateManager
InitialReferencesService
Authenticator
POACurrent
RootPOA
SecurityCurrent
PolicyCurrent
SessionCurrent
TSIdentification
DynAnyFactory
ORBPolicyManager
NameServiceFactory

Copyright © 2000-2003, Novell, Inc. All rights reserved.