BEA Logo BEA WebLogic Enterprise Release 5.0

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy

 

   WLE Doc Home   |   idltojava Compiler and Related Topics   |   Previous   |   Next   |   Contents   |   Index

Java IDL Examples

This topic includes the following sections:

Getting Started with a Simple Example of IDL

Listing 3-1 shows the OMG IDL to describe a CORBA object whose operations to_lower() and to_upper() each return a single string in which the letter case of the user input is changed accordingly. (Uppercase input is changed to lowercase, and vice-versa.)

Listing 3-1 IDL Interface for the WLE Java Simpapp Sample Application


#pragma prefix "beasys.com"

interface Simple
{
//Convert a string to lower case (return a new string)
string to_lower(in string val);

//Convert a string to upper case (in place)
void to_upper(inout string val);
};

interface SimpleFactory
{
Simple find_simple();
};


If you were implementing this application from scratch, you would compile this IDL interface with the following command:

m3idltojava Simple.idl

This would generate stubs and skeletons and several other files.

For comprehensive information on how to create the Java server and client for this example, along with instructions on how to build and run it, see The Java Simpapp Sample Application in the Guide to the Java Sample Applications in the WebLogic Enterprise online documentation.

For information on the options and flags on the idltojava compiler, refer to the topic Using the idltojava Command.

Callback Objects IDL Example

Listing 3-2 shows the OMG IDL to define the Callback, Simple, and SimpleFactory interfaces in the WebLogic Enterprise (WLE) Callback sample application.

Listing 3-2 IDL Definition for the WLE Callback Sample Application


#pragma prefix "beasys.com"

interface Callback

//This method prints the passed data in uppercase and lowercase
//letters.
{
void print_converted(in string message);
};

interface Simple

//Call the callback object in the joint client/server application
{
void call_callback(in string val, in Callback

callback_ref);
};

interface SimpleFactory
{
Simple find_simple();
};


For a complete explanation of the Java CORBA callbacks example as well as information on how to build and run the example, see Developing Java Joint Client/Server Applications in CORBA Server-to-Server Communication in the WebLogic Enterprise online documentation.

Persistent State and User Exceptions IDL Example

The WLE SimpApp example shows support of transient object references in WLE. If the object's server process stops and restarts, the object reference that the client is holding becomes invalid. However, Java CORBA clients can also create persistent object references in WLE; that is, references that remain valid even if the WLE server is stopped and restarted.

The BEA WLE system supports persistent objects by means of callbacks and the Portable Object Adapter (POA).

The POA provides transient, persistent, and other user ID policies with which to create objects in WLE. You can create a persistent object reference in WLE by creating a callback object with a Persistent/User ID Object Policy.

Implementation Inheritance

Ordinarily, servant classes must inherit from the ImplBase class generated by the idltojava compiler. This is inadequate for servant classes that need to inherit functionality from another Java class. The Java programming language allows a class only one superclass and the generated ImplBase class already occupies this position. A servant class can inherit an implementation from any Java class using Tie classes