BEA Logo BEA BEA Tuxedo Release [Release Number]

  BEA Home  |  Events  |  Solutions  |  Partners  |  Products  |  Services  |  Download  |  Developer Center  |  WebSUPPORT

 

   BEA Tuxedo Doc Home   |   Interoperability   |   Previous Topic   |   Next Topic   |   Contents   |   Index

Connectivity Between a BEA Tuxedo CORBA Client and an EJB in WebLogic Server

 

This topic includes the following sections:

 


Overview of the WLStrader Value Type Sample Application

The WLStrader Value Type sample application demonstrates connectivity between an RMI over IIOP client and an EJB. More specifically, this sample application illustrates how a CORBA C++ client application developed in BEA Tuxedo can interact with an EJB in WebLogic Server. The application makes use of the Trader EJB included in the WebLogic Server examples. The WLStrader Value Type sample builds on components of the Trader sample application, while providing its own build and run procedures.

Figure 2-1 illustrates the connectivity provided in the WLStrader Value Type sample application.

Figure 2-1 CORBA C++ Client to WebLogic Server EJB


 
 
 

In the WLStrader Value Type example, a BEA Tuxedo CORBA C++ client employs a value type, passing an object-by-value. This supports an RMI over IIOP invocation of an IDL interface, and provides connectivity to the WebLogic Server TraderBean Enterprise JavaBean (EJB).

A value type represents a class whose values can be moved between systems. Value types can be passed as arguments or results of remote methods, or as fields within other objects that are passed remotely. For information on support for value types in BEA Tuxedo CORBA, see Chapter 13, "Mapping of OMG IDL Statements to C++," in the CORBA Programming Reference in the BEA Tuxedo online documentation.

The CORBA client obtains the WebLogic Server Inter-operable Object Reference (IOR) by invoking the COSNaming Service layer provided in the WebLogic Server JNDI implementation. For information on the CORBA Name Service and the COSNaming data structures, see Using the CORBA Name Service in the BEA Tuxedo online documentation.

 


Components of the WLStrader Value Type Sample Application

This topic describes the components and operations in the WLStrader Value Type sample application. It includes the following sections:

WebLogic Server Trader Sample Application

The WLStrader Value Type sample builds on components of the WebLogic Server Trader sample application, employing its XML deployment files and Trader EJB. To derive the optimum benefit from this example, read through the source code files to understand the design and the steps involved. Review the deployment files to understand the general structure of the Trader EJB.

The WebLogic Server code sample files for the Trader sample are in the wlserver6\samples\examples\rmi_iiop\ejb\rmi_iiop directory.

Table 2-1 Java Interface Summary

Java Interface

Description

Trader

The methods in this interface are the public face of TraderBean.

TraderHome

This interface is the home interface for TraderBean.java, which in WebLogic is implemented by the code-generated container class TraderBeanC.

Table 2-1 provides a summary of the Java interfaces in this example.

Table 2-2 Java Class Summary

Java Class

Description

Tuxclient

This C++ client program logic invokes a stateless Session Bean and performs the following exercises: creates a Trader, buys some shares using the Trader, retrieves the NumberTraded returned in a value type, and removes the Trader.

TraderBean

TraderBean is a stateless Session Bean.

TradeResult

This class implements the serializable interface, and does not have any classes generated on the value type. The state of TradeResult is maintained in private instance members, and there is no default public access to the state of the value type. Because TradeResult implements the serializable interface, the ejbc utility generates a value type for it in the IDL file.

Table 2-2 provides a summary of the Java classes in this example.

Mapping from a WebLogic Server to a CORBA Client

When deriving the mapping from a WebLogic Server application to a CORBA client, the sources of the mapping information are the EJB classes as defined in the Java source files. WebLogic Server provides the weblogic.ejbc utility for generating required CORBA IDL files. These files represent the CORBA view into the state and behavior of the target EJB.

The weblogic.ejbc utility performs the following:

The weblogic.ejbc utility supports a number of command qualifiers. In the WLStrader Value Type example, the ejbc step invokes these qualifiers on the command line:

Resulting files are processed using the BEA Tuxedo IDL compiler, reading source files from the idlSources directory and generating CORBA C++ stub and skeleton files. These generated files are sufficient for all CORBA data types with the exception of value types. Value types need to be implemented on each platform on which they are defined or referenced. Specifying the -i qualifier directs the IDL compiler to create implementation files named FileName_i.h and FileName_i.cpp. For example, this syntax creates the TradeResult_i.h and TradeResult_i.cpp implementation files:

idl -IidlSources -i idlSources\examples\rmi_iiop\ejb\rmi_iiop\TradeResult.idl

The resulting source files provide implementations for application-defined operation on a value type. Implementation files are included in a CORBA client application.

BEA Tuxedo CORBA C++ Client

The CORBA C++ client program tuxclient performs the exercises against the Trader. The results from a Trader transaction are returned to the client through the TradeResult value type. The tuxclient application performs these operations:

The code extract from tuxclient.cpp in Listing 2-2 contains the steps for creating a Trader instance and buying some shares of BEAS.

Listing 2-2 tuxclient.cpp—Create a Trader; Buy Some Shares

 . . .
// Create a Trader instance
::examples::rmi_iiop::ejb::rmi_iiop::Trader_ptr trader =
home->create();
// Buy some shares
CORBA::WStringValue_ptr BEASsym = new
CORBA::WStringValue(CORBA::wstring_dup((wchar_t *)L"BEAS"));
::examples::rmi_iiop::ejb::rmi_iiop::TradeResult_ptr result;
cout << "Buying 3000 shares of BEAS" << endl;
result = trader->buy(BEASsym, 3000);
. . .

The "buy" request from the CORBA client is for 3000 shares of BEA stock with symbol BEAS. The actual number of shares traded is 500, imposed by the tradeLimit threshold defined in the ejb-jar.xml deployment file for the WebLogic Server examples.

Listing 2-3 tradeLimit Defined in ejb-jar.xml

 . . .
<env-entry-name>
tradeLimit</env-entry-name>
<env-entry-type>java.lang.Integer</env-entry-type>
<env-entry-value>
500</env-entry-value>
. . .

To achieve different results when you run the WLStrader Value Type sample application, you can vary definitions in the ejb-jar.xml file, or constants in the tuxclient.cpp source file.


 
 

 


Building and Running the WLStrader Value Type Sample Application

This section leads you through the process of building and running the WLStrader Value Type sample application.

Before running the example, described later in the sequence of steps, you must obtain the WebLogic Server Inter-operable Object Reference (IOR) by running the host2ior utility. Complete this step once for any WebLogic Server installation. You can obtain this file any time after installing WebLogic Server, and before running an application requiring the file.

To build and run the wlstrader sample application, complete the following steps. Each step is described in detail in subsequent sections. The steps detailed here supplement the information in the WebLogic Server installation location:wlserver6\samples\examples\rmi_iiop\ejb\rmi_iiop\package-summary.html.

Set the Development Environment

When developing in Java, make sure you have a controlled development environment.

  1. Set your development environment as described in the WebLogic Server Examples Guide (which is included with the product). See Setting Up Your Environment for Building and Running the Examples.

  2. From your user interface tool or from a command prompt, set the TUXDIR environment variable to the BEA Tuxedo installation location.

    For example:

    Windows

    > set TUXDIR=D:\TUXDIR

    UNIX

    ksh prompt> export TUXDIR=/usr/local/TUXDIR

Copy the BEA Tuxedo WLStrader Value Type Files

Rename the build command script, and copy the BEA Tuxedo WLStrader Value Type files from the BEA Tuxedo CORBA samples directory to your WebLogic Server examples build area.

  1. Use a command prompt or user interface tool to rename the build command script to a unique, recognizable name. The remainder of this text uses the script name tuxbuild. You will be copying this file into a WebLogic Server examples directory that already contains a build command script.

    For example:

    Windows

    rename %TUXDIR%\samples\corba\wlstrader\build.cmd tuxbuild.cmd

    UNIX

    mv $TUXDIR/samples/corba/wlstrader/build.sh tuxbuild.sh

  2. From a command prompt or user interface tool, copy files from the BEA Tuxedo CORBA samples wlstrader directory to your WebLogic Server examples build area.

    For example:

    Windows

    copy %TUXDIR%\samples\corba\wlstrader\*.*
    D:\bea\wlserver6\samples\examples\rmi_iiop\ejb\rmi_iiop\*.*

    UNIX

    cp $TUXDIR/samples/corba/wlstrader/*.*
    /usr/local/wlserver6/samples/examples/rmi_iiop/ejb/rmi_iiop/*.*


     
     

The sample files listed in Table 2-3 should now be in your WebLogic Server examples build area.

Table 2-3 Wlstrader Value Type Sample Files

File

Description

TradeResult_i.cpp

C++ source defining the constructor for the TradeResult value type. TradeResult_i.cpp and TradeResult_i.h provide the actual implementation of the concrete class for the TradeResult value type.

TradeResult_i.h

The C++ header file that defines the implementation class for the TradeResult value type.

tuxbuild.cmd

The renamed build command file for Windows systems.

tuxbuild.sh

The renamed build command script for UNIX systems.

tuxclient.cpp

C++ source code for the CORBA client application.

Build the Example

Execute the renamed build script for this example. This is the file you renamed before copying from the BEA Tuxedo samples\corba\wlstrader directory into the samples\examples\rmi_iiop\ejb\rmi_iiop directory of your WebLogic Server installation. The script performs the following steps presented here for a Windows environment:

  1. Sets the TUXDIR environment variable. You can modify this step in the tuxclient.cmd script, or comment out the step if TUXDIR is already defined.

  2. Sets the IDL2CPP environment variable, defining the idl executable program in the %TUXDIR%\bin directory and setting the required command-line parameters.

  3. Creates a build directory structure, copies in the deployment descriptors, and copies in *.gif images.

    > mkdir build build\META-INF build\images

    > copy *.xml build\META-INF

    > copy *.gif build\images

  4. Compiles EJB classes into the build directory (JAR preparation).

    > javac -d build Trader.java TraderHome.java
    TraderResult.java TraderBean.java

  5. Makes an EJB JAR file, including the XML deployment descriptors.

    > cd build

    > jar cv0f std_ejb_over_iiop.jar META-INF examples images

    > cd ..

  6. Runs the weblogic.ejbc utility against the JAR file, directing generated IDL files to the idlSources directory.

    > java weblogic.ejbc -compiler javac -keepgenerated
    -idl -idlDirectory idlSources
    -iiop build\std_ejb_over_iiop.jar
    %APPLICATIONS%\ejb_over_iiop.jar

  7. Compiles the EJB interfaces and client application into the directory defined by the CLIENT_CLASSES target variable.

    > javac -d %CLIENT_CLASSES% Trader.java TraderHome.java
    TradeResult.java Client.java

  8. Runs the IDL compiler against the IDL files built in the weblogic.ejbc step, creating C++ source files.

    >%IDL2CPP% idlSources\examples\rmi_iiop\ejb\rmi_iiop\Trader.idl
    . . .
    >%IDL2CPP% idlSources\javax\ejb\RemoveException.idl

  9. Builds the CORBA C++ client executable program tuxclient.exe by invoking the buildobjclient command.

Configure the Server

Start the WebLogic Server by reviewing and implementing the steps defined in the WebLogic Server Examples documentation. See Starting WebLogic Server with the Examples Configuration. Review the configuration file containing the configuration attributes for all of the examples, located in config\examples\config.xml in the WebLogic Server installation location. To run a start server script:

Windows

prompt> startExampleServer

Alternatively, on Windows platforms you can start the WebLogic Server with the examples configuration from the Windows Start Menu.

UNIX

$ sh startExamplesServer.sh

Run the Example

Run the WLStrader Value Type sample program by setting up the environment and starting the tuxclient.exe executable program. The following steps are for a Windows environment:

  1. Add the ejb_over_iiop.jar file to your WebLogic Server CLASSPATH. For example:

    prompt> set CLASSPATH=%CLASSPATH%;%WL_HOME%\config\
    examples\applications\ejb_over_iiop.jar

  2. Ensure that you have obtained the WebLogic Server Inter-operable Object Reference (IOR) by running the host2ior utility. The ior.txt file must be accessible to the tuxclient.exe CORBA C++ client program. You create this file once for a specific WebLogic Server installation. For example:

    prompt> java utils.host2ior hostname port

  3. Start the tuxclient.exe CORBA client program by invoking the executable client application you created when you built the example.

    prompt> tuxclient.exe

  4. Observe CORBA client output messages similar to the following:


    Creating a trader

    Buying 3000 shares of BEAS
    500 shares bought
    Buying 100 shares of PSFT
    100 shares bought

    End statelessSession.Client

 


Additional Sources of Information

The process of developing a BEA Tuxedo CORBA client application to interact with a WebLogic Server application begins with an EJB. If you are creating a new WebLogic Server application, the first step is to design and implement the server.

The following sections list sources of information about the steps required to implement connectivity between an RMI over IIOP CORBA Client and an EJB in WebLogic Server.

WebLogic Server

These topics are included in the WebLogic Server online documentation:

Object Management Group (OMG)

Information about CORBA objects and value types, which are objects passable by value, is available from the OMG Web site: http://www.omg.org.

BEA Tuxedo CORBA

The BEA Tuxedo online documentation provides complete documentation on CORBA topics in the BEA Tuxedo product. The references listed here contain information on creating CORBA clients, the COSNaming Service, the IDL command, and BEA Tuxedo support for value types:

 

back to top previous page next page