diff options
author | mhengstmengel <mhengstmengel@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2010-11-17 14:03:54 +0000 |
---|---|---|
committer | mhengstmengel <mhengstmengel@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2010-11-17 14:03:54 +0000 |
commit | d4d932790fe25b9aa9ec8c92bb1103637636797e (patch) | |
tree | ceb4dbc704b699cb3b000973a677c9ed1c2b4e0a | |
parent | c57591bb5034fa9efff5c9766f42322e88dc5d63 (diff) | |
download | ATCD-d4d932790fe25b9aa9ec8c92bb1103637636797e.tar.gz |
Reverting previous commit
-rw-r--r-- | CIAO/connectors/ami4ccm/tutorials/Hello/Hello_asm/Sender_comp/src/Hello_Sender_comp_exec.cpp | 310 |
1 files changed, 269 insertions, 41 deletions
diff --git a/CIAO/connectors/ami4ccm/tutorials/Hello/Hello_asm/Sender_comp/src/Hello_Sender_comp_exec.cpp b/CIAO/connectors/ami4ccm/tutorials/Hello/Hello_asm/Sender_comp/src/Hello_Sender_comp_exec.cpp index 02ef213fe23..b8b9fb7f846 100644 --- a/CIAO/connectors/ami4ccm/tutorials/Hello/Hello_asm/Sender_comp/src/Hello_Sender_comp_exec.cpp +++ b/CIAO/connectors/ami4ccm/tutorials/Hello/Hello_asm/Sender_comp/src/Hello_Sender_comp_exec.cpp @@ -1,60 +1,280 @@ // -*- C++ -*- // $Id$ -/** - * Code generated by the The ACE ORB (TAO) IDL Compiler v1.8.3 - * TAO and the TAO IDL Compiler have been developed by: - * Center for Distributed Object Computing - * Washington University - * St. Louis, MO - * USA - * http://www.cs.wustl.edu/~schmidt/doc-center.html - * and - * Distributed Object Computing Laboratory - * University of California at Irvine - * Irvine, CA - * USA - * and - * Institute for Software Integrated Systems - * Vanderbilt University - * Nashville, TN - * USA - * http://www.isis.vanderbilt.edu/ - * - * Information about TAO is available at: - * http://www.cs.wustl.edu/~schmidt/TAO.html - **/ - #include "Hello_Sender_comp_exec.h" +#include "ace/OS_NS_unistd.h" namespace CIAO_Hello_Sender_comp_Impl { + //============================================================ + // Facet Executor Implementation Class: MyFoo_callback_exec_i + //============================================================ + MyFoo_obj_callback_exec_i::MyFoo_obj_callback_exec_i (void) + { + } - /** - * Component Executor Implementation Class: Sender_comp_exec_i - */ + MyFoo_obj_callback_exec_i::~MyFoo_obj_callback_exec_i (void) + { + } - Sender_comp_exec_i::Sender_comp_exec_i (void){ + //============================================================ + // Operations from ::CCM_AMI::MyFoo_obj_callback + //============================================================ + // Foo methods + void + MyFoo_obj_callback_exec_i::foo ( + ::CORBA::Long ami_return_val, + const char * answer) + { + /* Your code here. */ + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender:\tMyFoo AMI Callback from foo:") + ACE_TEXT("result <%u> answer <%C>\n"), + ami_return_val, answer)); } - Sender_comp_exec_i::~Sender_comp_exec_i (void) + void + MyFoo_obj_callback_exec_i::foo_excep ( + ::CCM_AMI::ExceptionHolder * excep_holder) { + /* Your code here. */ + try + { + excep_holder->raise_exception (); + } + catch (const Hello::InternalError& ex) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender:\tMyFoo Expected excception AMI Callback ") + ACE_TEXT("from foo: id <%u> error_string <%C>\n"), + ex.id, ex.error_string.in ())); + } } - // Supported operations and attributes. + // Hello methods + void + MyFoo_obj_callback_exec_i::hello ( + ::CORBA::Long answer) + { + /* Your code here. */ + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender:\tMyFoo AMI Callback from hello:") + ACE_TEXT(" answer <%u>\n"), answer)); + } - // Component attributes and port operations. + void + MyFoo_obj_callback_exec_i::hello_excep ( + ::CCM_AMI::ExceptionHolder * excep_holder) + { + /* Your code here. */ + try + { + excep_holder->raise_exception (); + } + catch (const Hello::InternalError& ex) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender:\tMyFoo Exception AMI Callback from hello:\n") + ACE_TEXT(" id <%u> error_string <%C>\n"), + ex.id, ex.error_string.in ())); + } + } + + // GET rw_attrib meyhods + void + MyFoo_obj_callback_exec_i::get_rw_attrib ( + ::CORBA::Short ami_return_val) + { + /* Your code here. */ + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender:\tMyFoo AMI Callback from get_rw_attrib:") + ACE_TEXT(" result <%u>\n"), ami_return_val)); + } + void + MyFoo_obj_callback_exec_i::get_rw_attrib_excep ( + ::CCM_AMI::ExceptionHolder * excep_holder) + { + /* Your code here. */ + excep_holder->raise_exception (); + } + + //SET rw_attrib methods + void + MyFoo_obj_callback_exec_i::set_rw_attrib () + { + /* Your code here. */ + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender:\tMyFoo AMI Callback from ") + ACE_TEXT("set_rw_attrib.\n"))); + } + + void + MyFoo_obj_callback_exec_i::set_rw_attrib_excep ( + ::CCM_AMI::ExceptionHolder * excep_holder) + { + /* Your code here. */ + excep_holder->raise_exception (); + } + + //ro_attrib Reply Handler + void + MyFoo_obj_callback_exec_i::get_ro_attrib ( + ::CORBA::Short ami_return_val) + { + /* Your code here. */ + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender:\tMyFoo AMI Callback from ") + ACE_TEXT("get_ro_attrib: result <%u>\n"), ami_return_val)); + } + + void + MyFoo_obj_callback_exec_i::get_ro_attrib_excep ( + ::CCM_AMI::ExceptionHolder * excep_holder) + { + /* Your code here. */ + excep_holder->raise_exception (); + } + + //============================================================ + // Worker thread for asynchronous invocations for MyFoo + //============================================================ + asynch_foo_generator::asynch_foo_generator ( + ::Hello::AMI4CCM_MyFoo_obj_ptr my_foo_ami) + : my_foo_ami_ (::Hello::AMI4CCM_MyFoo_obj::_duplicate (my_foo_ami)) + { + } + + int asynch_foo_generator::svc () + { + ACE_OS::sleep (2); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender (ASYNCH) :") + ACE_TEXT("\tInvoke Asynchronous calls\n"))); + + for (int i = 0; i < 5; ++i) + { + if (CORBA::is_nil (my_foo_ami_)) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT("ERROR Sender (ASYNCH) :") + ACE_TEXT("\tfoo_ami is NIL !!!\n"))); + return 1; + } + else + { + my_foo_ami_->sendc_foo (new MyFoo_obj_callback_exec_i (), + "Do something asynchronous"); + my_foo_ami_->sendc_hello (new MyFoo_obj_callback_exec_i ()); + my_foo_ami_->sendc_get_rw_attrib(new MyFoo_obj_callback_exec_i ()); + my_foo_ami_->sendc_set_rw_attrib(new MyFoo_obj_callback_exec_i (), 15); + my_foo_ami_->sendc_get_ro_attrib(new MyFoo_obj_callback_exec_i ()); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender (ASYNCH) :\tInvoked 5 Asynchronous calls\n"))); + } + } + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender (ASYNCH) :\tInvoke Asynchronous calls ") + ACE_TEXT("to test except handling\n"))); + my_foo_ami_->sendc_foo (new MyFoo_obj_callback_exec_i (), ""); + my_foo_ami_->sendc_set_rw_attrib(new MyFoo_obj_callback_exec_i (), 0); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender (ASYNCH) :\tInvoked 2 Asynchronous call.\n"))); + return 0; + } + + //============================================================ + // Worker thread for synchronous invocations for MyFoo + //============================================================ + synch_foo_generator::synch_foo_generator (::Hello::MyFoo_obj_ptr my_foo_ami) + : my_foo_ami_ (::Hello::MyFoo_obj::_duplicate (my_foo_ami)) + { + } + + int synch_foo_generator::svc () + { + ACE_OS::sleep (2); + // run synch calls + CORBA::String_var out_str; + for (int i = 0; i < 2; ++i) + { + try + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender (SYNCH) :\tInvoke synchronous call (foo)\n"))); + CORBA::Long result = my_foo_ami_->foo ("Do something synchronous", + out_str.out()); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender (SYNCH):\tInvoked synchronous call (foo)\n") + ACE_TEXT(" result <%u> answer <%C>\n"), + result, out_str.in())); + + CORBA::Long answer; + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender (SYNCH) :\tInvoke synchronous call") + ACE_TEXT(" (hello)\n"))); + my_foo_ami_->hello (answer); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender (SYNCH):\tInvoked synchronous ") + ACE_TEXT("call (hello) result <%u>\n"), answer)); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender (SYNCH) :\tInvoke synchronous call ") + ACE_TEXT("(rw_attrib())\n"))); + CORBA::Short rw_attrib = my_foo_ami_->rw_attrib (); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender (SYNCH):\tInvoked synchronous call ") + ACE_TEXT("(rw_attrib()) return <%u>\n"), rw_attrib)); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender (SYNCH) :\tInvoke synchronous call") + ACE_TEXT(" (rw_attrib(15))\n"))); + my_foo_ami_->rw_attrib (15); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender (SYNCH):\tInvoked synchronous call ") + ACE_TEXT("(rw_attrib(15))\n"))); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender (SYNCH) :\tInvoke synchronous call") + ACE_TEXT(" (ro_attrib())\n"))); + CORBA::Short ro_attrib = my_foo_ami_->ro_attrib (); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender (SYNCH):\tInvoked synchronous call ") + ACE_TEXT("(ro_attrib) return <%u>\n"), ro_attrib)); + } + catch (const Hello::InternalError& ex) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sender (SYNCH) :\tUnexpected Exception caught :") + ACE_TEXT(" <%u> <%C>\n"), ex.id, ex.error_string.in ())); + } + } + return 0; + } + + //============================================================ + // Component Executor Implementation Class: Sender_comp_exec_i + //============================================================ + Sender_comp_exec_i::Sender_comp_exec_i (void) + { + } + + Sender_comp_exec_i::~Sender_comp_exec_i (void) + { + } + + // Supported operations and attributes. + // Component attributes. + // Port operations. // Operations from Components::SessionComponent. void Sender_comp_exec_i::set_session_context ( ::Components::SessionContext_ptr ctx) { - this->ciao_context_ = + this->context_ = ::Hello::CCM_Sender_comp_Context::_narrow (ctx); - - if ( ::CORBA::is_nil (this->ciao_context_.in ())) + if ( ::CORBA::is_nil (this->context_.in ())) { throw ::CORBA::INTERNAL (); } @@ -63,36 +283,44 @@ namespace CIAO_Hello_Sender_comp_Impl void Sender_comp_exec_i::configuration_complete (void) { - /* Your code here. */ } void Sender_comp_exec_i::ccm_activate (void) { - /* Your code here. */ + ::Hello::AMI4CCM_MyFoo_obj_var asynch_foo = + this->context_->get_connection_sendc_run_my_foo(); + asynch_foo_generator* asynch_foo_gen = + new asynch_foo_generator (asynch_foo); + asynch_foo_gen->activate (THR_NEW_LWP | THR_JOINABLE, 1); + + ::Hello::MyFoo_obj_var synch_foo = + this->context_->get_connection_run_my_foo (); + synch_foo_generator* synch_foo_gen = + new synch_foo_generator (synch_foo); + synch_foo_gen->activate (THR_NEW_LWP | THR_JOINABLE, 1); } void Sender_comp_exec_i::ccm_passivate (void) { - /* Your code here. */ } void Sender_comp_exec_i::ccm_remove (void) { - /* Your code here. */ } extern "C" ::Components::EnterpriseComponent_ptr - create_Hello_Sender_comp_Impl (void) + create_Hello_AMI_Sender_comp_Impl (void) { ::Components::EnterpriseComponent_ptr retval = ::Components::EnterpriseComponent::_nil (); - ACE_NEW_NORETURN ( + ACE_NEW_RETURN ( retval, - Sender_comp_exec_i); + Sender_comp_exec_i, + ::Components::EnterpriseComponent::_nil ()); return retval; } |