Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / tests / Collocation_Oneway_Tests / Client_Task.cpp
blobf2f97b4513ea953cbe8fc4ec6365d6b298bb82fb
2 #include "tao/Messaging/Messaging.h"
3 #include "tao/AnyTypeCode/Any.h"
4 #include "Client_Task.h"
5 #include "TestC.h"
7 Client_Task::Client_Task (const ACE_TCHAR *ior,
8 CORBA::ORB_ptr corb,
9 Client_Task::ClientSyncModeEnum syncMode,
10 ACE_Thread_Manager *thr_mgr)
11 : ACE_Task_Base (thr_mgr)
12 , input_ (ior)
13 , corb_ (CORBA::ORB::_duplicate (corb))
14 , syncMode_ (syncMode)
19 int
20 Client_Task::svc ()
22 try
24 CORBA::Object_var tmp =
25 this->corb_->string_to_object (input_);
27 Test::Hello_var hello =
28 Test::Hello::_narrow(tmp.in ());
30 if (CORBA::is_nil (hello.in ()))
32 ACE_ERROR_RETURN ((LM_DEBUG,
33 "Nil Test::Hello reference <%s>\n",
34 input_),
35 1);
38 Test::Hello_var tmpVar = hello;
39 CORBA::Any anyPolicy;
41 Messaging::SyncScope selectedScope = Messaging::SYNC_NONE; // default
43 if(syncMode_ == Client_Task::MODE_TRANSPORT) {
44 selectedScope = Messaging::SYNC_WITH_TRANSPORT;
45 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - SYNC_WITH_TRANSPORT collocated oneway test\n"));
47 else if(syncMode_ == Client_Task::MODE_SERVER) {
48 selectedScope = Messaging::SYNC_WITH_SERVER;
49 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - SYNC_WITH_SERVER collocated oneway test\n"));
51 else if(syncMode_ == Client_Task::MODE_TARGET) {
52 selectedScope = Messaging::SYNC_WITH_TARGET;
53 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - SYNC_WITH_TARGET collocated oneway test\n"));
55 else if(syncMode_ == Client_Task::MODE_NONE) {
56 selectedScope = Messaging::SYNC_NONE;
57 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - SYNC_NONE collocated oneway test\n"));
60 anyPolicy <<= selectedScope;
61 CORBA::PolicyList polList;
62 polList.length(1);
63 polList[0] = this->corb_->create_policy(
64 Messaging::SYNC_SCOPE_POLICY_TYPE, anyPolicy);
66 CORBA::Object_var tmpGenericVar =
67 tmpVar->_set_policy_overrides(polList,CORBA::ADD_OVERRIDE);
69 // do unchecked narrow because ORB's not activated. Otherwise get TRANSIENT exception
70 hello = Test::Hello::_narrow(tmpGenericVar.in());
72 if (CORBA::is_nil (hello.in ()))
74 ACE_ERROR_RETURN ((LM_DEBUG,
75 "Nil Test::Hello reference <%s>\n",
76 input_),
77 1);
80 CORBA::String_var the_string =
81 hello->get_string ();
83 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
84 the_string.in ()));
86 hello->onewayTest();
88 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - returned from onewayTest() call\n"));
90 hello->shutdown ();
92 catch (const CORBA::Exception& ex)
94 ex._tao_print_exception ("Exception caught:");
95 return 1;
98 return 0;