Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / orbsvcs / ImplRepo_Service / Locator_NT_Service.cpp
blob0ba84a23c445e0b29512fceb6d4e31a41477313c
1 //=============================================================================
2 /**
3 * @file Locator_NT_Service.cpp
5 * @author Darrell Brunsch <brunsch@cs.wustl.edu>
6 * @author Jeff Parsons <parsons@cs.wustl.edu>
7 * @author John Tucker <jtucker@infoglide.com>
8 * @author Mike Vitalo <mvitalo@infoglide.com>
9 */
10 //=============================================================================
12 #include "Locator_NT_Service.h"
14 #if defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_SERVICES)
16 #include "ImR_Locator_i.h"
17 #include "Locator_Options.h"
19 #include "tao/ORB_Core.h"
20 #include "tao/corba.h"
21 #include "ace/Reactor.h"
23 const ACE_TCHAR* IMR_LOCATOR_SERVICE_NAME = ACE_TEXT("TAOImR");
24 const ACE_TCHAR* IMR_LOCATOR_DISPLAY_NAME = ACE_TEXT("TAO Implementation Repository");
25 const ACE_TCHAR* IMR_LOCATOR_DESCRIPTION = ACE_TEXT("Implementation Repository Locator service for TAO");
27 /**
28 * Handles the SERVICE_CONTROL_SHUTDOWN and SERVICE_CONTROL_STOP commands
29 * by shutting down the ORB. Otherwise ACE_NT_Service::handle_control
30 * handles the command.
32 void
33 Locator_NT_Service::handle_control (DWORD control_code)
35 if (control_code == SERVICE_CONTROL_SHUTDOWN
36 || control_code == SERVICE_CONTROL_STOP)
38 report_status (SERVICE_STOP_PENDING);
39 TAO_ORB_Core_instance ()->reactor ()->end_reactor_event_loop ();
40 TAO_ORB_Core_instance ()->orb ()->shutdown (1);
42 else
44 ACE_NT_Service::handle_control (control_code);
49 int
50 Locator_NT_Service::handle_exception (ACE_HANDLE)
52 return 0;
56 /**
57 * We do almost the same thing as we do in run_standalone ()
59 int
60 Locator_NT_Service::svc (void)
62 ImR_Locator_i server;
63 Options opts;
65 if (opts.init_from_registry () != 0)
67 report_status (SERVICE_STOPPED);
68 return -1;
71 try
73 int status = server.init (opts);
75 if (status == -1)
77 report_status (SERVICE_STOPPED);
78 return -1;
80 else
82 report_status (SERVICE_RUNNING);
83 server.run ();
85 status = server.fini ();
87 report_status (SERVICE_STOPPED);
90 if (status != -1)
91 return 0;
93 catch (const CORBA::SystemException& sysex)
95 sysex._tao_print_exception (IMR_LOCATOR_DISPLAY_NAME);
97 catch (const CORBA::UserException& userex)
99 userex._tao_print_exception (IMR_LOCATOR_DISPLAY_NAME);
101 catch (const CORBA::Exception& ex)
103 ex._tao_print_exception (IMR_LOCATOR_DISPLAY_NAME);
106 report_status (SERVICE_STOPPED);
108 return -1;
111 #endif /* ACE_WIN32 && !ACE_LACKS_WIN32_SERVICES */