|
|
PersonQuery Sample Application
To understand and use the interceptor examples packaged with the WLE 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:
Note: The WebLogic Enterprise software provides C++ versions of both the client and server components of the PersonQuery sample application. However, only the server component of the PersonQuery sample application is provided in Java; there is no Java version of the PersonQuery client component. To build and run the Java version of the PersonQuery server application, you also need to build and run the C++ version of the PersonQuery client application.
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.
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 5-1 PersonQuery Application Commands and Keywords
Command |
Keyword |
Description |
---|---|---|
name |
"firstname lastname" |
Queries by name. Strings with spaces must be quoted. |
address |
"number street, city..." |
Queries by address. Strings with spaces must be quoted. Address parts are street number, street, town, state, and country. Entries for street, town, state, and country must be separated by commas. |
ss |
xxx-xx-xxxx |
Queries by U.S. Social Security number. The keyword must in the form xxx-xx-xxxx. |
sex |
sex |
Queries by sex. Choices are male, female, and cant_tell. |
age |
age |
Queries by age. |
marriage |
status |
Queries by marital status. Choices are married, single, divorced, and not_known. |
hobby |
hobby |
Queries by hobby. Choices are who_cares, rocks, swim, tv, stamps, photo, and weaving. |
dob |
mm/dd/yyyy |
Queries by date. The keyword must be in the form mm/dd/yyyy. |
height |
inches |
Queries by height, in inches. |
weight |
pounds |
Queries by weight, in pounds. |
hair |
color |
Queries by hair color. Choices are white, black, red, brown, green, yellow, blue, gray, and unknown. |
skin |
color |
Queries by skin color. Choices are white, black, brown, yellow, green, and red. |
eyes |
color |
Queries by eye color. Choices are blue, brown, gray, green, violet, black, and hazel. |
other |
feature |
Queries by other physical features. Choices are tattoo, limb (that is, a limb is missing), scar, and none. |
result |
|
Displays the result of last query on output. |
exit |
|
Displays bill for services rendered and closes application. |
The OMG IDL for the PersonQuery Sample Application
Listing 5-1 provides the OMG IDL code for the implemented in the PersonQuery sample application:
Listing 5-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 findPers
Building and Running the PersonQuery Sample Application
Regardless of whether you plan to experiment with the C++ or Java samples, you need to perform the steps described in this section. If you are planning to run the Java samples, complete the steps described in this section, then also complete the steps described in the section Building and Running the Java RLI Sample Applications.
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 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 NT
> 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 NT
> cd <workdirectory>\cxxUNIX
> cd <workdirectory>/cxxYou will use the files listed and described in Table 5-2 in the PersonQuery sample application.
Table 5-2 Files Included in the C++ Interceptors Sample Applications
Directory
File
Description
app_cxx (subdirectory under interceptors_cxx)
Readme.txt
The file that provides the latest information about building and running the set of interceptor sample applications.
makefile.mk
The makefile for building the entire set of interceptor sample applications (the PersonQuery application and all the sample interceptors) on UNIX systems.
makefile.nt
The makefile for building the entire set of interceptors sample applications (the PersonQuery application and all the sample interceptors) on Windows NT systems.
makefile.inc
The generic makefile that uses the macros defined in the appropriate platform.inc file.
personquery_i.h and
personquery_i.cppThe implementation of the PersonQuery interfaces.
personqueryc.cpp
The PersonQuery client application source file.
personquerys.cpp
The PersonQuery database server source file.
setenv.ksh
The shell file that sets all the required environment variables for building the entire set of interceptor sample applications on UNIX systems.
setenv.cmd
The command file that sets all the required environment variables for building the entire set of interceptor sample applications on Windows NT systems.
data_cxx
(subdirectory under interceptors_cxx)InterceptorData.cpp
The InterceptorData C++ source file.
InterceptorData.h
The InterceptorData class definition file.
makefile.inc
The generic makefile that uses the macros defined in the appropriate platform.inc file to build the InterceptorData interceptors.
makefile.mk
The makefile that builds the InterceptorData interceptors on UNIX systems.
makefile.nt
The makefile that builds the InterceptorData interceptors on Windows NT systems.
simple_cxx (subdirectory under interceptors_cxx)
InterceptorSimp.cpp
The InterceptorSimp C++ source file.
InterceptorSimp.h
The InterceptorSimp class definition file.
makefile.inc
The generic makefile that uses the macros defined in the appropriate platform.inc file to build the InterceptorSimp interceptors.
makefile.mk
The makefile that builds the InterceptorSimp interceptors on UNIX systems.
makefile.nt
The makefile that builds the InterceptorSimp interceptors on Windows NT systems.
security_cxx (subdirectory under interceptors_cxx)
InterceptorSec.cpp
The InterceptorSec C++ source file.
InterceptorSec.h
The InterceptorSec class definition file.
makefile.inc
The generic makefile that uses the macros defined in the appropriate platform.inc file to build the InterceptorSec interceptors.
makefile.mk
The makefile that builds the InterceptorSec interceptors on UNIX systems.
makefile.nt
The makefile that builds the InterceptorSec interceptors on Windows NT systems.
common (subdirectory under interceptors_cxx)
app.inc
The file that contains the makefile definitions for the application configuration.
platform.inc
The file that contains platform-specific make definitions for building the set of interceptor sample applications, where platform represents the system platform for the machine you are using.
common.mk
The file that contains makefile definitions for UNIX systems.
makefile.inc
The generic makefile that uses the macros defined in the appropriate platform.inc file.
makefile.mk
The makefile that builds the entire C++ set of sample application files on UNIX systems.
makefile.nt
The makefile that builds the entire C++ set of sample application files on NT systems.
personquery.idl
The OMG IDL file that defines the interfaces for the PersonQuery sample application.
Changing the Protection on PersonQuery Application Files
During the installation of the WebLogic Enterprise 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 NT
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 NT
> setenv.cmdUNIX:
> $ . ./setenv.kshBuilding the Client and Server Applications
The following command builds the PersonQuery application, creates a machine-specific UBBCONFIG file, and loads the UBBCONFIG file:
Windows NT
> nmake -f makefile.ntUNIX
$ make -f makefile.mkNote: For convenience, the makefile executed in this step builds the entire C++ 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 -yRunning the PersonQuery Sample Application
A typical usage scenario of the PersonQuery sample application involves the following steps:
- Enter a query command for one feature, and check for number of returned items, for example:
Option? hair brown eyes blue
- Enter additional query data about the feature queried in the preceding step.
- Continue queries until all the query data is narrowed down to a desirable level.
- Enter the result command to see the final query result.
- Start a new query cycle.
- 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
Building and Running the Java RLI Sample Applications
If you want to run the Java RLI sample applications provided with the WebLogic Enterprise software, make sure you have completed all the steps described in the section Building and Running the PersonQuery Sample Application before you complete any of the steps described in the procedure that follows. The Java RLI sample application is a server-side-only implementation, and it uses the C++ PersonQuery client application, which needs to be built so that the Java RLI sample applications can work.
To build and run the PersonQuery sample application:
- Copy the files for the Java PersonQuery samples into a work directory.
- Change the protection on the files for the Java PersonQuery samples.
- Set the environment variables.
- Build the server sample applications.
- Start the PersonQuery client and server applications.
- Stop the PersonQuery sample application.
Copying the Files for the Java PersonQuery Samples
The Java request-level interceptor sample application files are located in the following directory:
$TUXDIR\samples\corba\interceptors_javaTo 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_java samples to the working directory created in the previous step:
Windows NT
> xcopy /s/i %TUXDIR%\samples\corba\interceptors_java <workingdirectory>\javaUNIX
> cp -R $TUXDIR/samples/corba/interceptors_java <workingdirectory>/java
- Change to the directory containing the sample files:
Windows NT
> cd <workingdirectory>\javaUNIX
> cd <workingdirectory>/javaYou will use the files listed and described in Table 5-2.
Table 5-3 Files Included in the Java Interceptors Sample Directory
Directory
File
Description
interceptors_java
Readme.txt
The file that provides the latest information about building and running the set of Java interceptor sample applications.
makefile.mk
The makefile for building the Java interceptor sample applications (the Java PersonQuery server application and the sample interceptor) on UNIX systems.
makefile.nt
The makefile for building the Java interceptor sample applications (the Java PersonQuery server application and the sample interceptor) on NT systems.
setenv.ksh
The shell file that sets all the required environment variables for building the Java interceptor samples on UNIX systems.
setenv.cmd
The command file that sets all the required environment variables for building the Java samples on Windows NT systems.
Query.idl
Contains the Object Management Group (OMG) Interface Definition Language (IDL) file for the PersonQuery application.
Query.xml
Contains the Server Description File for the PersonQuery server application.
ServerImpl.java
Contains the implementation of the Server object for the PersonQuery server application.
QueryFactoryImpl.java
Contains the implementation of the PersonQuery factory object.
PersonQueryImpl.java
Contains the implementation of the PersonQuery application interfaces.
DataPackage
(subdirectory under interceptors_java)InterceptorData.java
Contains the implementation of the Java InterceptorData sample interceptor.
SimplePackage (subdirectory under interceptors_java)
InterceptorSimple.
javaContains the implementation of the Java InterceptorSimple sample interceptor.
SecurityPackage (subdirectory under interceptors_java)
InterceptorSecurity.
javaContains the implementation of the Java InterceptorSecurity sample interceptor.
Changing the Protection on PersonQuery Application Files
During the installation of the WebLogic Enterprise software, the sample application files are marked read-only. Before you can edit or build the files in the Java 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 containing the sample files you copied.
Windows NT
prompt>attrib -r /s *.*UNIX
prompt>/bin/ksh
ksh prompt>chmod -R u+w *.*Setting the Environment Variables
Before building and running the Java PersonQuery server 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 server application, enter the following command:
Windows NT
> setenv.cmdUNIX
> $ . ./setenv.kshBuilding the Server Application
The following command builds the Java PersonQuery server application, creates a machine-specific UBBCONFIG file, and loads the UBBCONFIG file:
Windows NT
> nmake -f makefile.ntUNIX
$ make -f makefile.mkNote: For convenience, the makefile executed in this step builds the set of Java RLI samples. This includes the Java InterceptorSimp, InterceptorSec, and InterceptorData interceptors as well as the Java PersonQuery server application. Details on implementing and building those interceptors, as well as running them with the PersonQuery client 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 -yNote: The Java PersonQuery server application uses the C++ PersonQuery client application.
Running the PersonQuery Sample Application
A typical usage scenario of the PersonQuery sample application involves the following steps:
- Using the C++ PersonQuery client application, enter a query command for one feature, and check for number of returned items, for example:
Option? hair brown eyes blue
- Enter additional query data about the feature queried in the preceding step.
- Continue queries until all the query data is narrowed down to a desirable level.
- Enter the result command to see the final query result.
- Start a new query cycle.
- 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 © 2000 BEA Systems, Inc. All rights reserved.
Required browser: Netscape 4.0 or higher, or Microsoft Internet Explorer 4.0 or higher.