Borland(R) Enterprise Server VisiBroker(R) デベロッパーズガイド
Requestオブジェクトはオペレーション,引数,および結果に対応するすべてのメモリの所有権を保持し,プログラマがそれらの項目を解放しないようにします。コードサンプル17-7にRequestオブジェクトの生成例(C++),コードサンプル17-8にRequestオブジェクトの生成例(Java)を示します。
. . . CORBA::NamedValue_ptr result; CORBA::Any_ptr resultAny; CORBA::Request_var req; CORBA::Any customer; . . . try { req = account->_request("balance"); // Create argument to request customer <<= (const char *) name; CORBA::NVList_ptr arguments = req->arguments(); arguments->add_value("customer", customer, CORBA::ARG_IN); // Set result result = req->result(); resultAny = result->value(); resultAny->replace(CORBA::_tc_float, &result); } catch(CORBA::Exception& excep) { . . .
// Client.java public class Client { public static void main(String[ ] args) { if (args.length ! = 2) { System.out.println( "Usage: vbj Client <manager-name> <account-name>\n"); return; } String managerName = args[0]; String accountName = args[1]; org.omg.CORBA.Object accountManager, account; org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null); accountManager = orb.bind("IDL:Bank/AccountManager:1.0", managerName, null, null); org.omg.CORBA.Request request = accountManager._request("open"); request.add_in_arg().insert_string(accountName); request.set_return_type(orb.get_primitive_tc( org.omg.CORBA.TCKind.tk_objref) ); request.invoke(); account = request.result().value().extract_Object(); org.omg.CORBA.Request request = account._request("balance"); request.set_return_type(orb.get_primitive_tc( org.omg.CORBA.TCKind.tk_float) ); request.invoke(); float balance = request.result().value().extract_float(); System.out.println("The balance in " + accountName + "'s account is $" + balance); } }
All Rights Reserved. Copyright (C) 2008, Hitachi, Ltd.
COPYRIGHT (C) 1992-2004 Borland Software Corporation. All rights reserved.