Oracle8i CORBA Developer's Guide and Reference Release 3 (8.1.7) Part Number A83722-01 |
Library | Service | Contents | Index

## Migrating from JDK 1.1 to Java 2

Oracle8i JServer updated its ORB implementation to Visibroker 3.4, which is compatible with both JDK 1.1 and Java 2.

Note: All existing CORBA applications must regenerate their stubs and skeletons to work with 8.1.6. You must use the 8.1.6 tools when regenerating code from an IDL file.

Sun Microsystems's Java 2 contains an OMG CORBA implementation; JDK 1.1 did not contain an OMG CORBA implementation. Thus, when you imported the Inprise libraries and invoked the CORBA methods, it always invoked the Visibroker implementation. With the implementation being contained in Java 2, if you invoke the CORBA methods without any modifications--as discussed below--you will invoke the Sun Microsystems CORBA implementation, which can cause unexpected results.

The following lists the three methods for initializing the ORB on the client-side and recommendations for bypassing the Sun Microsystems CORBA implementation:

- JNDI Lookup--The setup for the lookup method is the same for both JDK 1.1 and Java 2. However, you must regenerate the stubs and skeletons.

- Aurora ORB Interface--The Aurora ORB provides an interface for initializing the ORB. If you do not use JNDI, your client initializes an ORB on its node to communicate with the ORB in the database. You can use an Aurora ORB on your client through this class.

- CORBA ORB Interface--If you want to use OMG's CORBA ORB interface, you must set a few properties to ensure you are accessing the correct implementation. If you do not wish to use the Aurora ORB on your client, you can use the pure CORBA interfaces. However, you must set up your environment to direct your calls to the correct implementation.

#### JNDI Lookup

If you are using JNDI on the client to access CORBA objects that reside in the server, no code changes are necessary. However, you must regenerate your CORBA stubs and skeletons.

#### Aurora ORB Interface

If your client environment uses JDK 1.1, you do not need to change your existing code. However, you must regenerate your stubs and skeletons.

If your client environment has been upgraded to Java 2, you can initialize the ORB through the `oracle.aurora.jndi.orb_dep.Orb.init` method. This method guarantees that when you initialize the ORB, it will initialize only a single ORB instance. That is, if you use the Java 2 ORB interface, it returns a new ORB instance each time you invoke the `init` method. Aurora's `init` method initializes a singleton ORB instance. Each successive call to `init` returns an object reference to the existing ORB instance.

In addition, the Aurora ORB interface manages the session-based IIOP connection.

##### oracle.aurora.jndi.orb_dep.Orb Class

There are several `init` methods, each with a different parameter list. The following describes the syntax and parameters for each `init` method.

Note: The returned class for each `init` method is different. You can safely cast the `org.omg.CORBA.ORB` class to `com.visigenic.vbroker.orb.ORB`.

#### No Parameters

If you execute the `ORB.init` method that takes no parameters, it does the following:

- If no ORB instance exists, it creates an ORB instance and returns its reference to you.

- If an ORB instance exists, it returns the ORB reference to you.

##### Syntax

    public com.visigenic.vbroker.orb.ORB init();

#### Providing ORB Properties

If you execute the `ORB.init` method that takes the ORB properties as the only parameter, it does the following:

- If no ORB instance exists, it creates an ORB instance, taking into account the properties argument, and returns its reference to you.

- If an ORB instance exists, it returns the ORB reference to you.

##### Syntax

    public org.omg.CORBA.ORB init(Properties props);

#### Providing Input Arguments and ORB Properties

If you execute the `ORB.init` method that takes the ORB properties and ORB command-line arguments, it always creates an ORB instance and returns the reference to you.

##### Syntax

    public org.omg.CORBA.ORB init(String[] args, Properties props);

Parameter | Description
--- | ---
Properties props | ORB system properties.
String[] args | Arguments that are passed to the ORB instance.

#### Example 5-2 Using Aurora ORB init method

The following example shows a client instantiating an ORB using the Aurora Orb class.

    // Create the client object and publish it to the orb in the client
    // Substitute Aurora's Orb.init for OMG ORB.init call
    // old way: org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init ();
    com.visigenic.vbroker.orb.ORB orb = oracle.aurora.jndi.orb_dep.Orb.init();

#### Providing ORB Properties with Username, Password, and Role

If you execute the `ORB.init` method that provides the ORB properties, username, password, and role as parameters, it does the following:

- If no ORB instance exists, it creates an ORB instance and returns its reference to you.

- If an ORB instance exists, it returns the ORB reference to you.

You would use this method when your client chooses to not use JNDI for ORB initialization and it receives a reference to an existing object from another client. To access an active object within a session, the new client must authenticate itself to the database in one of two ways:

- If SSL_CREDENTIALS is requested, provide the username, password, and role in the `init` method parameters. Then, when you invoke a method on the supplied object reference, the username, password, and role are passed implicitly on the first message to authenticate the client to the database.

- If the login protocol is requested, through either SSL_LOGIN or NON_SSL_LOGIN, the first client must pass object references to both the login object and the destination object. The second client authenticates itself by providing the username, password, and role on the `authenticate` method of the login object. Then, it executes any method on the object.

This method is how a second client invokes an active object in an established session.

##### Syntax

    public org.omg.CORBA.ORB init(String un, String pw, String role,
    	boolean ssl, java.util.Properties props);

Parameter | Description
--- | ---
String un | The username for client-side authentication.
String pw | The password for client-side authentication.
String role | The role to use after logging on.
Boolean ssl | If true, SSL is enabled for the connection. If false, a NON-SSL connection is used.
Properties props | Properties that are used by the ORB.

#### CORBA ORB Interface

If you have implemented a pure CORBA client--that is, you do not use JNDI--you must set the following properties before the ORB initialization call. These properties direct the call to the Aurora implementation, rather than the Java 2 implementation. This ensures the behavior that you expect. The behavior expected from Visibroker is as follows:

- Even if you invoke `ORB.init` more than once, JServer creates only a single ORB instance. If you do not set these properties, be aware that each invocation of `ORB.init` will create a new ORB instance.

- The session IIOP connection is managed correctly.

- Callbacks from the server are managed correctly.

  Property | Assign Value
  --- | ---
  org.omg.corba.ORBClass | com.visigenic.vbroker.orb
  org.omg.corba.ORBSingletonClass | com.visigenic.vbroker.orb

#### Example 5-3 Assigning Visibroker values to OMG properties

The following example shows how to set up the OMG properties for directing the OMG CORBA `init` method to the Visibroker implementation.

    System.getProperties().put("org.omg.CORBA.ORBClass",

    	"com.visigenic.vbroker.orb.ORB");
    System.getProperties().put("org.omg.CORBA.ORBSingletonClass",

    	"com.visigenic.vbroker.orb.ORB");

Or you can set the properties on the command line, as follows:

    java -Dorg.omg.CORBA.ORBClass=com.visigenic.vbroker.orb.ORB

    	-Dorg.omg.CORBA.ORBSingletonClass=com.visigenic.vbroker.orb.ORB

#### Backwards Compatibility with 8.1.5

The tools provided with Oracle8i, such as `publish`, have been modified to work with either a JDK 1.1 or Java 2 environment. However, any code that has been generated or loaded with the 8.1.5 version of any tool, will not succeed. Make sure that you always use the 8.1.6 version of all tools. This rule applies to your CORBA stubs and skeletons. You must regenerate all stubs and skeletons with the 8.1.6 IDL compiler.

| Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
Library | Service | Contents | Index