Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / Portable_Interceptors / Bug_3079 / client.cpp
blob74a9139b15075b3d5a9532e589d68b7361a52617
1 // -*- C++ -*-
2 #include "ace/Get_Opt.h"
3 #include "testC.h"
4 #include "Client_ORBInitializer.h"
5 #include "tao/ORBInitializer_Registry.h"
7 const ACE_TCHAR *ior1 = 0;
8 const ACE_TCHAR *ior2 = 0;
9 const ACE_TCHAR *ior3 = 0;
11 int
12 parse_args (int argc, ACE_TCHAR *argv[])
14 if (argc != 7) // foo -p IOR_1 -f IOR_2 -s IOR_3
15 ACE_ERROR_RETURN ((LM_ERROR,
16 "Wrong number of arguments.\n"),
17 -1);
19 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("p:f:s:"));
20 int c;
22 while ((c = get_opts ()) != -1)
23 switch (c)
25 case 'p':
26 ior1 = get_opts.opt_arg ();
27 break;
28 case 'f':
29 ior2 = get_opts.opt_arg ();
30 break;
31 case 's':
32 ior3 = get_opts.opt_arg ();
33 break;
34 default:
35 ACE_ERROR_RETURN ((LM_ERROR,
36 "Usage: %s "
37 "-p IOR_1 -f IOR_2 -s IOR_3\n",
38 argv[0]),
39 -1);
42 return 0;
45 int
46 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
48 int status = 0;
50 try
52 #if TAO_HAS_INTERCEPTORS == 1
53 PortableInterceptor::ORBInitializer_ptr temp_initializer =
54 PortableInterceptor::ORBInitializer::_nil ();
56 ACE_NEW_RETURN (temp_initializer,
57 Client_ORBInitializer,
58 -1); // No exceptions yet!
59 PortableInterceptor::ORBInitializer_var orb_initializer =
60 temp_initializer;
62 PortableInterceptor::register_orb_initializer (orb_initializer.in ());
63 #endif /* TAO_HAS_INTERCEPTORS == 1 */
65 CORBA::ORB_var orb = CORBA::ORB_init (argc,
66 argv,
67 "Client ORB");
69 if (::parse_args (argc, argv) != 0)
70 return -1;
72 CORBA::Object_var object =
73 orb->string_to_object (ior1);
75 RedirectionTest::test_var server =
76 RedirectionTest::test::_narrow (object.in ());
78 if (CORBA::is_nil (server.in ()))
80 ACE_ERROR_RETURN ((LM_ERROR,
81 "Object reference <%s> is nil.\n",
82 ior1),
83 1);
86 CORBA::Short number = 0;
87 for (int i = 1; i <= 9; ++i)
89 ACE_DEBUG ((LM_INFO,
90 "CLIENT: Issuing request %d.\n",
91 i));
93 number = server->number ();
95 ACE_DEBUG ((LM_INFO,
96 "CLIENT: Request %d handled by object %d.\n",
98 number));
101 server->shutdown ();
103 orb->destroy ();
105 catch (const CORBA::Exception& ex)
107 ex._tao_print_exception ("Caught exception:");
108 return -1;
111 if (status != -1)
112 ACE_DEBUG ((LM_INFO,
113 "PortableInterceptor::Redirection test passed.\n"));
115 return status;