Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / DII_AMI_Forward / DII_ReplyHandler.cpp
bloba7ec401629a85f7a43db04cebb402e53597dab98
1 /* -*- C++ -*- */
4 #include "tao/DynamicInterface/Request.h" /* This must come first for
5 G++ 3.4 or better */
6 #include "DII_ReplyHandler.h"
7 #include "tao/AnyTypeCode/Any.h"
8 #include "tao/AnyTypeCode/Any_Impl.h"
10 DII_ReplyHandler::DII_ReplyHandler (bool &reply_notifier)
11 :got_reply_(reply_notifier)
15 DII_ReplyHandler::~DII_ReplyHandler ()
20 void
21 DII_ReplyHandler::handle_response (TAO_InputCDR &incoming)
23 this->got_reply_ = true;
24 CORBA::String_var result;
25 try
27 if (incoming >> result.inout())
28 ACE_DEBUG ((LM_DEBUG,"Got response: %C\n",result.in()));
29 else
30 ACE_ERROR ((LM_ERROR,"ERROR: Response is not a string!\n"));
32 catch (const CORBA::SystemException &ex)
34 ACE_ERROR ((LM_ERROR,
35 "ERROR: DII_ReplyHandler::handle_response caught %C\n",
36 ex._name()));
38 catch (...)
40 ACE_ERROR ((LM_ERROR,
41 "DII_Reply_Handler::handle_response Unknown Exception\n"));
46 void
47 DII_ReplyHandler::handle_excep (TAO_InputCDR &incoming,
48 CORBA::ULong reply_status)
50 TAO_InputCDR for_reading (incoming);
51 CORBA::String_var id;
52 if ((for_reading >> id.inout()) == 0)
54 ACE_DEBUG ((LM_DEBUG,
55 "DII_ReplyHandler::handle_excep could not extract id\n"));
56 return;
59 if (reply_status == TAO_AMI_REPLY_USER_EXCEPTION)
61 ACE_DEBUG ((LM_DEBUG,
62 "DII_ReplyHandler::handle_excep got user ex = %C\n",
63 id.in()));
65 else if (reply_status == TAO_AMI_REPLY_SYSTEM_EXCEPTION)
67 CORBA::ULong minor = 0;
68 CORBA::ULong completion = 0;
70 if ((for_reading >> minor) == 0
71 || (for_reading >> completion) == 0)
73 ACE_DEBUG ((LM_DEBUG,
74 "DII_ReplyHandler::handle_excep could not "
75 "extract system ex minor code or completion\n"));
77 else
79 ACE_DEBUG ((LM_DEBUG,
80 "Got system exception: %C, minor = %d, completed = %d\n",
81 id.in(), minor, completion));
85 else
87 ACE_DEBUG ((LM_DEBUG,
88 "Got an exception that is neither user nor system. "
89 "reply_status = %d\n",reply_status));
93 void
94 DII_ReplyHandler::handle_location_forward (TAO_InputCDR &incoming,
95 CORBA::ULong reply_status)
97 TAO_InputCDR for_reading (incoming);
98 CORBA::Object_var fwd;
99 if ((for_reading >> fwd) == 0)
101 return;
104 int argc = 0;
105 ACE_TCHAR **argv = 0;
106 CORBA::ORB_var orb = CORBA::ORB_init(argc,argv);
108 CORBA::String_var iorstr = orb->object_to_string(fwd.in ());
110 bool is_perm = reply_status == TAO_AMI_REPLY_LOCATION_FORWARD_PERM;
111 ACE_DEBUG ((LM_DEBUG,
112 "DII_ReplyHandler::handle_location_forward"
113 " got %C, is_perm = %b\n",
114 iorstr.in() ,is_perm));
116 CORBA::Request_var req = fwd->_request ("do_forward");
117 CORBA::String_var test_string = CORBA::string_dup ("123 look at me");
118 req->add_in_arg ("text") <<= CORBA::Any::from_string(test_string.in(),30);
119 req->sendc(this);