[omniORB] eg3_clt.cc eg3_impl.cc design questions

Andre Konopka andre.konopka at presse-data.de
Thu Apr 10 14:47:40 BST 2008


Hi Martin,

thank you for your help.

Yes, you are right!!! The exception is catched by main!
I overlooked it

best regards

Andre

Martin Trappel wrote:
> Andre Konopka wrote:
>> Hi,
>>
>> I'm new on corba and played around with the enclosed examples 
>> (especially eg3_clt.cc eg3_impl.cc).
>> I use Suse SLES9 and omniORB-4.1.2
>>
>> I would like to 'hide' the complete corba stuff in an additional class 
>> so that I can call the 'echoString' method as you see if you have a 
>> look at the following code
>>
>> (...)
>> I wrote a new class 'sendecho' to hide the corba details.
>> (...)
>> Here comes the sendecho.cc file
>> (...)
>> void sendecho::echoit(const char *msg) {
>>   int argc=0;
>>   char** argv=0;
>>   cout << "initializing corba " << endl;
>>   CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
>>   cout << "calling getObjectReference" << endl;
>>   CORBA::Object_var obj = getObjectReference(orb);
>>   Echo_var echoref = Echo::_narrow(obj);
>>   cout << "calling echoString with parameter "<< msg << endl;
>>   CORBA::String_var dest = echoref->echoString(msg);
>>   cout << "server replied: " << dest << endl;
>>
>> }
> 
> I guess it's just test code so it should be all right. But if you want 
> to hide the CORBA stuff, it will be better to call ORB_init (and maybe 
> also getObjReferences) in the dtor (or another initializer fn) of your 
> helper class.
> 
>>
>> CORBA::Object_ptr sendecho::getObjectReference(CORBA::ORB_ptr orb) {
>>
>> original code from eg3_clt.cc
>>
>> }
>>
>> It works fine as long as my 'server' eg3_impl.cc is up and running
>>
>> If I stop the server and restart my 'client' I get just
>>
>> Aborted
>> (...)
>> If I run the original code
>>
>> ./eg3_clt
>> Caught system exception TRANSIENT -- unable to contact the server.
>>
>> the 'client' aborted as expected.
>>
>>
>> Why the code doesn't throw an exception?
>> Is there a better (clean) way to hide corba implementation details?
>>
> 
> When you read the error messages given in eg3_clt you will see that the 
> try-catch block in getObjRef() is for the Naming Service and _not_ for 
> the Object. The TRANSIENT error message you are getting in the original 
> code comes from main() as there is also a try-catch block.
> 
> br,
> Martin
> 




More information about the omniORB-list mailing list