Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

J2SE 1.4 breathes new life into the CORBA community, Part 4

Portable interceptors and the Interoperable Naming Service

  • Print
  • Feedback

Page 2 of 5

To see the logging service in action, let's modify Part 1's Hello World example so that it uses the logging service. You won't believe how easy this is. To run the hello server with the logging service installed as an interceptor, use the following command line:

java -Dorg.omg.PortableInterceptor.ORBInitializerClass.hello.LoggingServiceORBInitializer HelloServer -ORBInitialPort 1050 -ORBInitialHost localhost


Note that the only difference from the server command above and Part 1's equivalent command is the presence of a system property org.omg.PortableInterceptor.ORBInitializerClass.hello.LoggingServiceORBInitializer, which causes the ORB runtime to install the logging service as an interceptor.

To run the hello client with the logging service installed as an interceptor, use the following command line:

java -Dorg.omg.PortableInterceptor.ORBInitializerClass.hello.LoggingServiceORBInitializer HelloClient -ORBInitialPort 1050 -ORBInitialHost localhost


Again, the only difference from Part 1's command that runs the client is the presence of system property org.omg.PortableInterceptor.ORBInitializerClass.hello.LoggingServiceORBInitializer.

As you can see, the beauty is that I do not need to change any code in the server, servant, or client programs to enable or disable the installation of interceptors (or in this case, the logging service).

Interoperable Naming Service

Now let's move on to the Interoperable Naming Service (INS). The INS is a URL-based naming system built on top of the CORBA Naming Service with a standardized bootstrap mechanism that lets applications share a common initial naming context. As you already know, the CORBA Naming Service provides a tree-like directory for object references much like a filesystem provides a directory structure for files. Here are some terms related to the naming service that you should know:

  1. Naming context: A naming service-specific object that contains a set of name bindings, in which each name is unique.
  2. Name binding: An association between an object and a name. A name binding is always defined relative to a naming context, with the first name binding defined relative to a root naming context.
  3. Binding a name: The process of associating a name with an object. Name binding is created as a result of binding a name.
  4. Resolving a name: The process of determining the object associated with a name.


J2SE 1.4's implementation of the CORBA Naming Service

J2SE 1.4 ships with two implementations of the CORBA Naming Service:

  1. ORBD (Object Request Broker Daemon): ORBD includes a persistent naming service and a transient naming service. The persistent naming service provides persistence for naming contexts. That means that the information persists across service shutdowns and startups, and is recoverable when a service fails. If ORBD restarts, the persistent naming service restores the naming context graph so the binding of all clients' and servers' names remains intact (persistent).
  2. tnameserv: tnameserv, which applies to the transient naming service only, ships with older JDK versions and is also included in J2SE 1.4 for backward compatibility. A transient naming service retains naming contexts as long as it runs. If the service is interrupted, the naming context graph is lost.


To obtain a reference to your program's naming service, call the resolve_initial_references() method on the ORB instance, passing in NameService as the parameter. If ORBD is running, you will receive a reference to a persistent naming context. Similarly, if tnameserv is running, you will get a reference to a transient naming context. To get a transient naming context with ORBD running, use the service name TNameService instead of NameService. Note that TNameService is a J2SE 1.4-specific service name and is not portable across ORBs.

  • Print
  • Feedback

Resources