// messenger.idl
This presentation is the property of its rightful owner.
Sponsored Links
1 / 7

// messenger.idl interface Messenger { boolean send_message ( PowerPoint PPT Presentation


  • 71 Views
  • Uploaded on
  • Presentation posted in: General

// 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; };

Download Presentation

// 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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Messenger idl interface messenger boolean send message

// messenger.idl

interface Messenger {

boolean send_message (

in string user_name,

in string subject,

inout string message );

};


Messenger idl interface messenger boolean send message

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

};

};


Corba diagram

IDL

File

Client

Object

Implementation

(Servant)

IDL

Stub

IDL

Skeleton

Request

Object Request Broker

CORBA Diagram

(c) 2001 A. David McKinnon, used with permission


Messenger idl interface messenger boolean send message

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

};


Messenger idl interface messenger boolean send message

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;

}


Messenger idl interface messenger boolean send message

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;

}


Messenger idl interface messenger boolean send message

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;

}


  • Login