![]() |
![]() |
|
|
Using the CORBA Name Service Sample Application
This topic includes the following sections:
How the Name Service Sample Application Works
The CORBA Name Service sample application is a modification of the Simpapp sample application. This sample application provides a CORBA C++ client and server, and a CORBA Java client. The Name Service sample application uses a namespace to store the SimpleFactory object. The server application creates the SimpleFactory object and binds the object to the namespace. The client application connects to the namespace, resolves the name of the SimpleFactory object, and then invokes methods on the SimpleFactory. Figure 5-1 illustrates how the Name Service sample application works.
Figure 5-1 The Name Service Sample Application
The Name Service sample application implements the CORBA interfaces listed in Table 5-1:
Listing 5-1 shows the simple.idl file that defines the CORBA interfaces in the Name Service sample application.
Listing 5-1 OMG IDL Code for the Name Service 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 Name Service Sample Application
To build and run the Name Service sample application, complete the following steps:
Step 1: Copy the Files for the Name Service Sample Application into a Work Directory
Copy the files for the Name Service sample application into a work directory on your local machine. Running the sample application in a work directory allows you to identify the files that are created when the sample is executed. The following sections detail the directory location and sources files for the the Name Service sample application.
CORBA C++ Client and Server, and CORBA Java Client Version of the Name Service Sample Application
The files for the Name Service sample application are located in the following directories:
Windows
drive:\tuxdir\samples\corba\cnssimpapp
UNIX
/usr/local/tuxdir/samples/corba/cnssimpapp
Use the files listed in Table 5-2 to build and run the Name Service sample application.
Step 2: Change the Protection Attribute on the Files for the Name Service Sample Application
The files for the sample application are installed with a permission level of read only. Before you can edit or build the files in the Name Service sample application, you must change the protection attribute of the files you copied into your work directory, as follows:
Windows
prompt> attrib -r drive:\workdirectory\*.*
UNIX
On UNIX platforms, you also need to change the permission of runme.ksh to allow execute permission, as follows:
ksh prompt> chmod +x runme.ksh
Step 3: Verify the Settings of the Environment Variables
Before running the Name Service sample application, you need to verify that certain environment variables are defined to correct locations. In most cases, these environment variables are set as part of the installation procedure. Some environment variables are set when you execute the runme command. You need to check the environment variables to ensure they reflect correct information.
Table 5-3 lists the environment variables required to run the Name Service sample application.
To verify that the information for the environment variables defined during installation is correct, complete the following steps:
Windows
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 settings, complete the following steps:
Windows
UNIX
ksh prompt> export TUXDIR=directorypath
ksh prompt> export JAVA_HOME=directorypath
Step 4: Execute the runme Command
The runme command completes the following steps end-to-end:
Note: You can also run the Name Service sample application manually. The steps for manually running the Name Service sample application are described in the Readme.txt file.
To build and run the Name Service sample application, enter the runme command, as follows:
Windows
prompt> cd workdirectory
prompt> runme
UNIX
ksh prompt> cd workdirectory
ksh prompt> ./runme.ksh
When the Name Service sample application runs successfully from start to finish, this series of messages is printed:
Testing NameService simpapp
cleaned up
prepared
built
loaded ubb
booted
ran
shutdown
saved results
PASSED
Table 5-4 lists the files in the work directory generated by the runme command.
Table 5-5 lists the Java files in the work directory generated by the runme command.
Table 5-6 lists files in the results directory generated by the runme command.
Using the Name Service Sample Application
Run the server application in the Name Service sample application, as follows:
Windows
prompt> tmboot
UNIX
ksh prompt> tmboot
Run the client application in the Name Service sample application, as follows:
Windows
prompt> java -classpath %CLIENTCLASSPATH%
-DTOBJADDR=%TOBJADDR% SimpleClient
String?
Hello World
HELLO WORLD
hello world
UNIX
ksh prompt> java -classpath $CLIENTCLASSPATH
/m3envobj.jar -DTOBJADDR=$TOBJADDR SimpleClient
String?
Hello World
HELLO WORLD
hello world
Before using another sample application, enter the following commands to stop the Name Service sample application and to remove unnecessary files from the work directory:
Windows
prompt> tmshutdown -y
prompt> nmake -f makefile.nt clean
UNIX
ksh prompt> tmshutdown -y
ksh prompt> make -f makefile.mk clean
![]() |
![]() |
|
Copyright © 2001 BEA Systems, Inc. All rights reserved.
|