// //////////////////////////////////////////////////////// // Lecture on the CORBA Component Model, summer term 2003 // Assignment 2, Stephan Brumme, 702544 // // CORBA server that provides an operation to reverse // a string // // save and display IOR #include #include // IDL compiler generated a skeleton #include "Aufgabe2.h" using namespace Aufgabe2; // the server class Server_Impl : public virtual Server_skel { public: // IDL: string reverse(in string message); char* reverse(const char* message); }; // reverse a given message char* Server_Impl::reverse(const char* message) { // some nice info std::cout << "Invoked by client, incoming: '" << message << "'"; // create new string unsigned int length = strlen(message); char* result = CORBA::string_alloc(length); if (result == NULL) return result; // zero-terminated ! result[length] = 0; // reverse the message for (unsigned i=0; iBOA_init(argc, argv, "mico-local-boa"); // register object Server_Impl* server = new Server_Impl; CORBA::String_var reference = orb->object_to_string(server); // write out the object's IOR std::cout << reference << std::endl; std::ofstream ior("ior.txt"); ior << reference; ior.close(); // wait for requests boa->impl_is_ready(CORBA::ImplementationDef::_nil()); orb->run(); // game over CORBA::release(server); return 0; }