Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / POA / Persistent_ID / client.cpp
blob50fc9d3d38c6170852a11664a6f32c3f0d74ebbc
2 //=============================================================================
3 /**
4 * @file client.cpp
6 * This is a client implementation.
8 * @author Irfan Pyarali
9 */
10 //=============================================================================
13 #include "ace/Get_Opt.h"
14 #include "testC.h"
15 #include "ace/OS_NS_string.h"
17 static const ACE_TCHAR *IOR = ACE_TEXT ("file://ior");
18 static int shutdown_server = 0;
20 static int
21 parse_args (int argc, ACE_TCHAR **argv)
23 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:x"));
24 int c;
26 while ((c = get_opts ()) != -1)
27 switch (c)
29 case 'k':
30 IOR = get_opts.opt_arg ();
31 break;
33 case 'x':
34 shutdown_server = 1;
35 break;
37 case '?':
38 default:
39 ACE_ERROR_RETURN ((LM_ERROR,
40 ACE_TEXT ("usage: %s ")
41 ACE_TEXT ("-k IOR ")
42 ACE_TEXT ("-x shutdown server ")
43 ACE_TEXT ("\n"),
44 argv [0]),
45 -1);
48 if (IOR == 0)
49 ACE_ERROR_RETURN ((LM_ERROR,
50 ACE_TEXT ("Please specify the IOR\n")), -1);
52 return 0;
55 int
56 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
58 try
60 CORBA::ORB_var orb =
61 CORBA::ORB_init (argc, argv);
63 int parse_args_result =
64 parse_args (argc, argv);
65 if (parse_args_result != 0)
66 return parse_args_result;
68 CORBA::Object_var object =
69 orb->string_to_object (IOR);
71 test_var test1 =
72 test::_narrow (object.in ());
74 test1->method ();
76 test_var test2 =
77 test1->create_POA ();
79 test2->method ();
81 test1->destroy_POA ();
83 try
85 test2->method ();
87 catch (const CORBA::Exception &ex)
89 ACE_DEBUG ((LM_DEBUG,
90 ACE_TEXT ("caught expected %s\n"),
91 ex._name()));
94 test_var test3 =
95 test1->create_POA ();
97 test2->method ();
99 test3->method ();
101 if (shutdown_server)
103 test1->shutdown ();
106 orb->destroy ();
108 catch (const CORBA::Exception& ex)
110 ex._tao_print_exception (ACE_TEXT ("Error!"));
111 return -1;
114 return 0;