Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / orbsvcs / tests / Bug_2709_Regression / server.cpp
blob680902b1a66e90ad7100e9f16b65475003225b27
1 #include "TestImpl.h"
2 #include "ace/Get_Opt.h"
3 #include "ace/OS_NS_stdio.h"
4 #include "ace/Argv_Type_Converter.h"
5 #include "tao/IORTable/IORTable.h"
6 #include "Server_Task.h"
8 const ACE_TCHAR *ior_output_file = ACE_TEXT("server.ior");
10 int
11 parse_args (int argc, ACE_TCHAR *argv[])
13 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("o:"));
14 int c;
16 while ((c = get_opts ()) != -1)
17 switch (c)
19 case 'o':
20 ior_output_file = get_opts.opt_arg ();
21 break;
23 case '?':
24 default:
25 ACE_ERROR_RETURN ((LM_ERROR,
26 "usage: %s "
27 "-o <iorfile>"
28 "\n",
29 argv [0]),
30 -1);
32 // Indicates successful parsing of the command line
33 return 0;
36 int
37 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
39 try
41 ACE_Argv_Type_Converter satc (argc, argv);
42 CORBA::ORB_var sorb =
43 CORBA::ORB_init (satc.get_argc (),
44 satc.get_TCHAR_argv ());
46 if (parse_args (argc, argv) != 0)
47 return 1;
49 ACE_Manual_Event me;
51 Server_Task server_task (ior_output_file,
52 sorb.in (),
53 me,
54 ACE_Thread_Manager::instance ());
56 if (server_task.activate (THR_NEW_LWP | THR_JOINABLE,
58 1) == -1)
60 ACE_ERROR ((LM_ERROR, "Error activating server task\n"));
63 // Wait for the server thread to do some processing
64 me.wait ();
66 ACE_Thread_Manager::instance ()->wait ();
69 sorb->destroy ();
71 catch (const CORBA::Exception& ex)
73 ex._tao_print_exception ("Exception caught:");
74 return 1;
77 return 0;