Activator_NT_Service.cpp

Go to the documentation of this file.
00001 //=============================================================================
00002 /**
00003  *  @file   Activator_NT_Service.cpp
00004  *
00005  *  Activator_NT_Service.cpp,v 1.8 2006/01/04 16:10:11 giovannd Exp
00006  *
00007  *  @author Darrell Brunsch <brunsch@cs.wustl.edu>
00008  *  @author Jeff Parsons <parsons@cs.wustl.edu>
00009  *  @author John Tucker <jtucker@infoglide.com>
00010  *  @author Mike Vitalo <mvitalo@infoglide.com>
00011  */
00012 //=============================================================================
00013 
00014 #include "Activator_NT_Service.h"
00015 
00016 #if defined (ACE_WIN32)
00017 
00018 #include "ImR_Activator_i.h"
00019 #include "Activator_Options.h"
00020 
00021 #include "tao/ORB_Core.h"
00022 
00023 #include "ace/Reactor.h"
00024 /**
00025  * Handles the SERVICE_CONTROL_SHUTDOWN and SERVICE_CONTROL_STOP commands
00026  * by shutting down the ORB.  Otherwise ACE_NT_Service::handle_control
00027  * handles the command.
00028  */
00029 void
00030 Activator_NT_Service::handle_control (DWORD control_code)
00031 {
00032   if (control_code == SERVICE_CONTROL_SHUTDOWN
00033       || control_code == SERVICE_CONTROL_STOP)
00034     {
00035       report_status (SERVICE_STOP_PENDING);
00036       TAO_ORB_Core_instance ()->reactor ()->end_reactor_event_loop ();
00037       TAO_ORB_Core_instance ()->orb ()->shutdown (1);
00038     }
00039   else
00040     {
00041       ACE_NT_Service::handle_control (control_code);
00042     }
00043 }
00044 
00045 
00046 /**
00047  */
00048 int
00049 Activator_NT_Service::handle_exception (ACE_HANDLE)
00050 {
00051   return 0;
00052 }
00053 
00054 
00055 /**
00056  * We do almost the same thing as we do in run_standalone () except that
00057  * we update the report_status after init.
00058  */
00059 int
00060 Activator_NT_Service::svc (void)
00061 {
00062   ImR_Activator_i server;
00063   Activator_Options opts;
00064 
00065   if (opts.init_from_registry() != 0)
00066     {
00067       report_status (SERVICE_STOPPED);
00068       return -1;
00069     }
00070 
00071   ACE_DECLARE_NEW_CORBA_ENV;
00072   ACE_TRY
00073     {
00074       int status = server.init (opts ACE_ENV_ARG_PARAMETER);
00075       ACE_TRY_CHECK;
00076 
00077       if (status == -1)
00078         {
00079           report_status (SERVICE_STOPPED);
00080           return -1;
00081         }
00082       else
00083         {
00084           report_status (SERVICE_RUNNING);
00085           server.run (ACE_ENV_SINGLE_ARG_PARAMETER);
00086           ACE_TRY_CHECK;
00087 
00088           status = server.fini (ACE_ENV_SINGLE_ARG_PARAMETER);
00089           ACE_TRY_CHECK;
00090 
00091           report_status (SERVICE_STOPPED);
00092 
00093         }
00094         if (status != -1)
00095             return 0;
00096     }
00097   ACE_CATCH (CORBA::SystemException, sysex)
00098     {
00099       ACE_PRINT_EXCEPTION (sysex, IMR_ACTIVATOR_DISPLAY_NAME);
00100     }
00101   ACE_CATCH (CORBA::UserException, userex)
00102     {
00103       ACE_PRINT_EXCEPTION (userex, IMR_ACTIVATOR_DISPLAY_NAME);
00104     }
00105   ACE_CATCHANY
00106     {
00107       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, IMR_ACTIVATOR_DISPLAY_NAME);
00108     }
00109   ACE_ENDTRY;
00110 
00111   report_status (SERVICE_STOPPED);
00112   return -1;
00113 }
00114 
00115 #endif /* ACE_WIN32 */

Generated on Thu Nov 9 13:36:19 2006 for TAO_Implementation_Repository by doxygen 1.3.6