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"
14 #include "ace/OS_NS_string.h"
16 #include "Smart_Proxy_Impl.h"
18 const ACE_TCHAR
*ior1
= ACE_TEXT("file://test1.ior");
19 const ACE_TCHAR
*ior2
= ACE_TEXT("file://test2.ior");
20 int one_shot_factory
= 1;
23 parse_args (int argc
, ACE_TCHAR
*argv
[])
25 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("i:j:f:"));
28 while ((c
= get_opts ()) != -1)
32 ior1
= get_opts
.opt_arg ();
35 ior2
= get_opts
.opt_arg ();
38 one_shot_factory
= ACE_OS::atoi (get_opts
.opt_arg ());
42 ACE_ERROR_RETURN ((LM_ERROR
,
53 run_test (CORBA::ORB_ptr orb_ptr
,
56 CORBA::ORB_var orb
= CORBA::ORB::_duplicate (orb_ptr
);
57 CORBA::Object_var object
;
63 orb
->string_to_object (ior1
);
68 orb
->string_to_object (ior2
);
72 Test::_narrow (object
.in ());
74 if (CORBA::is_nil (server
.in ()))
75 ACE_ERROR_RETURN ((LM_ERROR
,
76 "Object reference is nil\n"),
83 catch (const CORBA::Exception
& ex
)
85 ex
._tao_print_exception ("Client-side exception:");
91 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
96 CORBA::ORB_init (argc
,
99 if (parse_args (argc
, argv
) != 0)
102 // To use the smart proxy it is necessary to allocate the
103 // user-defined smart factory on the heap as the smart proxy
104 // generated classes take care of destroying the object. This
105 // way it a win situation for the application developer who
106 // doesnt have to make sure to destroy it and also for the smart
107 // proxy designer who now can manage the lifetime of the object
109 // By default this factory is permanent (i.e. registered for
110 // this interface) but if there is a need for flexibility per
111 // object instance then <one_shot_factory> needs to be set to 0.
112 Smart_Test_Factory
*test_factory
= 0;
113 ACE_NEW_RETURN (test_factory
,
114 Smart_Test_Factory (one_shot_factory
),
117 ACE_UNUSED_ARG (test_factory
);
119 run_test (orb
.in (), 1);
120 run_test (orb
.in (), 2);
124 catch (const CORBA::Exception
& ex
)
126 ex
._tao_print_exception ("Client-side exception:");