00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "Locator_NT_Service.h"
00015
00016 #if defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_SERVICES)
00017
00018 #include "ImR_Locator_i.h"
00019 #include "Locator_Options.h"
00020
00021 #include "tao/ORB_Core.h"
00022 #include "tao/corba.h"
00023 #include "ace/Reactor.h"
00024
00025
00026
00027
00028
00029
00030 void
00031 Locator_NT_Service::handle_control (DWORD control_code)
00032 {
00033 if (control_code == SERVICE_CONTROL_SHUTDOWN
00034 || control_code == SERVICE_CONTROL_STOP)
00035 {
00036 report_status (SERVICE_STOP_PENDING);
00037 TAO_ORB_Core_instance ()->reactor ()->end_reactor_event_loop ();
00038 TAO_ORB_Core_instance ()->orb ()->shutdown (1);
00039 }
00040 else
00041 {
00042 ACE_NT_Service::handle_control (control_code);
00043 }
00044 }
00045
00046
00047
00048
00049 int
00050 Locator_NT_Service::handle_exception (ACE_HANDLE)
00051 {
00052 return 0;
00053 }
00054
00055
00056
00057
00058
00059 int
00060 Locator_NT_Service::svc (void)
00061 {
00062 ImR_Locator_i server;
00063 Options opts;
00064
00065 if (opts.init_from_registry () != 0)
00066 {
00067 report_status (SERVICE_STOPPED);
00068 return -1;
00069 }
00070
00071 try
00072 {
00073 int status = server.init (opts);
00074
00075 if (status == -1)
00076 {
00077 report_status (SERVICE_STOPPED);
00078 return -1;
00079 }
00080 else
00081 {
00082 report_status (SERVICE_RUNNING);
00083 server.run ();
00084
00085 status = server.fini ();
00086
00087 report_status (SERVICE_STOPPED);
00088
00089 }
00090 if (status != -1)
00091 return 0;
00092 }
00093 catch (const CORBA::SystemException& sysex)
00094 {
00095 sysex._tao_print_exception (IMR_LOCATOR_DISPLAY_NAME);
00096 }
00097 catch (const CORBA::UserException& userex)
00098 {
00099 userex._tao_print_exception (IMR_LOCATOR_DISPLAY_NAME);
00100 }
00101 catch (const CORBA::Exception& ex)
00102 {
00103 ex._tao_print_exception (IMR_LOCATOR_DISPLAY_NAME);
00104 }
00105
00106 report_status (SERVICE_STOPPED);
00107
00108 return -1;
00109 }
00110
00111 #endif