Ignore:
Timestamp:
2012-03-16T21:38:01+13:00 (12 years ago)
Author:
ak19
Message:

Many changes to get corba working again ever since the addition of RSS support meant that the method get_rss_items needed to be mirrored in the corba code. The corba code was not compiling then and it turned out we needed a later version of Mico's corba implementation (2.3.13 up from 2.3.5). Therefore the current commit not only corrects some errors in the recently added getRssItems() method but includes further changes: 1. namespaced use of iostream functions were required in some mpp files. 2. New types and member variables added to the corbaiface.idl interface file, to mirror the presence of equivalent variables in comtools.h which hadn't been ported over yet. (Such as the complex corba data type equivalent of collectionmetamap used in comtools.h.) This required (de)serialisation methods to be declared and implemented in corbatext_t.h and corbatext_t.mpp. The additional member variables for the corbaColInfoResponse in corbaiface.idl are now also unpacked in corbaproto.mpp along with the rest of the data structure. 3. Having changed from mico version 2.3.5 to 2.3.13 required code to changed to use POA instead of BOA. This also meant that skeleton files were no longer to be generated when running idl over corbaiface.idl. corbaserver inherits from a POA related object now instead of from the skeleton. 4. Makefile.in was updated to reflect these changes (absence of skeleton), includes a target to run IDL over the corbaiface.idl file to generate the necessary helper files, and corrects earlier oversights in updating the corba makefile with the rest of the changes made over time to runtime-src.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/corba/corbaServer.mpp

    r24959 r25231  
     1#define USE_POA
     2
    13// Standard headers
    2 #include <iostream.h>
    3 #include <fstream.h>
     4#include <iostream>
     5#include <fstream>
    46
    57// protocol headers
     
    4446      here ++;
    4547    }
    46   cout << "Terminfo " << i << endl;
     48  std::cout << "Terminfo " << i << std::endl;
    4749}
    4850
     
    5759      corbaconv_text_t::setCorbatext(option.value,corba[i].value);
    5860
    59       // cout << corbatext_string(corba[i].name) << "?" << option
     61      // std::cout << corbatext_string(corba[i].name) << "?" << option
    6062
    6163      array.push_back(option);
     
    6365}
    6466
    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.
     69class corbaServer : virtual public POA_gsdlInterface::corbaiface
    6670{
    6771private:
     
    8892    char * cdirname;
    8993
    90     cout << "CorbaServer: gsdlhome = " << home << endl;
     94    std::cout << "CorbaServer: gsdlhome = " << home << std::endl;
    9195
    9296    this->gsdlhome = home;
    93     cout << gsdlhome.getcstr() << endl;
     97    std::cout << gsdlhome.getcstr() << std::endl;
    9498    dirname = filename_cat(gsdlhome, "/collect");
    9599    cdirname = dirname.getcstr();
    96100    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;
    98102      exit (1);
    99103    }
    100104    delete cdirname;
    101105
    102     cout << "Constructing set list server" << endl;
     106    std::cout << "Constructing set list server" << std::endl;
    103107    this->protocol = protocol;
    104108
     
    128132
    129133      // ****
    130       cout << "Recieved " << key << " = ";
     134      std::cout << "Recieved " << key << " = ";
    131135      for (int unsigned i=0; i<cfgline.size(); i++)
    132136    {
    133       cout << cfgline[i] << " ";
    134     }
    135       cout << endl;
     137      std::cout << cfgline[i] << " ";
     138    }
     139      std::cout << std::endl;
    136140
    137141      // DB // ****
     
    140144      text_tarray cfgline;
    141145      cfgline.push_back (gsdlhome);
    142       cout << "Changing gsdlhome to " << gsdlhome << endl;
     146      std::cout << "Changing gsdlhome to " << gsdlhome << std::endl;
    143147      protocol->configure(key, cfgline, error);
    144148    }
     
    146150    {
    147151      // Only let gsdlhome through !!!! // ****
    148       cout << "Supressing httpdomain" << endl;
     152      std::cout << "Supressing httpdomain" << std::endl;
    149153    }
    150154      else if (key=="httpprefix")
    151155    {
    152       cout << "Supressing httpprefix" << endl;
     156      std::cout << "Supressing httpprefix" << std::endl;
    153157    }
    154158      else
     
    170174    cct = new corbaconv_text_t(corbaCollect);
    171175
    172     cout << "Collection: " << cct->getcstr() << endl;
     176    std::cout << "Collection: " << cct->getcstr() << std::endl;
    173177
    174178    protocol->has_collection(*cct, _has, err, logout); // 'cct' typecast to text_t
     
    182186      }
    183187
    184     // cout << "  " << has << endl;
     188    // std::cout << "  " << has << std::endl;
    185189
    186190    delete cct;
     
    245249    logout.close();
    246250    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;
    248252  }
    249253
     
    262266    protocol->get_collectinfo(collection, response, error, logout);
    263267
    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;
    271275   
    272276    corbaResponse.useBook   = response.useBook;
     
    280284    corbaResponse.numWords  = response.numWords;
    281285
    282     corbatext_mapToCorbaMap(response.collectionmeta, &corbaResponse.collectionMeta);
     286    corbatext_colmetamapToCorbaColmetamap(response.collectionmeta, &corbaResponse.collectionMeta);
    283287    corbatext_mapToCorbaMap(response.format, &corbaResponse.format);
    284288    corbatext_mapToCorbaMap(response.building, &corbaResponse.building);
     
    292296    while (f_here!=f_end)
    293297    {
    294       cout << "**** format: " << f_here->first << " = " << f_here->second << endl;
     298      std::cout << "**** format: " << f_here->first << " = " << f_here->second << std::endl;
    295299      f_here++;
    296300    }
     
    362366
    363367    corbaconv_text_t::setCorbatext(collection,corbaCollect);
    364     cout << collection.getcstr() << endl;
     368    std::cout << collection.getcstr() << std::endl;
    365369               
    366370    protocol->get_filterinfo(collection, response, error, logout);
     
    399403  void getRssItems (const struct corbatext_t &corbaCollect,
    400404          const struct corbatext_t &corbaGsdlHome,
    401           const struct corbatext_t &corbaRssItems,
     405          struct corbatext_t &corbaRssItems,
    402406          enum corbaComError &corbaError)
    403407  {   
     
    416420    protocol->get_rss_items(collection, gsdlhome, rss_items, error, logout);
    417421    corbaconv_text_t::getCorbatext(rss_items,corbaRssItems);
    418 
     422   
    419423    // decode response
    420424    corbaError = (corbaComError) error;
     
    433437    ofstream logout;
    434438
    435     cout << "Received collection list request" << endl;
     439    std::cout << "Received collection list request" << std::endl;
    436440
    437441    this->openLogfile("/etc/corbaout.txt", logout);
     
    453457
    454458    corbatext_arrayToCorbaArray(collist, &corbalist);
    455     cout << "Replying " << collist.size() << ": " << endl;
     459    std::cout << "Replying " << collist.size() << ": " << std::endl;
    456460
    457461    for (int unsigned i = 0; i < collist.size(); i ++)
    458462      {
    459     cout << collist[i];
    460     if (i<collist.size()-1) cout << ", ";
     463    std::cout << collist[i];
     464    if (i<collist.size()-1) std::cout << ", ";
    461465      }
    462     cout << endl;
     466    std::cout << std::endl;
    463467
    464468    logout.close();
     
    472476  collectset *cservers;
    473477  text_t     gsdlhome;
    474 
    475   cservers = new collectset(gsdlhome);
     478  text_t     collecthome;
     479
     480  cservers = new collectset(gsdlhome, collecthome);
    476481  protocol.set_collectset(cservers);
    477482
    478   cout << "Started Corba ..." << endl;
     483  std::cout << "Started Corba ..." << std::endl;
    479484
    480485  // ORB initialization
     486  // Initialize the ORB
    481487  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
    482495  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
    486502  corbaServer* server = new corbaServer(&protocol, gsdlhome);
    487503
    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
    494517  // write id to "naming service"
    495518  ofstream out ("/tmp/localcorba.objid");
    496519    if (out.is_open()) {
    497         out << ref << endl;
     520        out << str.in() << std::endl;
    498521        if (out.fail() || out.bad()) {
    499             cout << "Failed " << endl;
     522            std::cout << "Failed " << std::endl;
    500523        }
    501524        out.close ();
    502525    }
    503526    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;
    506529        return 0;
    507530    }
    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
    510534  // indicate readiness and run
     535#if defined(USE_POA)
     536  mgr->activate ();
     537  //poa->the_POAManager()->activate();
     538#else
    511539  boa->impl_is_ready( CORBA::ImplementationDef::_nil() );
     540#endif
    512541  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
    513548  CORBA::release( server );
     549#endif
    514550  return 0;
    515551}
    516552
    517 
Note: See TracChangeset for help on using the changeset viewer.