![]() |
![]() |
e-docs > Tuxedo > Using CORBA Request-Level Interceptors > PersonQuery Sample Application |
Using CORBA Request-Level Interceptors
|
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);
boolean findPersonByHairColor (
in COLOR col, out Possibles hits)
raises (DataOutOfRange);
boolean findPersonBySkinColor (
in COLOR col, out Possibles hits)
raises (DataOutOfRange);
boolean findPersonByEyeColor (
in COLOR col, out Possibles hits)
raises (DataOutOfRange);
boolean findPersonByOther (
in MARKINGS other, out Possibles hits)
raises (DataOutOfRange);
void exit();
};
interface QueryFactory
{
PersonQuery createQuery (in string name);
};
Building and Running the PersonQuery Sample Application
To build and run 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_cxx
To create a copy of these files so that you can build them and run them, do the following:
Windows 2000
> xcopy /s/i %TUXDIR%\samples\corba\interceptors_cxx <workdirectory>\cxx
UNIX
> cp -R $TUXDIR/samples/corba/interceptors_cxx <workdirectory>/cxx
Windows 2000
> cd <workdirectory>\cxx
UNIX
> cd <workdirectory>/cxx
You 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 UNIX 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 UNIX: 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 UNIX 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: Running the PersonQuery Sample Application A typical usage scenario of the PersonQuery sample application involves the following steps:
prompt>attrib -r /s *.*
prompt>/bin/ksh
ksh prompt>chmod -R u+w *.* > setenv.cmd
> $ . ./setenv.ksh
> nmake -f makefile.nt
$ make -f makefile.mk
prompt> tmboot -y
Option? hair brown eyes blue
Stopping the PersonQuery Sample Application
To stop the PersonQuery sample application, enter the following command:
prompt>tmshutdown -y
![]() |
![]() |
![]() |
![]() |
||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |