Previous Table of Contents Next


21.7.3 register_orb_initializer Operation


   To register an ORBInitializer, a new operation is provided: register_orb_initializer. This operation, like ORB_init, is PIDL and is not part of any interface. It resides in the PortableInterceptor module.

   21-54 Common Object Request Broker Architecture (CORBA), v3.0.3 March 2004

   void register_orb_initializer (in ORBInitializer init);

   Each service that implements Interceptors will provide an instance of ORBInitializer. To use a service, an application would first call register_orb_initializer, passing in the service’s ORBInitializer. After this is complete, the application would make an instantiating ORB_init call. (An instantiating ORB_init call is one that produces a new ORB. In other words, one that is not passed the ID of an existing ORB.) This instantiating ORB_init call calls each registered ORBInitializer. The returned ORB will contain any Interceptors that the given service requires.

   register_orb_initializer is a global operation. An ORBInitializer registered at a given point in time will be called by all instantiating ORB_init calls that occur after that point in time. No ORB instantiated before that point in time will be affected by that ORBInitializer. Moreover, if register_orb_initializer is called from within an initializer, the initializer registered by that call will not be called for the ORB currently being initialized. That initializer will only be invoked on an ORB instantiated at a later time.

   21.7.3.1 Mappings of register_orb_initializer

   C++

   The register_orb_initializer method is defined in the PortableInterceptor name space as:

   namespace PortableInterceptor {static void register_orb_initializer (PortableInterceptor::ORBInitializer_ptr init);};

   Java

   The register_orb_initializer operation, since it is global, would break applet security with respect to the ORB. So, in Java, instead of registering ORBInitializers via register_orb_initializer, ORBInitializers are registered via Java ORB properties.

   New Property Set

   The new property names are of the form:

   org.omg.PortableInterceptor.ORBInitializerClass.<Service>

   where <Service> is the string name of a class, which implements

   org.omg.PortableInterceptor.ORBInitializer.

   To avoid name collisions, the reverse DNS name convention should be used. For example, if company X has three initializers, it could define the following properties:

   org.omg.PortableInterceptor.ORBInitializerClass.com.x.Init1org.omg.PortableInterceptor.ORBInitializerClass.com.x.Init2

   org.omg.PortableInterceptor.ORBInitializerClass.com.x.Init3

   During ORB.init, these ORB properties that begin with org.omg.PortableInterceptor.ORBInitializerClass shall be collected, the <Service> portion of each property shall be extracted, an object shall be instantiated with the <Service> string as its class name, and the pre_init and post_init methods shall be called on that object. If there are any exceptions, the ORB shall ignore them and proceed.

   Example

   A client-side logging service written by company X, for example, may have the following ORBInitializer implementation:

   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.}}

   To run a program called MyApp using this logging service, the user could type:

   java-Dorg.omg.PortableInterceptor.ORBInitializerClass.com.x.Logging.LoggingService MyApp

   Ada

   For the Ada mapping, a new child library procedure is defined to register ORBInitializers:

   procedure PortableInterceptor.ORBinitializer.Register(Init: in PortableInterceptor.ORBinitializer.Local_Ref);