Table of Contents Previous Next PDF


PersonQuery Sample Application

PersonQuery Sample Application
To understand and use the interceptor examples packaged with the Oracle 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:
Notes:
Technical support for third party CORBA Java ORBs should be provided by their respective vendors. Oracle Tuxedo does not provide any technical support or documentation for third party CORBA Java ORBs.
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? is the PersonQuery command prompt.
command is one of the PersonQuery commands from Table 4‑1.
keyword is one of the keywords from Table 4‑1. Note the following rules on specifying keywords:
Option? name "Thomas Mann"
Option? address "116 Einbahnstrasse, Frankfurt am Main, BRD"
Option? hair brown eyes blue
 
Queries by sex. Choices are male, female, and cant_tell.
Queries by marital status. Choices are married, single, divorced, and not_known.
Queries by hobby. Choices are who_cares, rocks, swim, tv, stamps, photo, and weaving.
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:
1.
2.
3.
4.
5.
6.
7.
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:
1.
2.
Copy the interceptors_cxx samples to the working directory created in the previous step:
Windows 2003
> xcopy /s/i %TUXDIR%\samples\corba\interceptors_cxx <workdirectory>\cxx
UNIX
> cp -R $TUXDIR/samples/corba/interceptors_cxx <workdirectory>/cxx
3.
Windows 2003
> cd <workdirectory>\cxx
UNIX
> cd <workdirectory>/cxx
You will use the files listed and described in Table 4‑2 in the PersonQuery sample application.
 
app_cxx (subdirectory under interceptors_cxx)
data_cxx
(subdirectory under interceptors_cxx)
The generic makefile that uses the macros defined in the appropriate platform.inc file to build the InterceptorData interceptors.
simple_cxx (subdirectory under interceptors_cxx)
The generic makefile that uses the macros defined in the appropriate platform.inc file to build the InterceptorSimp interceptors.
security_cxx (subdirectory under interceptors_cxx)
The generic makefile that uses the macros defined in the appropriate platform.inc file to build the InterceptorSec interceptors.
common (subdirectory under interceptors_cxx)
Changing the Protection on PersonQuery Application Files
During the installation of the Oracle 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 2003
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 2003
> 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 2003
> nmake -f makefile.nt
UNIX
$ make -f makefile.mk
Note:
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:
1.
Option? hair brown eyes blue
2.
3.
4.
Enter the result command to see the final query result.
5.
6.
Enter the exit command to quit from the application.
Stopping the PersonQuery Sample Application
To stop the PersonQuery sample application, enter the following command:
prompt>tmshutdown -y
 

Copyright © 1994, 2017, Oracle and/or its affiliates. All rights reserved.