Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / ImplRepo_Service / Activator_NT_Service.cpp
blobf52131335bcb831618b5e6f5819ee36935f47a4c
1 //=============================================================================
2 /**
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>
9 */
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");
30 /**
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.
35 void
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);
45 else
47 ACE_NT_Service::handle_control (control_code);
52 int
53 Activator_NT_Service::handle_exception (ACE_HANDLE)
55 return 0;
59 /**
60 * We do almost the same thing as we do in run_standalone () except that
61 * we update the report_status after init.
63 int
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);
72 return -1;
75 try
77 int status = server.init (opts);
79 if (status == -1)
81 report_status (SERVICE_STOPPED);
82 return -1;
84 else
86 report_status (SERVICE_RUNNING);
87 server.run ();
89 status = server.fini ();
91 report_status (SERVICE_STOPPED);
93 if (status != -1)
94 return 0;
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);
110 return -1;
113 #endif /* ACE_WIN32 && !ACE_LACKS_WIN32_SERVICES */