Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / DevGuideExamples / AMH_AMI / inner_cb.cpp
blobb9a85db840cf52b20a6082deb9eff1dbe0916400
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 ()
15 std::cout << "Inner_callback_i destroying" << std::endl;
18 void
19 Inner_callback_i::answer (const char * ami_return_val)
21 std::cout << "Inner_callback_i::answer called, return_val = "
22 << ami_return_val << std::endl;
23 this->response_handler_->get_the_answer (ami_return_val);
25 std::cout << "inner_callback_i deactivating self" << std::endl;
26 PortableServer::ObjectId_var oid = this->poa_->servant_to_id(this);
27 this->poa_->deactivate_object (oid.in());
30 void
31 Inner_callback_i::answer_excep (Messaging::ExceptionHolder* excep_holder)
33 // Here, we need to extract the exception from this holder, and package
34 // it in another so the AMH response handler may forward it on.
35 try
37 excep_holder->raise_exception();
39 catch(const CORBA::Exception& ex)
41 CORBA::Exception *local_ex = ex._tao_duplicate();
42 AMH_MiddleExceptionHolder amh_excep_holder (local_ex);
43 this->response_handler_->get_the_answer_excep (&amh_excep_holder);
45 catch(...)
47 std::cout
48 << "inner_callback_i::answer_excep got an unknown exception"
49 << std::endl;
51 CORBA::Exception *unknown_ex = new CORBA::UNKNOWN;
52 AMH_MiddleExceptionHolder amh_excep_holder (unknown_ex);
53 this->response_handler_->get_the_answer_excep (&amh_excep_holder);
56 std::cout << "inner_callback_i deactivating self" << std::endl;
57 PortableServer::ObjectId_var oid = this->poa_->servant_to_id(this);
58 this->poa_->deactivate_object (oid.in());