Oracle9i Application Server Migrating from Oracle Application Server
Release 1 (v1.0.2.2)

Part Number A83709-07

Library

Solution Area

Contents

Index

Go to previous page Go to next page

4
Migrating EJB, ECO/Java and JCORBA Applications

This chapter provides information on migrating EJB, ECO for Java and JCO applications from the Oracle Application Server to Oracle8i JVM EJB objects. Oracle8i JVM is the Oracle9i Application Server component that provides a runtime environment for EnterpriseJava Bean applications. The topics include:

Migrating EJBs

To migrate EJBs from Oracle Application Server 4.0.8 (or later) to Oracle8i JVM, you will need to modify code in the following areas:

The following sections describe these changes.

Deployment Descriptors

Oracle8i JVM allows you to put deployment information in a text file that you can run through the ejbdescriptor command line tool to create the serialized deployment descriptors. The format of this text file resembles Java. The example below shows the basic structure, in which ejb.test.server is the package that contains the implementation of the bean class ExampleBean.

SessionBean ejb.test.server.ExampleBeanImpl
{
   <attribute>=<value>
   ...
}

The required attributes are:

Common additional attributes include:

You can also use this format to set Java environment variables for the bean.


Note:

You can also use serialized deployment descriptors instead of the text file. 


See Also:

Oracle8i Enterprise JavaBeans and CORBA Developer's Guide in the Oracle9i Application Server documentation library 

Client Code

Changes to the client code are made in the initial context call using JNDI. The hashtable passed to the initial context call must contain all of the properties listed in the table below.

Table 4-1 Hashtable Values
Property  Value 

javax.naming.Context.URL_PKG_PREFIXES 

oracle.aurora.jndi 

javax.naming.Context.SECURITY_AUTHORIZATION 

One of:

  • oracle.aurora.sess_iiop.ServiceCtx.NON_SSL_LOGIN

  • oracle.aurora.sess_iiop.ServiceCtx.SSL_CREDENTIAL

  • oracle.aurora.sess_iiop.ServiceCtx.SSL_LOGIN

 

javax.naming.Context.SECURITY_PRINCIPAL 

The database or Oracle Database Cache username, for example, scott

javax.naming.Context.SECURITY_CREDENTIALS 

The user password, for example, tiger

You must also change the URL that accesses your EJB home to the Oracle 8i format of:

sess_iiop://<host>:<port>:<SID>/<path>/<bean>

For example:

sess_iiop://myhost:2481:ORCL/test/myBean

Logging (Server Code)

If application logging was done in Oracle Application Server, remove all references to oracle.oas.ejb.Logger from your EJB code. In Oracle8i JVM, you can use the println function for simple logging, or you can log to the database.

Migrating ECO/Java

When migrating ECO for Java (ECO/Java) to Oracle8i JVM, you can choose between migrating to EJB, or to CORBA. As the ECO model is very similar to EJB, the easiest migration is to EJB. You will need to change server code as described in the sections below in addition to changes for deployment descriptors and client code described in the sections above for EJB migration.

To modify your ECO for Java components to be compatible with Oracle8i JVM EJBs, you must modify the implementation file, the remote interface file, and the home interface file.

Remote Interface

Change the remote interface to extend javax.ejb.EJBObject instead of oracle.oas.eco.ECOObject. Each method must throw java.rmi.RemoteException.

Home Interface

Change the home interface to extend javax.ejb.EJBHome instead of oracle.oas.eco.ECOHome.

The create method must throw javax.ejb.CreateException and java.rmi.RemoteException instead of oracle.oas.eco.CreateException.

Implementation Class

Make the following changes to the implementation class:

  1. Remove all occurrences of, and references to, oracle.oas.eco.Logger.

  2. Change all occurrences of oracle.oas.eco.* to javax.ejb.*.

  3. Change ECOCreate method to ejbCreate method.

  4. Change ECORemove method to ejbRemove method.

  5. Change ECOActivate method to ejbActivate method.

  6. Change ECOPassivate method to ejbPassivate method.

Migrating JCORBA to EJB

Oracle Application Server versions 4.0.6 and 4.0.7 provided a component model called Java CORBA Objects (JCO), a precursor to the ECO for Java (ECO/Java) model. This section discusses migrating from JCO in Oracle Application Server to EJB in Oracle8i JVM.

To migrate to EJB, you must modify the server and client code as discussed in the following sections. To modify the server code, you must modify the remote interface, create a home interface, modify the JCORBA object implementation, and make parameters serializable. You must also modify the deployment descriptors as discussed in "Deployment Descriptors".

Remote Interface

Make the following changes to the remote interface:

  1. Convert all occurrences of org.omg.CORBA.Object or oracle.oas.jco.JCORemote to javax.ejb.EJBObject.

  2. Throw java.rmi.RemoteException for all methods in the interface.

Home Interface

You will need to create a home interface as defined in the EJB specification. An example is shown below.

import javax.ejb.*;
import java.rmi.RemoteException;
public interface ServerStackHome extends EJBHome
{
  public ServerStackRemote create() throws CreateException, RemoteException;
}

Object Implementation

Complete the following to migrate the implementation class:

  1. Change import oracle.oas.jco.* to import javax.ejb.*.

  2. Check that the class implements javax.ejb.SessionBean.


    Note:

    The JCORBA Lifecycle is not supported within EJB; if the JCORBA object implements oracle.oas.jco.Lifecycle, you must remove it.  


  3. Remove any logger references.

  4. Move any initialization operations to the ejbCreate() method.

  5. Save the session context passed into the setSessionContext() method in an instance variable.

  6. Ensure that all public methods in the class throw the java.rmi.RemoteException exception.

  7. Change any ObjectManager type to SessionContext type. The table below maps the methods in the ObjectManager class to methods in the SessionContext class.

    Table 4-2 ObjectManager and SessionContext Methods
    SessionContext Method  ObjectManager Method 

    getEnvironment() 

    getEnvironment() 

    Parameter passed to setSessionContext() 

    getObjectManager() 

    getEJBObject() 

    getSelf() 

    getEJBObject().remove() 

    revokeSelf() 

    getUserTransaction() 

    getCurrentTransaction() 

Make Parameters Serializable

If any user defined parameters are being passed in the remote interface, ensure that the classes implement java.io.Serializable.


Go to previous page Go to next page
Oracle
Copyright © 2001 Oracle Corporation.

All Rights Reserved.

Library

Solution Area

Contents

Index