ORBInitializerを登録するために,グローバルメソッドであるregister_orb_initializerが提供されています。インタセプタをインプリメントする各サービスは,ORBInitializerのインスタンスを提供します。サービスを使用するために,アプリケーションは次の手順を行います。
新しいプロパティ名の形式を次に示します。
org.omg.PortableInterceptor.ORBInitializerClass.<Service>
ここで<Service>は,org.omg.PortableInterceptor.ORBInitializerをインプリメントするクラスの文字列名です。
ORB.init()メソッドの実行中に行われることを次に示します。
org.omg.PortableInterceptor.ORBInitializerClass.com.abc.ORBInit1
org.omg.PortableInterceptor.ORBInitializerClass.com.abc.ORBInit2
class _VISEXPORT PortableInterceptor {
static void register_orb_initializer(ORBInitializer *init);
}
ABC社が書き込んだクライアント側の監視ツールに,次に示すORBInitializerインプリメンテーションがあるとします。
#include "PortableInterceptor_c.hh"
class MonitoringService:public PortableInterceptor::ORBInitializer
{
void pre_init(ORBInitInfo_ptr _info)
{
//instantiate the service ’s Interceptor.
Interceptor*interceptor =new MonitoringInterceptor();
//register the Monitoring ’s Intereptor.
_info->add_client_request_interceptor(interceptor);
}
void post_init(ORBInitInfo_ptr _info)
{
//This init point is not needed.
}
};
MonitoringService *monitoring_service =new MonitoringService();
PortableInterceptor::register_orb_initializer(monitoring_service);
package com.abc.Monitoring;
import org.omg.PortableInterceptor.Interceptor;
import org.omg.PortableInterceptor.ORBInitializer;
import org.omg.PortableInterceptor.ORBInitInfo;
public class MonitoringService extends org.omg.CORBA.LocalObject
implements org.omg.PortableInterceptor.ORBInitializer
{
void pre_init(ORBInitInfo info)
{
//instantiate the service ’s Interceptor.
Interceptor interceptor =new MonitoringInterceptor();
//register the Monitoring ’s Interceptor.
info.add_client_request_interceptor(interceptor);
}
void post_init(ORBInitInfo info)
{
//This init point is not needed.
}
}
この監視サービスを使用してMyAppと呼ばれるプログラムを実行するために次のコマンドが使用されます。
java -Dorg.omg.PortableInterceptor.ORBInitializerClass.
com.abc.Monitoring.MonitoringService MyApp