|
|
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
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).
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:
J2SE 1.4 ships with two implementations of the CORBA Naming Service:
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.