BEA Logo BEA WebLogic Enterprise Release 5.1

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

 

   WebLogic Enterprise Doc Home   |   Interoperability Topics   |   Previous Topic   |   Next Topic   |   Contents   |   Index

CORBA/C++-to-T-Engine EJB Simpapp Sample Application

 

This topic includes the following sections:

 


How the CORBA/C++-to-T-Engine EJB Simpapp Sample Application Works

The CORBA/C++-to-EJB Simpapp sample application features the following:

Figure 3-1 illustrates how the CORBA/C++-to-EJB Simpapp sample application works.

Figure 3-1 CORBA/C++-to-T-Engine EJB Simpapp Sample Application

Software Prerequisites

To run the m3idltojava compiler that is used by the CORBA/C++-to-EJB Simpapp sample application, you need to install Visual C++ version 6.0 with Service Pack 3 or later for Visual Studio. The m3idltojava compiler is installed by the WebLogic Enterprise software in the bin directory under TUXDIR.

Implementing the Bridge Object to Invoke an EJB

The SimpleBridge Java object serves as the intermediary between the CORBA/Java server and the EJB server application. The SimpleBridge Java object is created by the SimpleImpl Java object. The SimpleBridge Java object performs the following functions:

Listing 3-1 shows the methods on the SimpleBridge object that delegate the SimpleImpl object's requests to the EJB server application:

Listing 3-1 SimpleBridge Object Implementation Code


public class SimpBridge {


public String doUpper(String mixedStr)
{
String upperStr = "";
javax.naming.Context ctx = null;
SimpHome home = null;

try {
// create connection
ctx = getContext();

// look up home object
home = (SimpHome) ctx.lookup("ejb.SimpHome");

// create the object and use it
Simp simp = home.create();
upperStr = simp.upper(mixedStr);
} // catch exceptions
}

return upperStr;
}


public String doLower(String mixedStr)
{
String lowerStr = "";
javax.naming.Context ctx = null;
SimpHome home = null;

try {
// create connection
ctx = getContext();

// look up home object
home = (SimpHome) ctx.lookup("ejb.SimpHome");

// create the object and use it
Simp simp = home.create();
lowerStr = simp.lower(mixedStr);
} // catch exceptions
}

return lowerStr;
}


public static Context getContext()
{
Context context = null;

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.beasys.jndi.WLEInitialContextFactory");
env.put(Context.SECURITY_AUTHENTICATION, "none");

try {
context = new InitialContext(env);
} catch (NamingException ee) {
System.out.println("getContext failed: " + ee);
ee.printStackTrace();
}

return context;
}
}

 


The OMG IDL Code for the CORBA/C++-to-T-Engine EJB Simpapp Interfaces

The C++ and Java objects in the sample application described in this chapter implement the CORBA interfaces listed in Table 3-1.

Table 3-1 Sample Application IDL Interfaces

Interface

Description

Operation

Policies

SimpleFactory

Creates object references to the Simple object.

find_simple()

Activation: method

Transaction: optional

Simple

Delegates the conversion of the string to the EJB server.

to_upper()

to_lower()

Activation: method

Transaction: optional

Listing 3-2 shows the simple.idl file that defines the CORBA interfaces in the CORBA/C++-to-EJB Simpapp sample application.

Listing 3-2 OMG IDL Code for the CORBA/C++-to-EJB 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();
};


 


Building and Running the CORBA/C++-to-T-Engine EJB Simpapp Sample Application

To build and run the CORBA/C++-to-EJB Simpapp sample application, complete the following steps:

  1. Verify the environment variables.

  2. Copy the files for the CORBA/C++-to-EJB Simpapp sample application into a work directory.

  3. Change the protection attribute on the files for the CORBA/C++-to-EJB Simpapp sample application.

  4. Execute the runme command.

The following sections describe these steps, and also explain the following:

Verifying the Settings of the Environment Variables

Before building and running the CORBA/C++-to-EJB Simpapp sample application, you need to ensure that certain environment variables are set on your system. In most cases, these environment variables are set as part of the installation procedure. However, you need to check the environment variables to ensure they reflect correct information.

Table 3-2 lists the environment variables required to run the CORBA/C++-to-EJB Simpapp sample application.

Table 3-2 Required Environment Variables for the CORBA/C++-to-EJB Simpapp Sample Application

Environment Variable

Description

TUXDIR

The directory path where you installed the WebLogic Enterprise software. For example:

Windows NT

TUXDIR=c:\WLEdir

UNIX

TUXDIR=/usr/local/WLEdir

JAVA_HOME

The directory path where you installed the JDK software. For example:

Windows NT

JAVA_HOME=c:\JDK1.2.2

UNIX

JAVA_HOME=/usr/local/JDK1.2.2

You may optionally set the following system environment variables to change their default value prior to running the CORBA/C++-to-EJB Simpapp sample runme command. See the Administration Guide for more information about selecting appropriate values for these environment variables.

Table 3-3 lists the optional environment variables you can assign prior to running the CORBA/C++-to-EJB Simpapp sample application.

Table 3-3 Optional Environment Variables for the CORBA/C++-to-EJB Simpapp Sample Application

Environment Variable

Description

HOST

The host name portion of the TCP/IP network address used by the ISL process to accept connections from CORBA. The default value is the name of the local machine.

PORT

The TCP port number at which the ISL process listens for incoming requests; it must be a number between 0 and 65535. The default value is 2468.

IPCKEY

The address of shared memory; it must be a number greater than 32769 unique to this application on this system. The default value is 55432.

Verifying the Environment Variables

To verify that the information for the environment variables defined during installation is correct, complete the following steps:

Windows NT

  1. From the Start menu, select Settings.

  2. From the Settings menu, select the Control Panel.

    The Control Panel appears.

  3. Click the System icon.

    The System Properties window appears.

  4. Click the Environment tab.

    The Environment page appears.

  5. Check the settings for TUXDIR and JAVA_HOME.

UNIX

  1. Enter the ksh command to use the Korn shell.

  2. Enter the printenv command to display the values of TUXDIR and JAVA_HOME, as in the following example:

    ksh prompt>printenv TUXDIR
    ksh prompt>printenv JAVA_HOME

Changing the Environment Variables

To change the environment variable settings, complete the following steps:

Windows NT

  1. From the Start menu, select Settings.

  2. From the Settings menu, select the Control Panel.

    The Control Panel appears.

  3. Click the System icon.

    The System Properties window appears.

  4. Click the Environment tab.

    The Environment page appears.

  5. On the Environment page in the System Properties window, click the environment variable you want to change or enter the name of the environment variable in the Variable field.

  6. Enter the correct information for the environment variable in the Value field.

  7. Click OK to save the changes.

UNIX

  1. Enter the ksh command to use the Korn shell.

  2. Enter the export command to set the correct values for the TUXDIR and JAVA_HOME environment variables, as in the following example:

    ksh prompt>export TUXDIR=directorypath
    ksh prompt>export JAVA_HOME=directorypath

Copying the Files for the CORBA/C++-to-EJB Simpapp Sample Application into a Work Directory

You need to copy the files for the CORBA/C++-to-EJB Simpapp sample application into a work directory on your local machine. The files for the CORBA/C++-to-EJB Simpapp sample application are located in the following directories.

Windows NT

$TUXDIR\samples\interop\cpp_ejb

UNIX

$TUXDIR/samples/interop/cpp_ejb

The following steps describe how to execute a makefile to copy all the example files into a work directory.

  1. Create the work directory on your machine.

  2. Copy the entire cpp_ejb directory to the work directory created in the previous step:

    Windows NT

    > copy $TUXDIR\samples\interop\cpp_ejb\*.* <work_directory>

    UNIX

    > cp -R $TUXDIR/samples/interop/cpp_ejb/* <work_directory>

  3. Change to the work directory created in step 1.

  4. Enter the following command, which copies the remaining EJB-to-CORBA/Java Simpapp sample application files to the work directory:

    Windows NT

    >nmake -f makefile.nt copy

    UNIX

    >make -f makefile.mk copy

Files in the Work Directory

This section lists and describes the files copied into your work directory after you have completed the steps described in the previous section.

The CORBA/C++-to-EJB Simpapp sample application files exist in the following sets:

CORBA/C++ Client Files

Table 3-4 lists and describes the files needed to create the CORBA/C++ client. Also included are the files needed to create the CORBA/Java server that acts as a bridge for the CORBA/C++-to-EJB Simpapp sample application. These files are located in the cpp subdirectory.

Table 3-4 CORBA C++ and Java Files for the CORBA/C++-to-EJB Simpapp Sample Application

File

Description

simplec.cpp

C++ client program for the simple sample application.

simple.idl

The OMG IDL that declares the SimpleFactory and Simple interfaces.

simple.xml

The XML source file used to associate activation and transaction policy values with interfaces.

ServerImpl.Java

The Java source code that implements the Server.initialize and Server.release methods.

SimpleFactoryImpl.Java

The Java source code that implements the SimpleFactory methods.

SimpleImpl.Java

The Java source code that implements the Simple methods.

EJB Server Files

Table 3-5 lists and describes the files needed to create the EJB server for the CORBA/C++-to-EJB Simpapp sample application. These files are located in the ejb subdirectory.

Table 3-5 EJB Source Files for the CORBA/C++-to-EJB Simpapp Sample Application

File

Description

weblogic-ejb-extensions.XML

The XML file specifying the WebLogic EJB extensions to the deployment descriptor DTD.

SimpBean.java

The Java source code for the SimpBean class. This is an example of a stateless session bean. This bean contains the methods invoked by the SimpleBridge class.

Simp.java

The Java source code for the Remote interface of the SimpBean class.

SimpHome.java

The Java source code for the Home interface of the SimpBean class.

SimpleBridge.java

The Java source code for the SimpleBridge class. This class is used by the SimpleImpl class to communicate with the EJB server. This is the class that effects the interoperability between the CORBA/C++ object and the EJB server.

Utility Files

Table 3-6 lists and describes the utility files for this sample application.

Table 3-6 CORBA/C++-to-EJB Simpapp Utility Files

File

Description

Readme.txt

Contains directions for building and executing the CORBA/C++-to-EJB Simpapp sample application.

runme.cmd

The Windows NT batch file that contains commands to build and execute the CORBA/C++-to-EJB Simpapp sample application.

runme.ksh

The UNIX Korn shell script that contains commands to build and execute the CORBA/C++-to-EJB Simpapp sample application.

makefile.nt

The common makefile for the CORBA/C++-to-EJB Simpapp sample application on the Windows NT platform. This makefile can be used directly by the Visual C++ nmake command. The makefile.nt file is included by the smakefile.nt file.

smakefile.nt

The makefile for the CORBA/C++-to-EJB Simpapp sample application to be used by Symantec's Visual Café smake program.

makefile.mk

The makefile for the CORBA/C++-to-EJB Simpappp sample application on the UNIX platform.

Changing the Protection Attribute on the Files for the CORBA/C++-to-EJB Simpapp Sample Application

During the installation of the WebLogic Enterprise software, the sample application files are marked read-only. Before you can edit or build the files in the CORBA/C++-to-EJB Simpapp sample application, you need to change the protection attribute of the files you copied into your work directory (including the respective ejb and corbaj subdirectories), as follows:

Windows NT

prompt>attrib /S -r drive:\workdirectory\*.*

UNIX

prompt>/bin/ksh
ksh prompt>chmod +w /
workdirectory/*.*

On the UNIX operating system platform, you also need to change the permission of runme.ksh to give execute permission to the file, as follows:

ksh prompt>chmod +x runme.ksh

Executing the runme Command

The runme command automates the following steps:

  1. Sets the system environment variables

  2. Loads the UBBCONFIG file

  3. Compiles the code for the EJB server object

  4. Compiles the code for the CORBA/C++ joint client/server application

  5. Compiles the code for the CORBA/Java server application

  6. Starts the server application using the tmboot command

  7. Starts the client application

  8. Stops the server application using the tmshutdown command

To build and run the CORBA/Java Simpapp sample application, enter the runme command, as follows:

Windows NT

prompt>cd workdirectory

prompt>runme

UNIX

ksh prompt>cd workdirectory

ksh prompt>./runme.ksh

The CORBA/C++-to-EJB Simpapp sample application runs and prints the following messages:

Testing simpapp
cleaned up
prepared
built
loaded ubb
booted
ran
shutdown
saved results
PASSED

All of the sample application output is placed in the results directory. You can check in that directory for the following files:

Running the Sample Application

After you have executed the runme command, you can run the CORBA/C++-to-EJB Simpapp sample application manually, if you like.

To manually run the CORBA/C++-to-EJB Simpapp sample application:

  1. Verify that your environment variables are correct by entering the following command:

    Windows NT

    prompt>results\setenv

    UNIX

    prompt>. results/setenv.ksh

  2. Run the sample:

    Windows NT

    prompt>tmboot -y
    prompt>java -DTOBJADDR=%TOBJADDR% SimpleClient

    UNIX

    prompt>tmboot -y
    prompt>java -DTOBJADDR=$TOBJADDR SimpleClient

  3. To run the CORBA/C++ joint client/server application, enter a string. After you enter the string, the application returns the string in uppercase and lowercase characters, respectively:

    String?
    Hello World
    HELLO WORLD
    hello world

All of the sample application output is placed in the results directory. You can check in that directory for the following files:

Processes and Files Generated by the CORBA/C++-to-EJB Simpapp Sample Application

This section lists and describes the processes started and the files generated by the CORBA/C++-to-EJB Simpapp sample application.

Processes Started

When the tmboot command is executed to start the CORBA/C++-to-EJB Simpapp sample application, the server processes in Table 3-7 are started:

Table 3-7 CORBA/C++-to-EJB Simpapp Server Processes

Process

Description

TMSYSEVT

The BEA Tuxedo system Event Broker.

TMFFNAME

Starts the following TMFFNAME processes:

  • The TMFFNAME server process with the -N option and the -M option is the MASTER NameManager service. The -N option says to start the NameManager Service; the -M option says to start this name manager as a Master. This service maintains a mapping of application-supplied names to object references.

  • The TMFFNAME server process with the -N option only is a SLAVE NameManager service.

  • The TMFFNAME server with the -F option contains the FactoryFinder object.

JavaServer

The Simpapp server process that implements EJB JAR file for the SimpBean and SimpHome interfaces. The JavaServer has one argument, SimpleEjb.jar, which is the EJB Java ARchive (JAR) file that was created for the application.

JavaServer

The Simpapp server process that implements the SimpleFactory interface and the Simple interface. The JavaServer has one argument, SimpleCorba.jar, which is the CORBA Java ARchive (JAR) file that was created for the application.

ISL

The IIOP Listener/Handler.

Files Generated in the cpp Directory

Table 3-8 lists and describes the files generated in the cpp directory.

Table 3-8 Files Generated in the cpp Directory

File

Description

Simple_c.cpp

Client stubs for the Simple and SimpleFactory interfaces.

Simple_c.h

Client stub header for the Simple and SimpleFactory interfaces.

Simple_client.exe

C++ client executable.

Simple.java

Generated by the m3idltojava command for the Simple interface. This interface contains the Java version of the IDL interface. It extends the base class org.omg.CORBA.Object.

SimpleHelper.java

Generated by the m3idltojava command for the Simple interface. This class provides auxiliary functionality, notably the narrow method.

SimpleHolder.java

Generated by the m3idltojava command for the Simple interface. This class holds a public instance member of type Simple. It provides operations for out and inout arguments, which CORBA has, but which do not map easily to Java's semantics.

_SimpleImplBase.java

Generated by the m3idltojava command for the Simple interface. This abstract class is the server skeleton. It implements the Simple.java interface. The server class SimpleImpl extends _SimpleImplBase.

_SimpleStub.java

Generated by the m3idltojava command for the Simple interface. This class is the client stub. It implements the Simple.java interface.

SimpleFactory.java
SimpleFactoryHelper.java
SimpleFactoryHolder.java
_SimpleFactoryImplBase.java
_SimpleFactoryStub.java

Generated by the m3idltojava command for the SimpleFactory interface.

Simple.ser

The server descriptor file that is generated by the buildjavaserver command.

Simple.jar

The Java ARchive (JAR) file that is generated by the buildjavaserver command.

File Generated in the cpp_ejb Directory

Table 3-9lists and described the files generated in the cpp_ejb directory.

Table 3-9 Files Generated in the cpp_ejb Directory

File

Description

results directory

Generated by the runme command.

.adm/.keydb

Generated by the tmloadcf command. Contains the security encryption key database.

Files Generated in the results Directory

Table 3-10 lists and describes the files that are generated in the results directory, which is a subdirectory of the corbaj work directory.

Table 3-10 Files Generated in the results Directory

File

Description

input

Generated by the runme command. Contains the input that runme gives to the SimpleClient Java application.

output

Generated by the runme command. Contains the output that is produced when runme executes the SimpleClient Java application.

expected_output

Generated by the runme command. Contains the output that is expected when the SimpleClient Java application is executed by the runme command. The data in the output file is compared with the data in the expected_output file to determine whether the test passed or failed.

log

Generated by the runme command. Contains the output generated by the runme command. If the runme command fails, check this file, and the ULOG file, for errors.

setenv.cmd

Generated by the Windows NT runme.cmd command. Contains the commands to set the environment variables needed to build and execute the CORBA/C++-to-EJB Simpapp sample application.

setenv.ksh

Generated by the UNIX runme.ksh command. Contains the commands to set the environment variables needed to build and execute the Simpapp sample application.

stderr

Generated by the tmboot command, which is executed by the runme command. If the -noredirect server option is specified in the UBBCONFIG file, the System.err.println method sends the output to stderr instead of to the ULOG user log file.

stdout

Generated by the tmboot command, which is executed by the runme command. If the -noredirect server option is specified in the UBBCONFIG file, the System.out.println method sends the output to the stdout file instead of to the ULOG user log file.

tmsysevt.dat

Generated by the tmboot command, which is executed by the runme command. It contains filtering and notification rules used by the TMSYSEVT (system event reporting) process.

tuxconfig

Generated by the tmloadcf command, which is executed by the runme command.

ubb

The UBBCONFIG file for the CORBA/C++-to-EJB Simpapp sample application.

ULOG.<date>

A log file that contains messages generated by the tmboot command.

 


Stopping the CORBA/C++-to-T-Engine EJB Simpapp Sample Application

Before using another sample application, use the following procedure to stop the CORBA/C++-to-EJB Simpapp sample application and to remove unnecessary files from the work directory:

  1. To stop the application:

    Windows NT

    prompt>tmshutdown -y

    UNIX

    ksh prompt>tmshutdown -y

  2. To restore the work directory to its original state:

    Windows NT

    prompt>nmake -f makefile.nt clean

    UNIX

    prompt>. ./results/setenv.ksh
    prompt>make -f makefile.nt clean

  3. If Symantec's Visual Café is installed on your system, you can use the smakefile.nt file rather than the makefile.nt file, which is intended for use with the Visual C++ nmake program. For example, execute the following commands:

    prompt>results\setenv
    prompt>set JDKDIR=%JAVA_HOME%
    prompt>smake -f smakefile.nt