Migrating enterprise bean code from Version 1.0 to Version 1.1

Migrating enterprise bean code from Version 1.0 to Version 1.1

The following information generally applies to any enterprise bean that currently complies with Version 1.0 of the EJB specification.

Why and when to perform this task

For more information about migrating code for beans produced with Rational Application Developer, see the documentation for that product. For more information about migrating code in general, see Enterprise beans: Resources for learning.

  1. In session beans, replace all uses of javax.jts.UserTransaction with javax.transaction.UserTransaction. Entity beans may no longer use the UserTransaction interface at all.

  2. In finder methods for entity beans, include FinderException in the throws clause.

  3. Remove throws of java.rmi.RemoteException; throw javax.ejb.EJBException instead. However, continue to include RemoteException in the throws clause of home and remote interfaces as required by the use of Remote Method Invocation (RMI).

  4. Remove uses of the finalize() method.

  5. Replace calls to getCallerIdentity() with calls to getCallerPrincipal(). The use of getCallerIdentity() is deprecated.

  6. Replace calls to isCallerInRole(Identity) with calls to isCallerinRole (String). The use of isCallerInRole(Identity) and java.security.Identity is deprecated.

  7. Replace calls to getEnvironment() in favor of JNDI lookup. As an example, change the following code:
    String homeName =
       aLink.getEntityContext().getEnvironment().getProperty("TARGET_HOME_NAME");
    if (homeName == null) homeName = "TARGET_HOME_NAME";
    The updated code would look something like the following:
    Context env = (Context)(new InitialContext()).lookup("java:comp/env");
    String homeName = (String)env.lookup("ejb10-properties/TARGET_HOME_NAME");
    

  8. In ejbCreate methods for an entity bean with container-managed persistence (CMP), return the bean's primary key class instead of void .

  9. Add the getHomeHandle() method to home interfaces.
    public javax.ejb.HomeHandle getHomeHandle() {return null;}

 

What to do next

Consider enhancements to match the following changes in the specification:




Related tasks
Task overview: Using enterprise beans in applications

Related reference
Enterprise beans: Resources