1 / 7

// messenger.idl interface Messenger { boolean send_message (

// messenger.idl interface Messenger { boolean send_message ( in string user_name, in string subject, inout string message ); };. module BankExample { interface Account { exception BadCheck { float fee; };

lea
Télécharger la présentation

// messenger.idl interface Messenger { boolean send_message (

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. // messenger.idl interface Messenger { boolean send_message ( in string user_name, in string subject, inout string message ); };

  2. module BankExample { interface Account { exception BadCheck { float fee; }; float deposit(in float amount); float writeCheck(in float amount) raises (BadCheck); }; interface AccountManager { Account openAccount(in string name); }; };

  3. IDL File Client Object Implementation (Servant) IDL Stub IDL Skeleton Request Object Request Broker CORBA Diagram (c) 2001 A. David McKinnon, used with permission

  4. #include <Messenger_skel.h> class Messenger_impl : public POA_Messenger, public PortableServer::RefCountServantBase { public: virtual bool send_message (const char* user_name, const char* subject, char*& message) throw(CORBA::SystemException); };

  5. int main(int argc, char *argv[]) { int status = EXIT_SUCCESS; CORBA::ORB_var orb; try { orb = CORBA::ORB_init(argc,argv); status = run(orb); } catch(const CORBA::Exception&) { status = EXIT_FAILURE; } if (!CORBA::is_nil(orb)) { try { orb->destroy(); } catch(const CORBA::Exception&) { status = EXIT_FAILURE; } } return status; }

  6. int run(CORBA::ORB_ptr orb) { const char* refFile = "Messenger.ref"; ifstream in(refFile); char s [2048]; in >> s; in.close(); CORBA::Object_var obj = orb->string_to_object(s); CORBA::String_var message = CORBA::string_dup("Howdy!"); Messenger_var messenger = Messenger::_narrow(obj); if (messenger->send_message("hauser", "Test message", message.inout())) { cout << "server ok" << endl; cout << "Return message from server: " << message << endl; } else { cout << "server returned false" << endl; cout << "Return message from server: " << message << endl; } return 0; }

  7. int run(CORBA::ORB_ptr orb) { CORBA::Object_var poaObj = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var rootPoa = PortableServer::POA::_narrow(poaObj); PortableServer::POAManager_var manager = rootPoa->the_POAManager(); Messenger_impl* messengerImpl = new Messenger_impl(); PortableServer::ServantBase_var servant = messengerImpl; Messenger_var messenger = messengerImpl -> _this(); CORBA::String_var s = orb -> object_to_string(messenger); const char* refFile = "Messenger.ref"; ofstream out(refFile); out << s << endl; out.close(); manager -> activate(); orb->run(); return EXIT_SUCCESS; }

More Related