diff options
Diffstat (limited to 'modules/CIAO/connectors/AMI_CCM')
11 files changed, 166 insertions, 11 deletions
diff --git a/modules/CIAO/connectors/AMI_CCM/AMI/AMI_MyFoo_i.cpp b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_MyFoo_i.cpp index c9e4875615e..7777d253840 100644 --- a/modules/CIAO/connectors/AMI_CCM/AMI/AMI_MyFoo_i.cpp +++ b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_MyFoo_i.cpp @@ -16,21 +16,22 @@ namespace CCM_CORBA_AMI_MyFoo_Impl { } + // FOO methods void AMI_MyFoo_reply_handler::foo ( CORBA::Long result, const char * out_str) { - printf ("AMI CORBA (FOO) :\tMyFoo Reply Handler::foo\n"); + printf ("AMI CORBA (FOO) :\tMyFoo Foo Reply Handler::foo\n"); foo_callback_->foo_callback_handler (result, CORBA::string_dup (out_str)); - //this->_remove_ref (); + this->_remove_ref (); } void AMI_MyFoo_reply_handler::foo_excep ( ::Messaging::ExceptionHolder * excep_holder) { - printf ("AMI CORBA (FOO) :\tMyFoo Reply Handler::foo_excep\n"); + printf ("AMI CORBA (FOO) :\tMyFoo Foo Reply Handler::foo_excep\n"); try { @@ -56,8 +57,51 @@ namespace CCM_CORBA_AMI_MyFoo_Impl { ex._tao_print_exception ("ERROR (FOO) :\tCaught the WRONG exception:"); } - //this->_remove_ref (); - }; + this->_remove_ref (); + } + + // HELLO methods + void + AMI_MyFoo_reply_handler::hello ( + CORBA::Long answer) + { + printf ("AMI CORBA (FOO) :\tMyFoo Hello Reply Handler::foo\n"); + foo_callback_->hello_callback_handler (answer); + this->_remove_ref (); + } + + void + AMI_MyFoo_reply_handler::hello_excep ( + ::Messaging::ExceptionHolder * excep_holder) + { + printf ("AMI CORBA (FOO) :\tMyFoo Hello Reply Handler::foo_excep\n"); + + try + { + excep_holder->raise_exception (); + } + catch (const CCM_AMI::InternalError& ex) + { + printf ("AMI CORBA (FOO) :\tCaught the correct exception type (CCM_AMI::InternalError) <%d> <%s>\n", + ex.ex.id, ex.ex.error_string.in ()); + + foo_callback_->hello_callback_excep (ex.ex); + + if (ex.ex.id != 42) + { + printf ("ERROR (FOO):\tReceived unexpected ID received in exception handler\n"); + } + if (ACE_OS::strcmp (ex.ex.error_string.in (), "Hello world") != 0) + { + printf ("ERROR (FOO):\tReceived unexpected error string received in exception handler\n"); + } + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("ERROR (FOO) :\tCaught the WRONG exception:"); + } + this->_remove_ref (); + } //============================================================ // Implementation of the AMI CORBA FOO interface @@ -96,6 +140,32 @@ namespace CCM_CORBA_AMI_MyFoo_Impl } } + void + AMI_MyFoo_i::hello (CORBA::Long_out answer) + { + try + { + printf ("AMI CORBA (FOO) :\tHello. Try calling the Receiver component\n", answer); + foo_receiver_->hello (answer); + } + catch (CCM_AMI::InternalError& ex) + { + printf ("AMI CORBA (FOO) :\tCORRECT EXCEPTION -> re-throwing\n"); + CCM_AMI::InternalException excep; + excep.id = ex.ex.id; + excep.error_string = CORBA::string_dup (ex.ex.error_string); + throw CCM_AMI::InternalError (excep); + } + catch (...) + { + printf ("AMI CORBA (FOO) :\t!!!!!UNKNOWN EXCEPTION!!!!!\n"); + CCM_AMI::InternalException excep; + excep.id = 43; + excep.error_string = CORBA::string_dup ("UNKNOWN"); + throw CCM_AMI::InternalError (excep); + } + } + //============================================================ // Worker thread to service the AMI CORBA FOO interface //============================================================ diff --git a/modules/CIAO/connectors/AMI_CCM/AMI/AMI_MyFoo_i.h b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_MyFoo_i.h index c71867cacb2..377e8b02bbc 100644 --- a/modules/CIAO/connectors/AMI_CCM/AMI/AMI_MyFoo_i.h +++ b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_MyFoo_i.h @@ -27,6 +27,14 @@ namespace CCM_CORBA_AMI_MyFoo_Impl foo_excep ( ::Messaging::ExceptionHolder * excep_holder); + void + hello ( + CORBA::Long answer); + + void + hello_excep ( + ::Messaging::ExceptionHolder * excep_holder); + private: ::CCM_AMI::AMI_MyFoo_callback_var foo_callback_; }; @@ -40,8 +48,15 @@ namespace CCM_CORBA_AMI_MyFoo_Impl ::CCM_AMI::MyFoo_ptr foo_receiver); // The AMI methods. - CORBA::Long foo (const char * in_str, - CORBA::String_out out_str); + CORBA::Long + foo ( + const char * in_str, + CORBA::String_out out_str); + + void + hello ( + CORBA::Long_out answer); + private: CORBA::ORB_var orb_; ::CCM_AMI::MyFoo_var foo_receiver_; diff --git a/modules/CIAO/connectors/AMI_CCM/AMI/AMI_MyInterface_i.cpp b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_MyInterface_i.cpp index a0fa16bab6f..b4cf296368f 100644 --- a/modules/CIAO/connectors/AMI_CCM/AMI/AMI_MyInterface_i.cpp +++ b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_MyInterface_i.cpp @@ -23,7 +23,7 @@ namespace CCM_CORBA_AMI_MyInterface_Impl { printf ("AMI CORBA :\tMyInterface Reply Handler::do_something_with_something\n"); interface_callback_->do_something_with_something_callback_handler (result); - //this->_remove_ref (); + this->_remove_ref (); } void @@ -56,7 +56,7 @@ namespace CCM_CORBA_AMI_MyInterface_Impl { ex._tao_print_exception ("ERROR (FOO) :\tCaught the WRONG exception:"); } - //this->_remove_ref (); + this->_remove_ref (); } //============================================================ diff --git a/modules/CIAO/connectors/AMI_CCM/AMI/AMI_exec.cpp b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_exec.cpp index 90fb7134705..d3ce7501db4 100644 --- a/modules/CIAO/connectors/AMI_CCM/AMI/AMI_exec.cpp +++ b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_exec.cpp @@ -119,6 +119,7 @@ namespace CIAO_Hello_AMI_AMI_Impl const char * in_str) { printf ("AMI (FOO) :\tsendc_foo <%s>\n", in_str); + ::CCM_CORBA_AMI_MyFoo_Impl::AMI_MyFoo_reply_handler* handler = new ::CCM_CORBA_AMI_MyFoo_Impl::AMI_MyFoo_reply_handler (foo_callback_); CCM_AMI::AMI_MyFooHandler_var the_handler_var = handler->_this (); @@ -127,6 +128,20 @@ namespace CIAO_Hello_AMI_AMI_Impl printf ("AMI (FOO) : \tInvoked sendc_foo\n"); } + void + AMI_MyFoo_exec_i::sendc_hello ( + ::CCM_AMI::AMI_MyFoo_callback_ptr /*cb_handler */) + { + printf ("AMI (FOO) :\tsendc_hello\n"); + + ::CCM_CORBA_AMI_MyFoo_Impl::AMI_MyFoo_reply_handler* handler = + new ::CCM_CORBA_AMI_MyFoo_Impl::AMI_MyFoo_reply_handler (foo_callback_); + CCM_AMI::AMI_MyFooHandler_var the_handler_var = handler->_this (); + printf ("AMI (FOO) :\tCalling AMI CORBA server\n"); + ami_foo_server_->sendc_hello (the_handler_var.in ()); + printf ("AMI (FOO) : \tInvoked sendc_foo\n"); + } + //============================================================ // Facet Executor Implementation Class: AMI_MyFoo_exec_i //============================================================ diff --git a/modules/CIAO/connectors/AMI_CCM/AMI/AMI_exec.h b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_exec.h index 66f373adece..3a0773a51aa 100644 --- a/modules/CIAO/connectors/AMI_CCM/AMI/AMI_exec.h +++ b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_exec.h @@ -67,6 +67,10 @@ namespace CIAO_Hello_AMI_AMI_Impl ::CCM_AMI::AMI_MyFoo_callback_ptr cb_handler, const char * in_str); + virtual void + sendc_hello ( + ::CCM_AMI::AMI_MyFoo_callback_ptr cb_handler); + private: CCM_AMI::MyFoo_var ami_foo_server_; ::CCM_AMI::AMI_MyFoo_callback_var foo_callback_; diff --git a/modules/CIAO/connectors/AMI_CCM/Hello_Base/Hello.idl b/modules/CIAO/connectors/AMI_CCM/Hello_Base/Hello.idl index f8d81a969eb..9b71378fbae 100644 --- a/modules/CIAO/connectors/AMI_CCM/Hello_Base/Hello.idl +++ b/modules/CIAO/connectors/AMI_CCM/Hello_Base/Hello.idl @@ -18,6 +18,8 @@ module CCM_AMI { long foo (in string in_str, out string answer) raises (InternalError); + void hello (out long answer) + raises (InternalError); }; interface MyInterface diff --git a/modules/CIAO/connectors/AMI_CCM/Hello_Base/Hello_Base.idl b/modules/CIAO/connectors/AMI_CCM/Hello_Base/Hello_Base.idl index f425d6f0c9c..dcba7e10497 100644 --- a/modules/CIAO/connectors/AMI_CCM/Hello_Base/Hello_Base.idl +++ b/modules/CIAO/connectors/AMI_CCM/Hello_Base/Hello_Base.idl @@ -10,6 +10,9 @@ module CCM_AMI { void foo_callback_handler (in long result, in string answer); void foo_callback_excep (in CCM_AMI::InternalException exception_holder); + + void hello_callback_handler (in long answer); + void hello_callback_excep (in CCM_AMI::InternalException exception_holder); }; // AMI component. Sender calls AMI-component and AMI-component calls Receiver @@ -17,6 +20,7 @@ module CCM_AMI interface AMI_MyFoo { void sendc_foo (in AMI_MyFoo_callback cb_handler, in string in_str); + void sendc_hello (in AMI_MyFoo_callback cb_handler); }; // callback interface from AMI-component to Sender component diff --git a/modules/CIAO/connectors/AMI_CCM/Receiver/Hello_Receiver_exec.cpp b/modules/CIAO/connectors/AMI_CCM/Receiver/Hello_Receiver_exec.cpp index 12905f52b0d..1202d648117 100644 --- a/modules/CIAO/connectors/AMI_CCM/Receiver/Hello_Receiver_exec.cpp +++ b/modules/CIAO/connectors/AMI_CCM/Receiver/Hello_Receiver_exec.cpp @@ -67,8 +67,17 @@ namespace CIAO_Hello_AMI_Receiver_Impl return ACE_OS::rand () % 100; } } + + void + MyFoo_exec_i::hello ( + CORBA::Long_out answer) + { + printf ("Receiver (HELLO) :\tReceived request\n"); + ACE_OS::sleep (ACE_OS::rand () % 2); + answer = ACE_OS::rand () % 100; + } - //============================================================ +//============================================================ // Facet Executor Implementation Class: MyInterface_exec_i //============================================================ diff --git a/modules/CIAO/connectors/AMI_CCM/Receiver/Hello_Receiver_exec.h b/modules/CIAO/connectors/AMI_CCM/Receiver/Hello_Receiver_exec.h index bd0b73022f6..512a7946f79 100644 --- a/modules/CIAO/connectors/AMI_CCM/Receiver/Hello_Receiver_exec.h +++ b/modules/CIAO/connectors/AMI_CCM/Receiver/Hello_Receiver_exec.h @@ -60,6 +60,10 @@ namespace CIAO_Hello_AMI_Receiver_Impl foo ( const char * in_str, ::CORBA::String_out answer); + + virtual void + hello ( + CORBA::Long_out answer); }; class MyInterface_exec_i diff --git a/modules/CIAO/connectors/AMI_CCM/Sender/Hello_Sender_exec.cpp b/modules/CIAO/connectors/AMI_CCM/Sender/Hello_Sender_exec.cpp index 200d7aa267e..b5726500e5e 100644 --- a/modules/CIAO/connectors/AMI_CCM/Sender/Hello_Sender_exec.cpp +++ b/modules/CIAO/connectors/AMI_CCM/Sender/Hello_Sender_exec.cpp @@ -49,6 +49,8 @@ namespace CIAO_Hello_AMI_Sender_Impl //============================================================ // Operations from ::CCM_AMI::MyFoo_callback //============================================================ + + // FOO methods void MyFoo_callback_exec_i::foo_callback_handler ( ::CORBA::Long result, @@ -65,6 +67,22 @@ namespace CIAO_Hello_AMI_Sender_Impl exception_holder.id, exception_holder.error_string.in ()); } + // HELLO methods + void + MyFoo_callback_exec_i::hello_callback_handler ( + ::CORBA::Long answer) + { + printf ("Sender (FOO) :\tCallback from AMI (HELLO) : answer <%ld>\n", answer); + } + + void + MyFoo_callback_exec_i::hello_callback_excep ( + const ::CCM_AMI::InternalException & exception_holder) + { + printf ("Sender (FOO) :\tCallback EXCEPTION from AMI (HELLO) : exception id : <%d> exception error : <%s>\n", + exception_holder.id, exception_holder.error_string.in ()); + } + //============================================================ // Operations from ::CCM_AMI::MyInterface_callback //============================================================ @@ -112,6 +130,7 @@ namespace CIAO_Hello_AMI_Sender_Impl else { my_foo_ami_->sendc_foo (0, "Do something asynchronous"); + my_foo_ami_->sendc_hello (0); printf ("Sender (ASYNCH) :\tInvoked Asynchronous call\n"); } } @@ -137,7 +156,10 @@ namespace CIAO_Hello_AMI_Sender_Impl for (int i = 0; i < 5; ++i) { CORBA::Long result = my_foo_ami_->foo ("Do something synchronous", out_str); - printf ("Sender (SYNCH):\tInvoked synchronous call result <%d> answer <%s>\n", result, out_str); + printf ("Sender (SYNCH):\tInvoked synchronous call (FOO) result <%d> answer <%s>\n", result, out_str); + CORBA::Long answer; + my_foo_ami_->hello (answer); + printf ("Sender (SYNCH):\tInvoked synchronous call (HELLO) answer <%ld>\n", answer); } try { diff --git a/modules/CIAO/connectors/AMI_CCM/Sender/Hello_Sender_exec.h b/modules/CIAO/connectors/AMI_CCM/Sender/Hello_Sender_exec.h index 5204060dcc6..37f53fc941a 100644 --- a/modules/CIAO/connectors/AMI_CCM/Sender/Hello_Sender_exec.h +++ b/modules/CIAO/connectors/AMI_CCM/Sender/Hello_Sender_exec.h @@ -108,6 +108,7 @@ namespace CIAO_Hello_AMI_Sender_Impl class MyFoo_callback_exec_i : public virtual ::CCM_AMI::CCM_AMI_MyFoo_callback, + public virtual ::POA_CCM_AMI::AMI_MyFooHandler, public virtual ::CORBA::LocalObject { public: @@ -124,12 +125,21 @@ namespace CIAO_Hello_AMI_Sender_Impl ::CORBA::Long result, const char * answer); + virtual void + hello_callback_handler ( + ::CORBA::Long answer); + // TAO_IDL - Generated from // be/be_visitor_operation/operation_ch.cpp:46 virtual void foo_callback_excep ( const ::CCM_AMI::InternalException & exception_holder); + + virtual void + hello_callback_excep ( + const ::CCM_AMI::InternalException & exception_holder); + }; class Sender_exec_i |