1 //=============================================================================
5 * @author Tim Bradley <bradley_t@ociweb.com>
7 //=============================================================================
9 #include "ClientTask.h"
10 #include "ace/SString.h"
12 ClientTask::ClientTask(Foo_ptr foo
,
13 Callback_ptr callback
)
14 : foo_(Foo::_duplicate(foo
)),
15 callback_(Callback::_duplicate(callback
))
19 ClientTask::~ClientTask()
24 ClientTask::open(void*)
26 if (this->activate(THR_NEW_LWP
| THR_JOINABLE
, 1) != 0)
28 // Assumes that when activate returns non-zero return code that
29 // no threads were activated.
30 ACE_ERROR_RETURN((LM_ERROR
,
31 "(%P|%t) ClientTask failed to activate "
32 "the client thread.\n"),
44 "(%P|%t) ClientTask::svc start\n"));
48 for (CORBA::Long i
= 1; i
<= 100; i
++)
50 // Simple Two-way calls.
54 CORBA::Long value
= this->foo_
->op3();
57 "(%P|%t) ===> Value retrieved from op3() == %d\n",
60 for (CORBA::Long j
= 1; j
<= 5; j
++)
62 this->foo_
->op4(495 + (i
* 5) + j
);
67 ACE_DEBUG((LM_DEBUG
, "(%P|%t) ===> Invoke op5()\n"));
69 ACE_DEBUG((LM_DEBUG
, "(%P|%t) ===> No exception raised from op5(). :-(\n"));
71 catch (const FooException
& )
74 "(%P|%t) ===> Caught FooException - as expected.\n"));
77 // Two-Way calls with inout parameters.
78 CORBA::String_var message
= CORBA::string_dup( "Hello! " );
80 = this->foo_
->op6( "TAO User", message
.inout());
85 "(%P|%t) ===> Message from op6() == %s\n",
91 "(%P|%t) ===> op6() returned false.\n"));
95 this->foo_
->callback_object (this->callback_
.in ());
97 this->foo_
->test_callback ();
99 // One-Way calls with various arguments.
100 CORBA::String_var ub_string
= CORBA::string_dup( "UNBOUNDED STRING" );
101 this->foo_
->test_unbounded_string_arg (ub_string
.in ());
103 CORBA::String_var bd_string
= CORBA::string_dup( "BOUNDED STRING" );
104 this->foo_
->test_bounded_string_arg (bd_string
.in ());
106 Fixed_Array fixed_array
;
108 for (CORBA::ULong m
= 0; m
< 20; m
++)
110 fixed_array
[m
] = i
+ m
;
113 this->foo_
->test_fixed_array_arg (fixed_array
);
116 var_array
[0] = CORBA::string_dup( "STRING 1" );
117 var_array
[1] = CORBA::string_dup( "STRING 2" );
118 var_array
[2] = CORBA::string_dup( "STRING 3" );
119 this->foo_
->test_var_array_arg (var_array
);
121 Bounded_Var_Size_var bd_var_size_string
= new Bounded_Var_Size();
122 char * buffer1
= CORBA::string_dup ("BOUNDED VAR SIZE CHAR");
123 bd_var_size_string
->replace (ACE_OS::strlen (buffer1
) + 1,
125 this->foo_
->test_bounded_var_size_arg (bd_var_size_string
.in ());
127 char * buffer2
= CORBA::string_dup ("UNBOUNDED VAR SIZE CHAR");
128 Unbounded_Var_Size_var ub_var_size_string
= new Unbounded_Var_Size(100);
129 ub_var_size_string
->replace (ub_var_size_string
->maximum (),
130 ACE_OS::strlen (buffer2
) + 1,
133 this->foo_
->test_unbounded_var_size_arg (ub_var_size_string
.in ());
139 this->foo_
->test_fixed_size_arg (t
);
141 this->foo_
->test_fixed_size_arg_two_way (t
);
143 CORBA::Boolean special_value
= 1;
144 this->foo_
->test_special_basic_arg (special_value
);
146 this->foo_
->test_objref_arg (this->callback_
.in ());
150 "(%P|%t) ClientTask::svc - Invoke foo->done()\n"));
154 "(%P|%t) ClientTask::svc - Back from foo->done()\n"));
156 catch (const CORBA::Exception
& ex
)
158 ex
._tao_print_exception ("Caught exception in ClientTask::svc():");
163 "(%P|%t) Unknown (...) exception caught in ClientTask::svc()\n"));
168 "(%P|%t) ClientTask::svc end\n"));
175 ClientTask::close(u_long
)
178 "(%P|%t) ClientTask::close() - enter/exit\n"));