1 //=============================================================================
3 * @file Activator_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>
10 //=============================================================================
12 #include "Activator_NT_Service.h"
14 #if defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_SERVICES)
16 #include "ImR_Activator_i.h"
17 #include "Activator_Options.h"
19 #include "tao/ORB_Core.h"
21 #include "ace/Reactor.h"
23 const ACE_TCHAR
* IMR_ACTIVATOR_SERVICE_NAME
=
24 ACE_TEXT("TAOImRActivator");
25 const ACE_TCHAR
* IMR_ACTIVATOR_DISPLAY_NAME
=
26 ACE_TEXT("TAO Implementation Repository Activator");
27 const ACE_TCHAR
* IMR_ACTIVATOR_DESCRIPTION
=
28 ACE_TEXT("Implementation Repository Activator service for TAO");
31 * Handles the SERVICE_CONTROL_SHUTDOWN and SERVICE_CONTROL_STOP commands
32 * by shutting down the ORB. Otherwise ACE_NT_Service::handle_control
33 * handles the command.
36 Activator_NT_Service::handle_control (DWORD control_code
)
38 if (control_code
== SERVICE_CONTROL_SHUTDOWN
39 || control_code
== SERVICE_CONTROL_STOP
)
41 report_status (SERVICE_STOP_PENDING
);
42 TAO_ORB_Core_instance ()->reactor ()->end_reactor_event_loop ();
43 TAO_ORB_Core_instance ()->orb ()->shutdown (1);
47 ACE_NT_Service::handle_control (control_code
);
53 Activator_NT_Service::handle_exception (ACE_HANDLE
)
60 * We do almost the same thing as we do in run_standalone () except that
61 * we update the report_status after init.
64 Activator_NT_Service::svc ()
66 ImR_Activator_i server
;
67 Activator_Options opts
;
69 if (opts
.init_from_registry() != 0)
71 report_status (SERVICE_STOPPED
);
77 int status
= server
.init (opts
);
81 report_status (SERVICE_STOPPED
);
86 report_status (SERVICE_RUNNING
);
89 status
= server
.fini ();
91 report_status (SERVICE_STOPPED
);
96 catch (const CORBA::SystemException
& sysex
)
98 sysex
._tao_print_exception (IMR_ACTIVATOR_DISPLAY_NAME
);
100 catch (const CORBA::UserException
& userex
)
102 userex
._tao_print_exception (IMR_ACTIVATOR_DISPLAY_NAME
);
104 catch (const CORBA::Exception
& ex
)
106 ex
._tao_print_exception (IMR_ACTIVATOR_DISPLAY_NAME
);
109 report_status (SERVICE_STOPPED
);
113 #endif /* ACE_WIN32 && !ACE_LACKS_WIN32_SERVICES */