2 //=============================================================================
6 * This is the client program that tests TAO's Smart Proxy extension.
8 * @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
10 //=============================================================================
13 #include "ace/Get_Opt.h"
15 #include "Smart_Proxy_Impl.h"
16 #include "ace/OS_NS_string.h"
17 #include "ace/OS_NS_unistd.h"
19 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
22 parse_args (int argc
, ACE_TCHAR
*argv
[])
24 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("i:"));
27 while ((c
= get_opts ()) != -1)
31 ior
= get_opts
.opt_arg ();
35 ACE_ERROR_RETURN ((LM_ERROR
,
46 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
51 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
53 if (parse_args (argc
, argv
) != 0)
56 CORBA::Object_var object
=
57 orb
->string_to_object (ior
);
59 // To use the smart proxy it is necessary to allocate the
60 // user-defined smart factory on the heap as the smart proxy
61 // generated classes take care of destroying the object. This
62 // way it a win situation for the application developer who
63 // doesnt have to make sure to destroy it and also for the smart
64 // proxy designer who now can manage the lifetime of the object
66 Smart_Test_Factory
*test_factory
= 0;
67 ACE_NEW_RETURN (test_factory
,
71 ACE_UNUSED_ARG (test_factory
);
74 Test::_narrow (object
.in ());
76 if (CORBA::is_nil (server
.in ()))
77 ACE_ERROR_RETURN ((LM_ERROR
,
78 "Object reference <%s> is nil.\n",
84 CORBA::String_var sm_ior
= orb
->object_to_string (server
.in ());
85 if (Smart_Test_Proxy::fake_ior () != sm_ior
.in ())
89 "ERROR: The Smart Proxy IOR is:\n%C\n"
90 "but should have been: %C\n",
92 Smart_Test_Proxy::fake_ior ().c_str ()));
95 catch (const CORBA::MARSHAL
& ex
)
98 ex
._tao_print_exception ("Unexpected MARSHAL exception:");
105 // The following sleep is a hack to make sure the above oneway
106 // request gets sent before we exit. Otherwise, at least on
107 // Windows XP, the server may not even get the request.
108 ACE_Time_Value
tv (0, 100000);
113 catch (const CORBA::Exception
& ex
)
115 ex
._tao_print_exception ("Client-side exception:");