00001 /* -*- C++ -*- */ 00002 // $Id: IFR_Server.cpp 80726 2008-02-25 15:38:10Z sowayaa $ 00003 00004 #include "IFR_Service.h" 00005 #include "tao/Environment.h" 00006 #include "orbsvcs/Shutdown_Utilities.h" 00007 00008 ACE_RCSID (IFR_Service, 00009 IFR_Server, 00010 "$Id: IFR_Server.cpp 80726 2008-02-25 15:38:10Z sowayaa $") 00011 00012 class IFR_Service_Shutdown_Functor : public Shutdown_Functor 00013 { 00014 public: 00015 IFR_Service_Shutdown_Functor (IFR_Service& ifr); 00016 00017 void operator() (int which_signal); 00018 private: 00019 IFR_Service& ifr_; 00020 }; 00021 00022 IFR_Service_Shutdown_Functor::IFR_Service_Shutdown_Functor (IFR_Service &ifr) 00023 : ifr_(ifr) 00024 { 00025 } 00026 00027 void 00028 IFR_Service_Shutdown_Functor::operator() (int which_signal) 00029 { 00030 if (TAO_debug_level > 0) 00031 ACE_DEBUG ((LM_DEBUG, 00032 "shutting down on signal %d\n", which_signal)); 00033 (void) this->ifr_.shutdown (); 00034 } 00035 00036 int 00037 ACE_TMAIN(int argc, ACE_TCHAR *argv[]) 00038 { 00039 IFR_Service server; 00040 00041 IFR_Service_Shutdown_Functor killer (server); 00042 Service_Shutdown kill_contractor (killer); 00043 00044 try 00045 { 00046 int status = server.init (argc, argv); 00047 00048 if (status != 0) 00049 { 00050 return 1; 00051 } 00052 else 00053 { 00054 server.run (); 00055 00056 status = server.fini (); 00057 00058 if (status == -1) 00059 { 00060 return 1; 00061 } 00062 } 00063 } 00064 catch (const CORBA::SystemException& sysex) 00065 { 00066 sysex._tao_print_exception ("System Exception"); 00067 return -1; 00068 } 00069 catch (const CORBA::Exception& ex) 00070 { 00071 ex._tao_print_exception ("Unknown Exception"); 00072 return -1; 00073 } 00074 return 0; 00075 }