Borland(R) Enterprise Server VisiBroker(R) デベロッパーズガイド
int main(int argc, char* const* argv) { try { // Initialize the ORB. CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); // Install untyped object wrappers TimingObjectWrapperFactory timingfact( VISObjectWrapper::Client, "timeclient"); TraceObjectWrapperFactory tracingfact( VISObjectWrapper::Client, "traceclient"); // Now locate an account manager. . . .
// UntypedClient.java import com.inprise.vbroker.interceptor.*; public class UntypedClient { public static void main(String[ ] args) throws Exception { // Initialize the ORB. org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args,null); doMain (orb, args); } public static void doMain(org.omg.CORBA.ORB orb, String[ ] args) throws Exception { ChainUntypedObjectWrapperFactory Cfactory = ChainUntypedObjectWrapperFactoryHelper.narrow( orb.resolve_initial_references( "ChainUntypedObjectWrapperFactory") ); Cfactory.add(new UtilityObjectWrappers. TimingUntypedObjectWrapperFactory(), Location.CLIENT); Cfactory.add(new UtilityObjectWrappers. TracingUntypedObjectWrapperFactory(), Location.CLIENT); // Locate an account manager. . . . } }
// UntypedServer.C #include "Bank_s.hh" #include "BankImpl.h" #include "TimeWrap.h" #include "TraceWrap.h" USE_STD_NS int main(int argc, char* const* argv) { try { // Initialize the ORB. CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); // Initialize the POA. CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var rootPoa = PortableServer::POA::_narrow(obj); CORBA::PolicyList policies; policies.length(1); policies[(CORBA::ULong)0] = rootPoa->create_lifespan_policy( PortableServer::PERSISTENT); // Get the POA Manager. PortableServer::POAManager_var poa_manager = rootPoa->the_POAManager(); // Create myPOA With the Right Policies. PortableServer::POA_var myPOA = rootPoa->create_POA("bank_ow_poa", poa_manager, policies); // Install Untyped Object Wrappers for Account Manager. TimingObjectWrapperFactory timingfact( VISObjectWrapper::Server, "timingserver"); TraceObjectWrapperFactory tracingfact( VISObjectWrapper::Server, "traceserver"); // Create the Account Manager Servant. AccountManagerImpl managerServant; // Decide on ID for Servant. PortableServer::ObjectId_var managerId = PortableServer::string_to_ObjectId("BankManager"); // Activate the Servant with the ID on myPOA. myPOA->activate_object_with_id( managerId, &managerServant); // Activate the POA Manager. rootPoa->the_POAManager()->activate(); cout << "Manager is ready." << endl; // Wait for Incoming Requests. orb->run(); } catch(const CORBA::Exception& e) { cerr << e << endl; return 1; } return 0; }
// UntypedServer.java import com.inprise.vbroker.interceptor.*; import org.omg.PortableServer.*; import com.inprise.vbroker.PortableServerExt. BindSupportPolicyValue; import com.inprise.vbroker.PortableServerExt. BindSupportPolicyValueHelper; import com.inprise.vbroker.PortableServerExt. BIND_SUPPORT_POLICY_TYPE; public class UntypedServer { public static void main(String[ ] args) throws Exception { // Initialize the ORB. org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args,null); ChainUntypedObjectWrapperFactory Sfactory = ChainUntypedObjectWrapperFactoryHelper.narrow (orb.resolve_initial_references( "ChainUntypedObjectWrapperFactory")); Sfactory.add(new UtilityObjectWrappers. TracingUntypedObjectWrapperFactory(), Location.SERVER); // get a reference to the rootPOA POA rootPOA = POAHelper. narrow(orb.resolve_initial_references("RootPOA")); // Create a BindSupport Policy that makes POA register // each servant with osagent org.omg.CORBA.Any any = orb.create_any(); BindSupportPolicyValueHelper.insert(any, BindSupportPolicyValue.BY_INSTANCE); org.omg.CORBA.Policy bsPolicy = orb.create_policy(BIND_SUPPORT_POLICY_TYPE.value, any); // Create policies for our testPOA org.omg.CORBA.Policy[ ] policies = { rootPOA.create_lifespan_policy (LifespanPolicyValue.PERSISTENT), bsPolicy }; // Create myPOA with the right policies POA myPOA = rootPOA.create_POA( "bank_agent_poa", rootPOA.the_POAManager(), policies ); // Create the account manager object. AccountManagerImpl managerServant = new AccountManagerImpl(); // Decide on the ID for the servant byte[ ] managerId = "BankManager".getBytes(); // Activate the servant with the ID on myPOA myPOA.activate_object_with_id(managerId, managerServant); // Activate the POA manager rootPOA.the_POAManager().activate(); System.out.println( "AccountManager: BankManager is ready."); for( int i = 0; i < args.length; i++ ) { if( args[i].equalsIgnoreCase("-runCoLocated") ) { if( args[i+1].equalsIgnoreCase("Client") ) { Client.doMain(orb, new String[0]); }else if( args[i+1]. equalsIgnoreCase("TypedClient") ) { TypedClient.doMain(orb, new String[0]); } if( args[i+1].equalsIgnoreCase("UntypedClient") ) { UntypedClient.doMain(orb, new String[0]); } System.exit(1); } } // Wait for incoming requests orb.run(); } }
All Rights Reserved. Copyright (C) 2006, Hitachi, Ltd.
COPYRIGHT (C) 1992-2004 Borland Software Corporation. All rights reserved.