|
|
This chapter discusses the following topics:
Note: Each sample application directory tree provided with the WLE software includes a Readme.txt file that explains how to build and run the sample. Refer to this file in the following directory for troubleshooting information or other last-minute information about using the CORBA/C++-to-EJB Simpapp sample application.
Windows NT:
$TUXDIR\samples\interop\cpp_ejb
UNIX:
$TUXDIR/samples/interop/cpp_ejb
The CORBA/C++-to-EJB Simpapp sample application features the following:
How the CORBA/C++-to-EJB Simpapp Sample Application Works
The following figure illustrates how the CORBA/C++-to-EJB Simpapp sample application works.
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 WLE software in the bin
directory under TUXDIR
.
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:
Software Prerequisites
Implementing the Bridge Object to Invoke an EJB
The following code fragment shows the methods on the SimpleBridge
object that delegate the SimpleImpl
's requests to the EJB server application:
public class SimpBridge { The C++ and Java objects in the sample application described in this chapter implement the CORBA interfaces listed in the following table.
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-EJB Simpapp Interfaces
Interface |
Description |
Operation |
Policies |
---|---|---|---|
Listing 3-1 shows the simple.idl
file that defines the CORBA interfaces in the CORBA/C++-to-EJB Simpapp sample application.
Listing 3-1
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();
};
Perform the following steps to build and run the CORBA/C++-to-EJB Simpapp sample application:
The following sections describe these steps, and also explain the following:
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-1 lists the environment variables required to run the CORBA/C++-to-EJB Simpapp sample application.
Verifying the Settings of the Environment Variables
Table 3-1 Required Environment Variables for the CORBA/C++-to-EJB Simpapp Sample Application
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-2 lists the optional environment variables you can assign prior to running the CORBA/C++-to-EJB Simpapp sample application.
Table 3-2 Optional Environment Variables for the CORBA/C++-to-EJB Simpapp Sample Application
Environment Variable |
Description |
---|---|
To verify that the information for the environment variables defined during installation is correct, perform the following steps:
Windows NT:
Verifying the Environment Variables
The Control Panel appears.
The System Properties window appears.
The Environment page appears.
UNIX:
ksh prompt>printenv TUXDIR
ksh prompt>printenv JAVA_HOME
To change the environment variable settings, perform the following steps:
Windows NT:
The Control Panel appears.
The System Properties window appears.
The Environment page appears.
UNIX:
ksh prompt>export TUXDIR=
directorypath
ksh prompt>export JAVA_HOME=
directorypath
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.
Windows NT:
> copy $TUXDIR\samples\interop\cpp_ejb\*.* <work_directory>
UNIX:
> cp -R $TUXDIR/samples/interop/cpp_ejb/* <work_directory>
Windows NT:
>nmake -f makefile.nt copy
UNIX:
>make -f makefile.mk copy
This section lists and describes the files copied into your working directory after you have performed the steps described in the previous section.
The CORBA/C++-to-EJB Simpapp sample application files exist in the following sets:
Table 3-3 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-3 CORBA C++ and Java Files for the CORBA/C++-to-EJB Simpapp Sample Application
Table 3-4 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-4 EJB Source Files for the CORBA/C++-to-EJB Simpapp Sample Application
Table 3-5 lists and describes the utility files for this sample application.
Table 3-5 CORBA/C++-to-EJB Simpapp Utility Files
During the installation of the WLE 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 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
The runme
command automates the following steps:
Changing the Protection Attribute on the Files for the CORBA/C++-to-EJB Simpapp Sample Application
ksh prompt>chmod +w /
workdirectory
/*.*
Executing the runme 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:
After you have executed the runme
command, you can run the CORBA/C++-to-EJB Simpapp sample application manually if you like.
To run the CORBA/C++-to-EJB Simpapp sample application:
Running the Sample Application
Windows NT:
prompt>results\setenv
UNIX:
prompt>. results/setenv.ksh
Windows NT:
prompt>tmboot -y
prompt>java -DTOBJADDR=%TOBJADDR% SimpleClient
UNIX:
prompt>tmboot -y
prompt>java -DTOBJADDR=$TOBJADDR SimpleClient
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:
This section lists and describes the processes started and the files generated by the CORBA/C++-to-EJB Simpapp sample application.
When the tmboot
command is executed to start the CORBA/C++-to-EJB Simpapp sample application, the following server processes are started:
Processes and Files Generated by the CORBA/C++-to-EJB Simpapp Sample Application
Processes Started
The following table lists and describes the files generated in the cpp
directory.
Files Generated in the cpp Directory
The following files are generated in the cpp_ejb
directory:
File Generated in the cpp_ejb Directory
Generated by the tmloadcf
command. Contains the security encryption key database.
|
The following table lists and describes the files that are generated in the results
directory, which is a subdirectory of the corbaj
working directory.
Files Generated in the results Directory
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:
Stopping the CORBA/C++-to-EJB Simpapp Sample Application
Windows NT:
prompt>tmshutdown -y
UNIX:
ksh prompt>tmshutdown -y
Windows NT:
prompt>nmake -f makefile.nt clean
UNIX:
prompt>. ./results/setenv.ksh
prompt>make -f makefile.nt clean
prompt>results\setenv
prompt>set JDKDIR=%JAVA_HOME%
prompt>smake -f smakefile.nt
|
Copyright © 1999 BEA Systems, Inc. All rights reserved.
|