Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / LongUpcalls / blocking_client.cpp
blob38ad1df82b6b9462de15e8478bbed1bbf539afc4
1 #include "ace/Get_Opt.h"
2 #include "Controller.h"
4 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
6 int
7 parse_args (int argc, ACE_TCHAR *argv[])
9 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:"));
10 int c;
12 while ((c = get_opts ()) != -1)
13 switch (c)
15 case 'k':
16 ior = get_opts.opt_arg ();
17 break;
18 case '?':
19 default:
20 ACE_ERROR_RETURN ((LM_ERROR,
21 "usage: %s "
22 "-k <ior>"
23 "\n",
24 argv [0]),
25 -1);
27 // Indicates successful parsing of the command line
28 return 0;
31 int
32 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
34 try
36 CORBA::ORB_var orb =
37 CORBA::ORB_init (argc, argv);
39 CORBA::Object_var object =
40 orb->resolve_initial_references("RootPOA");
42 if (CORBA::is_nil (object.in ()))
43 ACE_ERROR_RETURN ((LM_ERROR,
44 " (%P|%t) Unable to initialize the POA.\n"),
45 1);
47 PortableServer::POA_var root_poa =
48 PortableServer::POA::_narrow (object.in ());
50 PortableServer::POAManager_var poa_manager =
51 root_poa->the_POAManager ();
53 if (parse_args (argc, argv) != 0)
54 return 1;
56 Controller controller_impl;
58 PortableServer::ObjectId_var id =
59 root_poa->activate_object (&controller_impl);
61 CORBA::Object_var object_act = root_poa->id_to_reference (id.in ());
63 Test::Controller_var controller =
64 Test::Controller::_narrow (object_act.in ());
66 object = orb->string_to_object (ior);
68 Test::Manager_var manager =
69 Test::Manager::_narrow (object.in ());
71 if (CORBA::is_nil (manager.in ()))
72 ACE_ERROR_RETURN ((LM_ERROR,
73 "Manager is nil\n"),
74 1);
77 poa_manager->activate ();
79 const CORBA::Short worker_count = 10;
80 manager->start_workers (worker_count,
81 CORBA::Long (1000),
82 controller.in ());
84 controller_impl.dump_results ();
86 manager->shutdown ();
88 root_poa->destroy (1, 1);
90 orb->destroy ();
92 catch (const CORBA::Exception& ex)
94 ex._tao_print_exception ("Exception caught:");
95 return 1;
98 return 0;