Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / DevGuideExamples / AMH_AMI / inner_cb.cpp
blob6ce5e71297661f907b561265c48daa18f5c8d78a
1 #include "amh_ami_pch.h"
2 #include "inner_cb.h"
3 #include <iostream>
4 // Implementation skeleton constructor
5 Inner_callback_i::Inner_callback_i (PortableServer::POA_ptr p,
6 AMH_MiddleResponseHandler_ptr rh)
7 : poa_(PortableServer::POA::_duplicate (p)),
8 response_handler_ (AMH_MiddleResponseHandler::_duplicate (rh))
12 // Implementation skeleton destructor
13 Inner_callback_i::~Inner_callback_i (void)
15 std::cout << "Inner_callback_i destroying" << std::endl;
19 void
20 Inner_callback_i::answer (const char * ami_return_val)
22 std::cout << "Inner_callback_i::answer called, return_val = "
23 << ami_return_val << std::endl;
24 this->response_handler_->get_the_answer (ami_return_val);
26 std::cout << "inner_callback_i deactivating self" << std::endl;
27 PortableServer::ObjectId_var oid = this->poa_->servant_to_id(this);
28 this->poa_->deactivate_object (oid.in());
31 void
32 Inner_callback_i::answer_excep (Messaging::ExceptionHolder* excep_holder)
34 // Here, we need to extract the exception from this holder, and package
35 // it in another so the AMH response handler may forward it on.
36 try
38 excep_holder->raise_exception();
40 catch(const CORBA::Exception& ex)
42 CORBA::Exception *local_ex = ex._tao_duplicate();
43 AMH_MiddleExceptionHolder amh_excep_holder (local_ex);
44 this->response_handler_->get_the_answer_excep (&amh_excep_holder);
46 catch(...)
48 std::cout
49 << "inner_callback_i::answer_excep got an unknown exception"
50 << std::endl;
52 CORBA::Exception *unknown_ex = new CORBA::UNKNOWN;
53 AMH_MiddleExceptionHolder amh_excep_holder (unknown_ex);
54 this->response_handler_->get_the_answer_excep (&amh_excep_holder);
57 std::cout << "inner_callback_i deactivating self" << std::endl;
58 PortableServer::ObjectId_var oid = this->poa_->servant_to_id(this);
59 this->poa_->deactivate_object (oid.in());