3.6 ステップ4: CORBAクライアント・アプリケーションの記述
Oracle Tuxedoソフトウェアでは、次のタイプのCORBAクライアント・アプリケーションがサポートされています:
- CORBA C++
CORBAクライアント・アプリケーションを作成するステップは次のとおりです:
- ORBを初期化します。
- BootstrapオブジェクトまたはCORBA INSブートストラップ処理メカニズムを使用して、Oracle Tuxedoドメインとの通信を確立します。
- FactoryFinder環境オブジェクトへの初期リファレンスを解決します。
- ファクトリを使用して目的の
CORBAオブジェクトのオブジェクト参照を取得します。 - CORBAオブジェクトのメソッドを呼び出します。
CORBAクライアントの開発ステップは、次のリストで説明されています。これらのリストの内容は、Simpappサンプルのアプリケーションのコードです。Simpappサンプル・アプリケーションのCORBAクライアント・アプリケーションは、ファクトリを使用してSimpleオブジェクトのオブジェクト参照を取得し、Simpleオブジェクトのto_upper()メソッドとto_lower()メソッドを呼び出します。
次に、Simpappサンプル・アプリケーションのCORBAクライアント・アプリケーションを示すコード・スニペットを示します。
int main(int argc, char * argv[]) {
try {
// Initialize the ORB
CORBA::ORB_var var_orb = CORBA::ORB_init(argc, argv, "");
// Create the Bootstrap object
Tobj_Bootstrap bootstrap(var_orb.in(), "");
// Use the Bootstrap object to find the FactoryFinder
CORBA::Object_var var_factory_finder_oref =
bootstrap.resolve_initial_references("FactoryFinder");
// Narrow the FactoryFinder
Tobj::FactoryFinder_var var_factory_finder_reference =
Tobj::FactoryFinder::_narrow(var_factory_finder_oref.in());
// Use the factory finder to find the Simple factory
CORBA::Object_var var_simple_factory_oref =
var_factory_finder_reference - > find_one_factory_by_id(
_tc_SimpleFactory - > id()
);
// Narrow the Simple factory
SimpleFactory_var var_simple_factory_reference =
SimpleFactory::_narrow(
var_simple_factory_oref.in());
// Find the Simple object
Simple_var var_simple =
var_simple_factory_reference - > find_simple();
// Get a string from the user
cout << "String?";
char mixed[256];
cin >> mixed;
// Convert the string to upper case :
CORBA::String_var var_upper = CORBA::string_dup(mixed);
var_simple - > to_upper(var_upper.inout());
cout << var_upper.in() << endl;
// Convert the string to lower case
CORBA::String_var var_lower = var_simple - > to_lower(mixed);
cout << var_lower.in() << endl;
return 0;
}
}