Module  java.corba

Interface ORBInitializer

  • All Superinterfaces:
    IDLEntityObjectORBInitializerOperationsSerializable


    public interface ORBInitializer
    extends ORBInitializerOperations, Object, IDLEntity
    方便拦截器注册和ORB初始化。

    拦截器旨在成为ORB服务获得ORB处理的一种手段,有效地成为ORB的一部分。 由于拦截器是ORB的一部分,当ORB.init返回ORB时,拦截器已被注册。 在通过电话ORB.init返回后,拦截器无法在ORB上注册。

    通过注册实现ORBInitializer接口的相关联的ORBInitializer对象来注册拦截器。 当ORB正在初始化时,它将调用每个注册的ORBInitializer ,传递一个用于注册其拦截器的ORBInitInfo对象。

    在Java中注册ORB初始化器

    ORBInitializers通过Java ORB属性注册。

    财产名称的格式如下:

    org.omg.PortableInterceptor.ORBInitializerClass.<Service>
    其中<Service>是实现的类的字符串名称
    org.omg.PortableInterceptor.ORBInitializer
    为避免名称冲突,应使用反向DNS名称约定。 例如,如果X公司有三个初始化器,它可以定义以下属性:
    • org.omg.PortableInterceptor.ORBInitializerClass.com.x.Init1
    • org.omg.PortableInterceptor.ORBInitializerClass.com.x.Init2
    • org.omg.PortableInterceptor.ORBInitializerClass.com.x.Init3
    ORB.init期间,应收集以org.omg.PortableInterceptor.ORBInitializerClass开头的ORB属性,提取每个属性的<Service>部分,对象应以<Service>字符串作为其类别名称进行实例化,并应调用pre_initpost_init方法那个对象。 如果有任何例外,ORB将忽略它们并继续进行。

    例如,由公司X编写的客户端日志记录服务可能具有以下ORBInitializer实现:

       package com.x.logging; import org.omg.PortableInterceptor.Interceptor; import org.omg.PortableInterceptor.ORBInitializer; import org.omg.PortableInterceptor.ORBInitInfo; public class LoggingService implements ORBInitializer { void pre_init( ORBInitInfo info ) { // Instantiate the Logging Service s Interceptor. Interceptor interceptor = new LoggingInterceptor(); // Register the Logging Service s Interceptor. info.add_client_request_interceptor( interceptor ); } void post_init( ORBInitInfo info ) { // This service does not need two init points. } }  
    要使用此日志记录服务运行一个名为MyApp的程序,用户可以键入:
    java -Dorg.omg.PortableInterceptor.ORBInitializerClass.com.x.Logging.LoggingService MyApp

    关于注册拦截器的注意事项

    请求拦截器以每ORB的形式进行注册。

    要实现虚拟的每个对象拦截器,从截取点内查询目标上的策略,以确定它们是否应该做任何工作。

    为了实现虚拟的每个POA拦截器,用不同的ORB实例化每个POA。 虽然拦截器可能被行政命令,但是关于拦截器的注册没有关于秩序的概念。 请求拦截器涉及服务环境。 服务上下文没有任何命令,因此请求拦截器无需订单。 IOR拦截器涉及标记的组件。 标签组件也没有任何命令,因此IOR Interceptor不能有订单。

    注册代码应避免使用ORB(即拨打ORB.init ,提供的orb_id )。 由于在ORB初始化期间发生注册,因此在此ORB处于此状态时调用的结果未定义。

    另请参见:
    ORBInitInfo