|
|
The 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 EJB-to-CORBA/Java sample application:
Window NT:
$TUXDIR\samples\interop\ejb_corbaj
UNIX:
$TUXDIR/samples/interop/ejb_corbaj
The EJB-to-CORBA/Java Simpapp sample application has an EJB client, an EJB server deploying the SimpBean
EJB and an EJB-to-CORBA bridge object, and a CORBA server deploying a CORBA object.
The SimpBean
EJB has the following two remote methods:
How the EJB-to-CORBA/Java Simpapp Sample Application Works
The CORBA Simple object has the following two methods:
The following figure illustrates how the EJB-to-CORBA/Java Simpapp sample application works.
To run the m3idltojava
compiler that is used by the EJB-to-CORBA/Java 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 implements bridge design pattern. This object serves as a bridge between the SimpBean
EJB and the CORBA/Java Simple
object, and it is created by the SimpBean
EJB.
The SimpleBridge
Java object performs the following functions:
Software Prerequisites
Implementing the Bridge Object to Invoke a CORBA/Java Object
The following code fragment shows the methods on the SimpleBridge
object that delegate the SimpBean
's requests to the CORBA/Java Simple
object:
public class SimpleBridge The sample application described in this chapter implements the CORBA interfaces listed in the following table.
{
private Simple simple = null;
public SimpleBridge ()
{
simple = getSimple();
}
public String doUpper(String mixedStr)
{
// Convert the string to upper case.
org.omg.CORBA.StringHolder upperStr =
new org.omg.CORBA.StringHolder(mixedStr);
simple.to_upper(upperStr);
System.out.println("in SimpleBridge.doUpper()");
return upperStr.value;
}
public String doLower(String mixedStr)
{
// Convert the string to lower case.
String lowerStr = simple.to_lower(mixedStr);
System.out.println("in SimpleBridge.doLower()");
return lowerStr;
}
public Simple getSimple()
{
try {
// Obtain the bootstrap object,
// the TOBJADDR property contains host and port to connect to.
Tobj_Bootstrap bootstrap = TP.bootstrap();
// Use the bootstrap object to find the factory finder.
org.omg.CORBA.Object fact_finder_oref =
bootstrap.resolve_initial_references("FactoryFinder");
// Narrow the factory finder.
FactoryFinder fact_finder_ref =
FactoryFinderHelper.narrow(fact_finder_oref);
// Use the factory finder to find the simple factory.
org.omg.CORBA.Object simple_fact_oref =
fact_finder_ref.find_one_factory_by_id(SimpleFactoryHelper.id());
// Narrow the simple factory.
SimpleFactory simple_factory_ref =
SimpleFactoryHelper.narrow(simple_fact_oref);
// Find the simple object.
Simple simple = simple_factory_ref.find_simple();
// everything succeeded.
return simple;
}
// catch the exceptions
return null;
}
} The OMG IDL Code for the EJB-to-CORBA/Java Simpapp Interfaces
Interface |
Description |
Operation |
Policies |
---|---|---|---|
Listing 2-1 shows the simple.idl
file that defines the CORBA interfaces in the EJB-to-CORBA/Java Simpapp sample application.
Listing 2-1
OMG IDL Code for the EJB-to-CORBA/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();
};
Perform the following steps to build and run the EJB-to-CORBA/Java Simpapp sample application:
The following sections describe these steps, and also explain the following:
Before building and running the EJB-to-CORBA/Java 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 2-1 lists the environment variables required to run the EJB-to-CORBA/Java Simpapp sample application.
Verifying the Settings of the Environment Variables
Table 2-1 Required Environment Variables for the EJB-to-CORBA/Java Simpapp Sample Application
You may optionally set the following system environment variables to change their default value prior to running the EJB-to-CORBA/Java Simpapp sample application runme
command. See the Administration Guide for more information about selecting appropriate values for these environment variables.
Table 2-2 lists the optional environment variables required to run the EJB-to-CORBA/Java Simpapp sample application.
Table 2-2 Optional Environment Variables for the EJB-to-CORBA/Java 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 EJB-to-CORBA/Java Simpapp sample application into a work directory on your local machine. The files for the EJB-to-CORBA/Java Simpapp sample application are located in the following directories under TUXDIR:
Windows NT:
$TUXDIR\samples\interop\ejb_corbaj
UNIX:
$TUXDIR/samples/interop/ejb_corbaj
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\ejb_corbaj\*.* <work_directory>
UNIX:
> cp -R $TUXDIR/samples/interop/ejb_corbaj/* <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 EJB-to-CORBA/Java Simpapp sample application files exist in the following sets:
Table 2-3 lists and describes the source files for the EJB portion of this sample application. These are the files that exist after you do the make command. These files are copied into a subdirectory named ejb
.
Table 2-3 EJB Simpapp Files
File |
Description |
---|---|
The XML file specifying the WebLogic EJB extensions to the deployment descriptor DTD.
|
|
Table 2-4 lists and describes the source files for the CORBA/Java portion of this sample application. They are copied into a subdirectory named corbaj
.
Table 2-4 CORBA/Java Simpapp Files
File |
Description |
---|---|
The OMG IDL that declares the SimpleFactory
and Simple
interfaces.
|
|
The implementation of the Server.initialize
and Server.release
methods.
|
|
Table 2-5 lists and describes the utility files for this sample application.
Table 2-5 EJB-to-CORBA/Java 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 EJB-to-CORBA/Java 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
The runme
command automates the following steps:
Changing the Protection Attribute on the Files for the EJB-to-CORBA/Java Simpapp Sample Application
Executing the runme Command
To build and run the EJB-to-CORBA 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 EJB-to-CORBA/Java 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, which is located in the ejb_corbaj working directory. You can check in the results directory for the following files:
After you have executed the runme
command, you can run the EJB-to-CORBA/Java Simpapp sample application manually if you like.
To manually run the EJB-to-CORBA/Java Simpapp sample application:
Running the Sample Application
Windows NT:
prompt>results\setenv
UNIX:
prompt>. results/setenv.ksh
Windows NT:
prompt>tmboot -y
prompt>java -classpath %CLIENTCLASSPATH% ejb.SimpClient corbaloc:%TOBJADDR%
UNIX:
prompt>tmboot -y
prompt>java -classpath ${CLIENTCLASSPATH} ejb.SimpClient corbaloc:${TOBJADDR}
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 EJB-to-CORBA/Java Simpapp sample application.
When the tmboot
command is executed to start the EJB-to-CORBA/Java Simpapp sample application, the following server processes are started:
Processes and Files Generated by the EJB-to-CORBA/Java Simpapp Sample Application
Processes Started
The following table lists and describes the files that are generated in the corbaj
working directory.
Files Generated in the corbaj Directory
The following file is generated in the ejb_corbaj
directory:
File Generated in the ejb_corbaj 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 ejb_corbaj
working directory.
Files Generated in the results Directory
File |
Description |
---|---|
Generated by the tmloadcf
command, which is executed by the runme
command.
|
|
The UBBCONFIG
file for the EJB-to-CORBA/Java Simpapp sample application.
|
|
Before using another sample application, use the following procedure to stop the EJB-to-CORBA/Java Simpapp sample application and to remove unnecessary files from the work directory.
Stopping the EJB-to-CORBA/Java 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.
|