BEA Logo BEA WebLogic Enterprise Release 5.1

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy

 

   WebLogic Enterprise Doc Home   |   CORBA Programming & Related Topics   |   Previous Topic   |   Next Topic   |   Contents   |   Index

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:

 


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:

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:

 


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:

  1. Copy the files for the PersonQuery sample application into a work directory.

  2. Change the protection of the files for the PersonQuery sample application.

  3. Set the environment variables.

  4. Build the client and server sample applications.

  5. Start the PersonQuery client and server applications.

  6. Using the client application, enter a number of commands to search the database on the server.

  7. 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_cxx

To create a copy of these files so that you can build them and run them, do the following:

  1. Create a working directory into which to copy the sample files.

  2. 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>\cxx

UNIX

> cp -R $TUXDIR/samples/corba/interceptors_cxx <workdirectory>/cxx

  1. Change to the working directory containing the sample files:

Windows NT

> cd <workdirectory>\cxx

UNIX

> cd <workdirectory>/cxx

You 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.cpp

The 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.cmd

UNIX:

> $ . ./setenv.ksh

Building 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.nt

UNIX

$ make -f makefile.mk

Note: 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 -y

Running the PersonQuery Sample Application

A typical usage scenario of the PersonQuery sample application involves the following steps:

  1. Enter a query command for one feature, and check for number of returned items, for example:

    Option? hair brown eyes blue

  2. Enter additional query data about the feature queried in the preceding step.

  3. Continue queries until all the query data is narrowed down to a desirable level.

  4. Enter the result command to see the final query result.

  5. Start a new query cycle.

  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

 


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:

  1. Copy the files for the Java PersonQuery samples into a work directory.

  2. Change the protection on the files for the Java PersonQuery samples.

  3. Set the environment variables.

  4. Build the server sample applications.

  5. Start the PersonQuery client and server applications.

  6. 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_java

To create a copy of these files so that you can build them and run them, do the following:

  1. Create a working directory into which to copy the sample files.

  2. 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>\java

UNIX

> cp -R $TUXDIR/samples/corba/interceptors_java <workingdirectory>/java

  1. Change to the directory containing the sample files:

Windows NT

> cd <workingdirectory>\java

UNIX

> cd <workingdirectory>/java

You 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.
java

Contains the implementation of the Java InterceptorSimple sample interceptor.

SecurityPackage (subdirectory under interceptors_java)

InterceptorSecurity.
java

Contains 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.cmd

UNIX

> $ . ./setenv.ksh

Building 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.nt

UNIX

$ make -f makefile.mk

Note: 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 -y

Note: 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:

  1. 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

  2. Enter additional query data about the feature queried in the preceding step.

  3. Continue queries until all the query data is narrowed down to a desirable level.

  4. Enter the result command to see the final query result.

  5. Start a new query cycle.

  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