- Timestamp:
- 2012-03-16T21:38:01+13:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/runtime-src/src/corba/corbaServer.mpp
r24959 r25231 1 #define USE_POA 2 1 3 // Standard headers 2 #include <iostream .h>3 #include <fstream .h>4 #include <iostream> 5 #include <fstream> 4 6 5 7 // protocol headers … … 44 46 here ++; 45 47 } 46 cout << "Terminfo " << i <<endl;48 std::cout << "Terminfo " << i << std::endl; 47 49 } 48 50 … … 57 59 corbaconv_text_t::setCorbatext(option.value,corba[i].value); 58 60 59 // cout << corbatext_string(corba[i].name) << "?" << option61 // std::cout << corbatext_string(corba[i].name) << "?" << option 60 62 61 63 array.push_back(option); … … 63 65 } 64 66 65 class corbaServer : virtual public corbaiface_skel 67 // corbaServer no longer inherits from corbaiface_skel since the change from using 68 // BOA to POA in the Corba code upon updating Mico from version 2.3.5 to 2.3.13. 69 class corbaServer : virtual public POA_gsdlInterface::corbaiface 66 70 { 67 71 private: … … 88 92 char * cdirname; 89 93 90 cout << "CorbaServer: gsdlhome = " << home <<endl;94 std::cout << "CorbaServer: gsdlhome = " << home << std::endl; 91 95 92 96 this->gsdlhome = home; 93 cout << gsdlhome.getcstr() <<endl;97 std::cout << gsdlhome.getcstr() << std::endl; 94 98 dirname = filename_cat(gsdlhome, "/collect"); 95 99 cdirname = dirname.getcstr(); 96 100 if (!read_dir (cdirname, collections)) { 97 cout << "Unable to read the gsdl directory; terminating" <<endl;101 std::cout << "Unable to read the gsdl directory; terminating" << std::endl; 98 102 exit (1); 99 103 } 100 104 delete cdirname; 101 105 102 cout << "Constructing set list server" <<endl;106 std::cout << "Constructing set list server" << std::endl; 103 107 this->protocol = protocol; 104 108 … … 128 132 129 133 // **** 130 cout << "Recieved " << key << " = ";134 std::cout << "Recieved " << key << " = "; 131 135 for (int unsigned i=0; i<cfgline.size(); i++) 132 136 { 133 cout << cfgline[i] << " ";134 } 135 cout <<endl;137 std::cout << cfgline[i] << " "; 138 } 139 std::cout << std::endl; 136 140 137 141 // DB // **** … … 140 144 text_tarray cfgline; 141 145 cfgline.push_back (gsdlhome); 142 cout << "Changing gsdlhome to " << gsdlhome <<endl;146 std::cout << "Changing gsdlhome to " << gsdlhome << std::endl; 143 147 protocol->configure(key, cfgline, error); 144 148 } … … 146 150 { 147 151 // Only let gsdlhome through !!!! // **** 148 cout << "Supressing httpdomain" <<endl;152 std::cout << "Supressing httpdomain" << std::endl; 149 153 } 150 154 else if (key=="httpprefix") 151 155 { 152 cout << "Supressing httpprefix" <<endl;156 std::cout << "Supressing httpprefix" << std::endl; 153 157 } 154 158 else … … 170 174 cct = new corbaconv_text_t(corbaCollect); 171 175 172 cout << "Collection: " << cct->getcstr() <<endl;176 std::cout << "Collection: " << cct->getcstr() << std::endl; 173 177 174 178 protocol->has_collection(*cct, _has, err, logout); // 'cct' typecast to text_t … … 182 186 } 183 187 184 // cout << " " << has <<endl;188 // std::cout << " " << has << std::endl; 185 189 186 190 delete cct; … … 245 249 logout.close(); 246 250 corbaError = (corbaComError) error; 247 cout << "Filter prepared" << corbaResponse.docInfo.length() << "," << corbaResponse.numDocs <<endl;251 std::cout << "Filter prepared" << corbaResponse.docInfo.length() << "," << corbaResponse.numDocs << std::endl; 248 252 } 249 253 … … 262 266 protocol->get_collectinfo(collection, response, error, logout); 263 267 264 cout << "IsPublic = " << ((response.isPublic)?"True":"False") <<endl;265 cout << "IsBeta = " << ((response.isBeta) ?"True":"False") <<endl;266 cout << "BuildDate = " << response.buildDate <<endl;267 cout << "NumDocs = " << response.numDocs <<endl;268 cout << "NumBytes = " << response.numBytes <<endl;269 cout << "NumWords = " << response.numWords <<endl;270 cout << "UseBook = " << ((response.useBook) ?"True":"False") <<endl;268 std::cout << "IsPublic = " << ((response.isPublic)?"True":"False") << std::endl; 269 std::cout << "IsBeta = " << ((response.isBeta) ?"True":"False") << std::endl; 270 std::cout << "BuildDate = " << response.buildDate << std::endl; 271 std::cout << "NumDocs = " << response.numDocs << std::endl; 272 std::cout << "NumBytes = " << response.numBytes << std::endl; 273 std::cout << "NumWords = " << response.numWords << std::endl; 274 std::cout << "UseBook = " << ((response.useBook) ?"True":"False") << std::endl; 271 275 272 276 corbaResponse.useBook = response.useBook; … … 280 284 corbaResponse.numWords = response.numWords; 281 285 282 corbatext_ mapToCorbaMap(response.collectionmeta, &corbaResponse.collectionMeta);286 corbatext_colmetamapToCorbaColmetamap(response.collectionmeta, &corbaResponse.collectionMeta); 283 287 corbatext_mapToCorbaMap(response.format, &corbaResponse.format); 284 288 corbatext_mapToCorbaMap(response.building, &corbaResponse.building); … … 292 296 while (f_here!=f_end) 293 297 { 294 cout << "**** format: " << f_here->first << " = " << f_here->second <<endl;298 std::cout << "**** format: " << f_here->first << " = " << f_here->second << std::endl; 295 299 f_here++; 296 300 } … … 362 366 363 367 corbaconv_text_t::setCorbatext(collection,corbaCollect); 364 cout << collection.getcstr() <<endl;368 std::cout << collection.getcstr() << std::endl; 365 369 366 370 protocol->get_filterinfo(collection, response, error, logout); … … 399 403 void getRssItems (const struct corbatext_t &corbaCollect, 400 404 const struct corbatext_t &corbaGsdlHome, 401 conststruct corbatext_t &corbaRssItems,405 struct corbatext_t &corbaRssItems, 402 406 enum corbaComError &corbaError) 403 407 { … … 416 420 protocol->get_rss_items(collection, gsdlhome, rss_items, error, logout); 417 421 corbaconv_text_t::getCorbatext(rss_items,corbaRssItems); 418 422 419 423 // decode response 420 424 corbaError = (corbaComError) error; … … 433 437 ofstream logout; 434 438 435 cout << "Received collection list request" <<endl;439 std::cout << "Received collection list request" << std::endl; 436 440 437 441 this->openLogfile("/etc/corbaout.txt", logout); … … 453 457 454 458 corbatext_arrayToCorbaArray(collist, &corbalist); 455 cout << "Replying " << collist.size() << ": " <<endl;459 std::cout << "Replying " << collist.size() << ": " << std::endl; 456 460 457 461 for (int unsigned i = 0; i < collist.size(); i ++) 458 462 { 459 cout << collist[i];460 if (i<collist.size()-1) cout << ", ";463 std::cout << collist[i]; 464 if (i<collist.size()-1) std::cout << ", "; 461 465 } 462 cout <<endl;466 std::cout << std::endl; 463 467 464 468 logout.close(); … … 472 476 collectset *cservers; 473 477 text_t gsdlhome; 474 475 cservers = new collectset(gsdlhome); 478 text_t collecthome; 479 480 cservers = new collectset(gsdlhome, collecthome); 476 481 protocol.set_collectset(cservers); 477 482 478 cout << "Started Corba ..." <<endl;483 std::cout << "Started Corba ..." << std::endl; 479 484 480 485 // ORB initialization 486 // Initialize the ORB 481 487 CORBA::ORB_var orb = CORBA::ORB_init( argc, argv, "mico-local-orb" ); 488 489 #if defined(USE_POA) 490 // Obtain a reference to the RootPOA and its Manager 491 CORBA::Object_var poaobj = orb->resolve_initial_references ("RootPOA"); 492 PortableServer::POA_var poa = PortableServer::POA::_narrow (poaobj); 493 PortableServer::POAManager_var mgr = poa->the_POAManager(); 494 #else 482 495 CORBA::BOA_var boa = orb->BOA_init( argc, argv, "mico-local-boa" ); 483 484 cout << "Initialised ORB and BOA" << endl; 485 496 #endif 497 498 std::cout << "Initialised ORB and P/BOA" << std::endl; 499 500 501 // Create the Server object (the object that inherits from the POA_gsdlInterface::corbaiface 486 502 corbaServer* server = new corbaServer(&protocol, gsdlhome); 487 503 488 cout << "Initialised server" << endl; 489 490 CORBA::String_var ref = orb->object_to_string( server ); 491 492 cout << "Mapped Corba object to string" << endl; 493 504 // Activate the Servant (server) 505 #if defined(USE_POA) 506 PortableServer::ObjectId_var oid = poa->activate_object (server); 507 #endif 508 509 std::cout << "Initialised server" << std::endl; 510 511 CORBA::Object_var ref = poa->id_to_reference ( oid.in() ); 512 CORBA::String_var str = orb->object_to_string( ref.in() ); 513 514 std::cout << "Mapped Corba object to string" << std::endl; 515 516 // Write referene to file 494 517 // write id to "naming service" 495 518 ofstream out ("/tmp/localcorba.objid"); 496 519 if (out.is_open()) { 497 out << ref <<endl;520 out << str.in() << std::endl; 498 521 if (out.fail() || out.bad()) { 499 cout << "Failed " <<endl;522 std::cout << "Failed " << std::endl; 500 523 } 501 524 out.close (); 502 525 } 503 526 else { 504 cout << "Unable to write string to file /tmp/localcorba.objid" <<endl;505 cout << "Please check the file permissions/ownership" <<endl;527 std::cout << "Unable to write string" << str.in() << " to file /tmp/localcorba.objid" << std::endl; 528 std::cout << "Please check the file permissions/ownership" << std::endl; 506 529 return 0; 507 530 } 508 cout << "Corba string is " << ref << endl; 509 531 std::cout << "Corba string is " << str.in() << std::endl; 532 533 // Activate the POA and start serving requests 510 534 // indicate readiness and run 535 #if defined(USE_POA) 536 mgr->activate (); 537 //poa->the_POAManager()->activate(); 538 #else 511 539 boa->impl_is_ready( CORBA::ImplementationDef::_nil() ); 540 #endif 512 541 orb->run (); 542 543 #if defined(USE_POA) 544 // Shutdown (never reached) 545 poa->destroy (TRUE, TRUE); 546 delete server; // should I include this???? 547 #else 513 548 CORBA::release( server ); 549 #endif 514 550 return 0; 515 551 } 516 552 517
Note:
See TracChangeset
for help on using the changeset viewer.