Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / TAO / orbsvcs / CosEvent_Service / CosEvent_Service.cpp
blob4b735e5dddc661ae1f92cae57d2e82e9154a503e
1 #include "orbsvcs/CosNamingC.h"
2 #include "orbsvcs/Daemon_Utilities.h"
3 #include "orbsvcs/CosEvent/CEC_EventChannel.h"
4 #include "orbsvcs/CosEvent/CEC_Default_Factory.h"
5 #include "orbsvcs/CosEvent/CEC_Event_Loader.h"
6 #include "ace/Get_Opt.h"
7 #include "ace/Argv_Type_Converter.h"
8 #include "ace/OS_main.h"
10 int
11 ACE_TMAIN (int argc, ACE_TCHAR* argv[])
13 TAO_CEC_Default_Factory::init_svcs ();
15 try
17 // Check if -ORBDaemon is specified and if so, daemonize at this moment,
18 // -ORBDaemon in the ORB core is faulty, see bugzilla 3335
19 TAO_Daemon_Utility::check_for_daemon (argc, argv);
21 // Copy command line parameter.
22 ACE_Argv_Type_Converter command_line(argc, argv);
24 // Intialize the ORB
25 CORBA::ORB_var orb =
26 CORBA::ORB_init (command_line.get_argc(), command_line.get_TCHAR_argv());
28 // Call TAO_CEC_Event_Loader::init (argc, argv) from here.
29 TAO_CEC_Event_Loader event_service;
31 // To intialise the service
32 int const result =
33 event_service.init (command_line.get_argc(), command_line.get_TCHAR_argv());
35 if (result == -1)
36 return 1;
38 // @@ Run forever... even after the EC is destroyed...
39 // The "Right Way"[tm] to fix this is to modify
40 // TAO_CEC_EventChannel to get a new option.. If the option is
41 // set then we destroy the ORB on EventChannel::destroy(),
42 // otherwise we don't.
43 // The option will not be set by default, but the user can pass
44 // it in the command line, and in this main program with set it
45 // to 1 by default or something like that...
46 // Don't worry about this change yet... Let's get all the changes
47 // in and then we can fix the EC shutdown problem...
49 // As inidicated above, The Typed EC implementation can now be
50 // destroyed by passing -d at the command line and
51 // calling destroy on the typed EC interface.
52 // Calling fini() completes the destruction, although most of
53 // this is done in TAO_CEC_TypedEventChannel::shutdown().
54 orb->run ();
56 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
57 event_service.fini();
58 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
60 // Destroy the ORB
61 orb->destroy();
63 catch (const CORBA::Exception& ex)
65 ex._tao_print_exception (argv[0]);
66 return 1;
68 return 0;