bea ホーム | 製品 | dev2dev | support | askBEA
BEA Logo Tuxedo
 ドキュメントのダウンロード   サイトマップ   用語集 
検索
0

Tuxedo CORBA 要求レベルのインターセプタ

 Previous Next Contents Index View as PDF  

PersonQuery サンプル・アプリケーション

BEA Tuxedo ソフトウェアに同梱されたインターセプタ例を理解して使用するには、PersonQuery サンプル・アプリケーションをビルドして実行する必要があります。PersonQuery サンプル・アプリケーション自体には、インターセプタは含まれていません。しかし、このアプリケーションは、以降の 3 つの章で説明するインターセプタのサンプル・アプリケーションの基本として使用されます。

ここでは、以下の内容について説明します。

 


PersonQuery サンプル・アプリケーションのしくみ

PersonQuery サンプル・アプリケーションは、単純なデータベース問い合せインターフェイスをインプリメントします。PersonQuery アプリケーションを使用すると、データベースから次のような特定の検索基準に一致する人物の情報を取得できます。

PersonQuery アプリケーションには、次のコンポーネントが含まれます。

PersonQuery データベース

サーバ・アプリケーションの PersonQuery データベースには、データベース内の各人物に関する次の情報が含まれます。

クライアント・アプリケーションのコマンド行インターフェイス

PersonQuery サンプル・アプリケーションは、ユーザがデータベース問い合せコマンド、およびアプリケーション終了コマンドを入力できるクライアント・コンポーネントの単純なコマンド行インターフェイスをインプリメントします。

データベース問い合せコマンドの構文は次のとおりです。

Option? command [keyword] [command [keyword]]...

このコマンド構文の詳細は以下のとおりです。

 


PersonQuery サンプル・アプリケーションの OMG IDL

リスト4-1 は、PersonQuery サンプル・アプリケーションでインプリメントされている OMG IDL コードを示します。

コード リスト 4-1 PersonQuery アプリケーションのインターフェイス用 OMG IDL

#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);
};

 


PersonQuery サンプル・アプリケーションのビルドと実行

PersonQuery サンプル・アプリケーションをビルドして実行するには、以下の手順に従います。

  1. PersonQuery サンプル・アプリケーションのファイルを作業ディレクトリにコピーします。

  2. PersonQuery サンプル・アプリケーションのファイルの保護を変更します。

  3. 環境変数を設定します。

  4. CORBA クライアントおよびサーバのサンプル・アプリケーションをビルドします。

  5. PersonQuery クライアントおよびサーバ・アプリケーションを起動します。

  6. クライアント・アプリケーションを使用して、サーバ上のデータベースを検索するためのいくつかのコマンドを入力します。

  7. PersonQuery サンプル・アプリケーションを停止します。

PersonQuery サンプル・アプリケーション用ファイルのコピー

要求レベルのインターセプタのサンプル・アプリケーション用ファイルは、次のディレクトリに格納されています。

$TUXDIR¥samples¥corba¥interceptors_cxx

これらのファイルをビルドおよび実行できるようにコピーするには、次の手順に従います。

  1. サンプル・ファイルのコピー先となる作業ディレクトリを作成します。

  2. 1 つ前の手順で作成した作業ディレクトリに interceptors_cxx サンプルをコピーします。

Windows 2000

> xcopy /s/i %TUXDIR%¥samples¥corba¥interceptors_cxx <workdirectory>¥cxx

UNIX

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

  1. サンプル・ファイルが格納された作業ディレクトリに移動します。

Windows 2000

> cd <workdirectory>¥cxx

UNIX

> cd <workdirectory>/cxx

PersonQuery サンプル・アプリケーションには 表 4-2 でリストおよび説明されているファイルを使用します。

表 4-2 インターセプタのサンプル・アプリケーションに含まれるファイル

ディレクトリ

ファイル

説明

app_cxx (interceptors_cxx のサブディレクトリ)

Readme.txt

インターセプタのサンプル・アプリケーション一式のビルドと実行に関する最新情報が記載されたファイル。

makefile.mk

UNIX システムでインターセプタのサンプル・アプリケーション一式すべて (PersonQuery アプリケーションおよび全サンプル・インターセプタ) をビルドするための makefile。

makefile.nt

Windows 2000 システムでインターセプタのサンプル・アプリケーション一式すべて (PersonQuery アプリケーションおよび全サンプル・インターセプタ) をビルドするための makefile。

makefile.inc

適切な platform.inc ファイルで定義されるマクロを使用する、一般的な makefile。

personquery_i.h and
personquery_i.cpp

PersonQuery インターフェイスのインプリメンテーション。

personqueryc.cpp

PersonQuery アプリケーションのソース・ファイル。

personquerys.cpp

PersonQuery データベース・サーバのソース・ファイル。

setenv.ksh

UNIX システムでインターセプタのサンプル・アプリケーション一式すべてをビルドするために必要な全環境変数を設定するシェル・ファイル。

setenv.cmd

Windows 2000 システムでインターセプタのサンプル・アプリケーション一式すべてをビルドするために必要な全環境変数を設定するコマンド・ファイル。

data_cxx
(subdirectory under interceptors_cxx)

InterceptorData.cpp

InterceptorData C++ ソース・ファイル。

InterceptorData.h

InterceptorData クラスの定義ファイル。

makefile.inc

InterceptorData インターセプタのビルドに、適切な platform.inc ファイルで定義されたマクロを使用する、一般的な makefile。

makefile.mk

UNIX システムで InterceptorData インターセプタをビルドする makefile。

makefile.nt

Windows 2000 システムで InterceptorData インターセプタをビルドする makefile。

simple_cxx(interceptors_cxx のサブディレクトリ)

InterceptorSimp.cpp

InterceptorData C++ ソース・ファイル。

InterceptorSimp.h

InterceptorSimp クラスの定義ファイル。

makefile.inc

InterceptorSimp インターセプタのビルドに、適切な platform.inc ファイルで定義されたマクロを使用する、一般的な makefile。

makefile.mk

UNIX システムで InterceptorSimp インターセプタをビルドする makefile。

makefile.nt

Windows 2000 システムで InterceptorSimp インターセプタをビルドする makefile。

security_cxx(interceptors_cxx のサブディレクトリ)

InterceptorSec.cpp

InterceptorSec C++ ソース・ファイル。

InterceptorSec.h

InterceptorSec クラスの定義ファイル。

makefile.inc

InterceptorSec インターセプタのビルドに、適切な platform.inc ファイルで定義されたマクロを使用する、一般的な makefile。

makefile.mk

UNIX システムで InterceptorSec インターセプタをビルドする makefile。

makefile.nt

Windows 2000 システムで InterceptorSec インターセプタをビルドする makefile。

common (interceptors_cxx のサブディレクトリ)

app.inc

アプリケーションのコンフィギュレーションのための makefile 定義を含むファイル。

platform.inc

インターセプタのサンプル・アプリケーション一式をビルドするための、プラットフォーム固有の make 定義が含まれるファイル。platform は、使用しているマシンのシステム・プラットフォームを表します。

common.mk

UNIX システムの makefile 定義が含まれるファイル。

makefile.inc

適切な platform.inc ファイルで定義されるマクロを使用する、一般的な makefile。

makefile.mk

UNIX システムでサンプル・アプリケーション用ファイル一式すべてをビルドする makefile。

makefile.nt

Windows システムでサンプル・アプリケーション用ファイル一式すべてをビルドする makefile。

personquery.idl

PersonQuery サンプル・アプリケーションのインターフェイスを定義する OMG IDL ファイル。


 

PersonQuery アプリケーション・ファイルに対する保護の変更

BEA Tuxedo ソフトウェアのインストール時には、サンプル・アプリケーションは読み取り専用に設定されています。PersonQuery サンプル・アプリケーションのファイルを編集またはビルドできるようにするには、次のように作業ディレクトリにコピーしたファイルの保護属性を変更する必要があります。まず、サンプル・アプリケーションのファイルをコピーしたディレクトリにアクセスしていることを確認します。

Windows 2000

prompt>attrib -r /s *.* 

UNIX

prompt>/bin/ksh 
ksh prompt>chmod -R u+w *.*

環境変数を設定する

PersonQuery サンプル・アプリケーションをビルドして実行する前に、アプリケーションが実行される環境を設定する必要があります。PersonQuery サンプル・アプリケーションのビルドと実行に必要な環境変数およびプロパティの設定を行うには、次のコマンドを入力します。

Windows 2000

> setenv.cmd

UNIX:

> $ . ./setenv.ksh

CORBA クライアントおよびサーバ・アプリケーションのビルド

次のコマンドにより、PersonQuery アプリケーションをビルドし、マシン固有の UBBCONFIG ファイルを作成し、UBBCONFIG ファイルをロードできます。

Windows 2000

> nmake -f makefile.nt

UNIX

$ make -f makefile.mk

注記 便宜上、この手順で実行される makefile によってインターセプタのサンプル一式すべてをビルドします。これには、InterceptorSimp、InterceptorSec、および InterceptorData インターセプタも含まれます。これらのインターセプタのインプリメントとビルド、および PersonQuery サンプル・アプリケーションによる実行については、以降の章で説明します。

PersonQuery クライアントおよびサーバ・アプリケーションの起動

次のコマンドを入力して、PersonQuery サンプル・アプリケーションを起動します。

prompt> tmboot -y

PersonQuery サンプル・アプリケーションの実行

PersonQuery サンプル・アプリケーションの代表的な使用方法として、次の手順に従います。

  1. 次の例のように、1 つの特性について問い合せコマンドを入力し、返された項目数を確認します。
    Option? hair brown eyes blue

  2. 1 つ前の手順で問い合せを行った特性に関し、さらに問い合せデータを入力します。

  3. すべての問い合せデータが必要なレベルに絞られるまで、問い合せを続行します。

  4. result コマンドを入力して、最終的な問い合せ結果を表示します。

  5. 新しい問い合せサイクルを開始します。

  6. exit コマンドを入力して、アプリケーションを終了します。

PersonQuery サンプル・アプリケーションの停止

PersonQuery サンプル・アプリケーションを停止するには、次のコマンドを入力します。

prompt>tmshutdown -y

 

Back to Top Previous Next
Contact e-docsContact BEAwebmasterprivacy