Skip Headers
Oracle® Fusion Middleware Programming RMI for Oracle WebLogic Server
12c Release 1 (12.1.1)

Part Number E24389-03
Go to Documentation Home
Go to Table of Contents
Go to Feedback page
Contact Us

Go to previous page
Go to next page
PDF · Mobi · ePub

10 Best Practices for Application Design

This chapter describes recommended design patterns when programming with RMI and RMI over IIOP.

This chapter includes the following sections:

Use java.rmi

Oracle recommends RMI users use java.rmi, see Although the WebLogic API contains the "weblogic.rmi" API, it is deprecated and is only provided as a compatibility API. Other WebLogic APIs provided for compatibility are:

Use PortableRemoteObject

To maintain code portability, always use PortableRemoteObject when casting the home interfaces. For example:

Propshome home = (PropsHome)
ctx.lookup( "Props" ),
PropsHome.class ); 

Use WebLogic Work Areas

A best practice is to use Work Areas:

How to Handle Changes in Security Context

WLS RMI does not carry forward the security context in the stub. The thread that establishes the stub has the right subject in its thread context. If the stub is later used in a different thread or the stub is used after the current thread context has changed as a result of some operations, subsequent calls using the stub may fail with SecurityException. Operations that can change the context of a thread include establishing a new initial context and running WLST programmatically. Thread context changes often surface as cross-domain security issues when using JMS, JTA, and MDBs in multi-domain configurations.

If an RMI stub is going to be used in a different thread, the application can use a JSR-237 work manager to schedule the new thread in the thread context that the stub is created so that the thread context is propagated to the new thread. For cases where this is not possible, or cases where the context of the original thread changes somehow, the application should reestablish the context under which the stub should be invoked with JAAS. The following public APIs can be used to reestablish the security context:

Guidelines on Using the RMI Timeout

This feature provides a work around for legacy systems where the behavior of asynchronous calls is desired but not yet implemented. Oracle recommends legacy systems implement more appropriate technologies if possible, such as:

If you need to use the RMI timeout for a legacy system, review the following guidelines: