![]() |
![]() |
|
|
PersonQuery Sample Application
To understand and use the interceptor examples packaged with the BEA Tuxedo software, you need to build and run the PersonQuery sample application. The PersonQuery sample application itself does not contain any interceptors; however, this application is used as the basis for the sample interceptor applications that are described in the three chapters that follow.
This topic includes the following sections:
How the PersonQuery Sample Application Works
The PersonQuery sample application implements a simple database query interface. Using the PersonQuery application, a user can get information about people in the database that match specific search criteria, such as:
The PersonQuery application contains the following components:
When the client application receives the result of the query from the server, it will report the number of items that were found. The user can then enter the command that displays the result of the latest query, or specify a new query.
PersonQuery Database
The PersonQuery database in the server application contains the following information about each person in the database:
Client Application Command-line Interface
The PersonQuery sample application implements a simple command-line interface in the client component with which the user can enter database query commands and the command to exit from the application.
The database query commands have the following syntax:
Option? command [keyword] [command [keyword]]...
In this command syntax:
Option? name "Thomas Mann"
Option? address "116 Einbahnstrasse, Frankfurt am Main, BRD"
Option? hair brown eyes blue
Table 4-1 PersonQuery Application Commands and Keywords
The OMG IDL for the PersonQuery Sample Application
Listing 4-1 provides the OMG IDL code for the implemented in the PersonQuery sample application.
Listing 4-1 OMG IDL Code for the PersonQuery Application Interfaces
#pragma prefix "beasys.com"
interface PersonQuery
{
enum MONTHS {Empty,Jan, Feb, Mar, Apr, May, Jun, Jul, Aug,
Sep, Oct, Nov, Dec};
struct date_ {
MONTHS Month;
short Day;
short Year;
};
typedef date_ Date;
struct addr_ {
short number;
string street;
string town;
string state;
string country;
};
typedef addr_ Address;
enum MARRIAGE {not_known, single, married, divorced};
enum HOBBIES {who_cares, rocks, swim, tv, stamps, photo,
weaving};
enum SEX {cant_tell, male, female};
enum COLOR {white, black, brown, yellow, red, green, blue,
gray, violet, hazel, unknown, dontcare};
enum MARKINGS {dont_care, tattoo, scar, missing_limb,
none};
struct person_ {
string name;
Address addr;
string ss;
SEX sex;
short age;
MARRIAGE mar;
HOBBIES rec;
Date dob;
short ht;
long wt;
COLOR hair;
COLOR eye;
COLOR skin;
MARKINGS other;
};
typedef person_ Person;
typedef sequence <Person> Possibles;
union reason_ switch (short)
{
case 0: string name;
case 1: Address addr;
case 2: string ss;
case 3: SEX sex;
case 4: short age;
case 5: MARRIAGE mar;
case 6: HOBBIES rec;
case 7: Date dob;
case 8: short ht;
case 9: long wt;
case 10: COLOR hair;
case 11: COLOR eyes;
case 12: COLOR skin;
case 13: MARKINGS other;
};
typedef reason_ Reason;
exception DataOutOfRange
{
Reason why;
};
boolean findPerson (
in Person who, out Possibles hits)
raises (DataOutOfRange);
boolean findPersonByName (
in string name, out Possibles hits)
raises (DataOutOfRange);
boolean findPersonByAddress (
in Address addr, out Possibles hits)
raises (DataOutOfRange);
boolean findPersonBySS (
in string ss, out Possibles hits)
raises (DataOutOfRange);
boolean findPersonByAge (
in short age, out Possibles hits)
raises (DataOutOfRange);
boolean findPersonByMarriage (
in MARRIAGE mar, out Possibles hits)
raises (DataOutOfRange);
boolean findPersonByHobbies (
in HOBBIES rec, out Possibles hits)
raises (DataOutOfRange);
boolean findPersonBydob (
in Date dob, out Possibles hits)
raises (DataOutOfRange);
boolean findPersonByHeight (
in short ht, out Possibles hits)
raises (DataOutOfRange);
boolean findPersonByWeight (
in long wt, out Possibles hits)
raises (DataOutOfRange);
boo
Building and Running the PersonQuery Sample Application
To build and run the PersonQuery sample application:
- Copy the files for the PersonQuery sample application into a work directory.
- Change the protection of the files for the PersonQuery sample application.
- Set the environment variables.
- Build the CORBA client and server sample applications.
- Start the PersonQuery client and server applications.
- Using the client application, enter a number of commands to search the database on the server.
- Stop the PersonQuery sample application.
Copying the Files for the PersonQuery Sample Application
The request-level interceptor sample application files are located in the following directory:
$TUXDIR\samples\corba\interceptors_cxxTo create a copy of these files so that you can build them and run them, do the following:
- Create a working directory into which to copy the sample files.
- Copy the interceptors_cxx samples to the working directory created in the previous step:
Windows 2000
> xcopy /s/i %TUXDIR%\samples\corba\interceptors_cxx <workdirectory>\cxxUNIX
> cp -R $TUXDIR/samples/corba/interceptors_cxx <workdirectory>/cxx
- Change to the working directory containing the sample files:
Windows 2000
> cd <workdirectory>\cxxUNIX
> cd <workdirectory>/cxxYou will use the files listed and described in Table 4-2 in the PersonQuery sample application.
Table 4-2 Files Included in the Interceptors Sample Applications
Changing the Protection on PersonQuery Application Files
During the installation of the BEA Tuxedo software, the sample application files are marked read-only. Before you can edit or build the files in the PersonQuery sample application, you need to change the protection attribute of the files you copied into your work directory, as follows. First make sure you are in the working directory into which you copied the sample application files.
Windows 2000
prompt>attrib -r /s *.*
UNIX
prompt>/bin/ksh
ksh prompt>chmod -R u+w *.*
Setting the Environment Variables
Before building and running the PersonQuery sample application, you need to set the environment in which the application runs. To set the environment variables and other property settings needed to build and run the PersonQuery sample application, enter the following command:
Windows 2000
> setenv.cmd
UNIX:
> $ . ./setenv.ksh
Building the CORBA Client and Server Applications
The following command builds the PersonQuery application, creates a machine-specific UBBCONFIG file, and loads the UBBCONFIG file:
Windows 2000
> nmake -f makefile.nt
UNIX
$ make -f makefile.mk
Note: For convenience, the makefile executed in this step builds the entire set of interceptor samples. This includes the InterceptorSimp, InterceptorSec, and InterceptorData interceptors as well. Details on implementing and building those interceptors, as well as running them with the PersonQuery sample application, are provided in the chapters that follow.
Start the PersonQuery Client and Server Applications
Start the PersonQuery sample application by entering the following command:
prompt> tmboot -y
Running the PersonQuery Sample Application
A typical usage scenario of the PersonQuery sample application involves the following steps:
Option? hair brown eyes blue
Stopping the PersonQuery Sample Application
To stop the PersonQuery sample application, enter the following command:
prompt>tmshutdown -y
![]() |
![]() |
![]() |
|
Copyright © 2001 BEA Systems, Inc. All rights reserved.
|