Before a Java program can use CORBA objects, it must initialize itself as follows:
Before it can create or invoke a CORBA object, an applet or application must first create an ORB object. Doing so introduces the applet or application to the ORB and obtains access to important operations that are defined on the ORB object.
Applets and applications create ORB instances slightly differently, because their parameters, which must be passed in the ORB.init() call, are arranged differently.
This fragment shows how an application might create an ORB:
import org.omg.CORBA.ORB; public static void main(String args[]) { try{ ORB orb = ORB.init(args, null);
An applet creates an ORB like this:
import org.omg.CORBA.ORB; public void init() { try { ORB orb = ORB.init(this, null);
The first argument to ORB.init(), which is required, gives the ORB access to the application's or applet's parameters. The second argument to ORB.init() is a java.util.Properties object, which may be null. The init() operation uses these parameters, as well as the System Properties object, to obtain information it needs to configure the ORB.
The init() operation searches for ORB configuration properties in the following places and order:
The first value found for a particular property is the value the init() operation uses. If a configuration property can't be found in any of these places, the init() operation assumes an implementation-specific value for it. For maximum portability among ORB implementations, applets and applications should explicitly specify configuration property values that affect their operation, rather than relying on the assumptions of the ORB they happen to be running in.
With respect to the System Properties object, note that Sun's Java virtual machine adds -D command line arguments to the System Properties object. Other Java virtual machines may or may not do the same.
Currently, the following configuration property is defined for all ORB implementations:
com.sun.CORBA.iiop.ORB orb = com.sun.CORBA.iiop.ORB.init(args, props);
In addition to the standard property listed above, Java IDL supports the following properties:
-ORBInitialPort 800
Applet parameters should specify the full property names. The conventions for applications differ from applets so as not to expose language-specific details in command-line invocations.
To invoke a CORBA object, an applet or application must have a reference for it. There are three ways to get a reference for a CORBA object:
The first technique, converting a stringified reference to an actual object reference, is ORB-implementation-independent: No matter what Java ORB an applet or application runs on, it can convert a stringified object reference. However, it's up to the applet or application developer to:
The following fragment shows how a CORBA object reference can be made into a string and vice versa:
org.omg.CORBA.Object obj = // Set the reference ... String stringifiedRef = ORB.object_to_string(obj); obj = ORB.string_to_object(stringifiedRef);
If you don't use a stringified reference to get an initial CORBA object, you use the ORB itself to produce an initial object reference. However, doing so may make your applet or application ORB-dependent, because, although the CORBA specification defines the interface for getting initial object references, it doesn't yet provide enough information for ORB vendors to implement it in a standard way. Applet and application developers should therefore be cautious when using this operation until the standard is more tightly specified. To guarantee ORB-implementation-independence, use the stringified object reference technique instead.
The ORB pseudo-object interface defines an operation called resolve_initial_reference() that is intended for bootstrapping object references into a newly started application or applet. The operation takes a string argument that names one of a few recognized objects; it returns a CORBA Object, which must be narrowed to the type the applet or application knows it to be. Two string values are presently defined:
The Java IDL implementation of resolve_initial_reference() requires an already-running naming service whose host and port are identified by the ORBInitialHost and ORBInitialPort properties described previously, or by their default values. See The JavaIDL Name Server for details on starting the Java IDL name server.
Copyright © 1996,1997 Sun Microsystems, Inc., 2550 Garcia Ave., Mtn. View, CA. 94043-1100 USA., All rights reserved.