3 //=============================================================================
5 * @file Server_Main.cpp
7 * Implements a generic object that acts as "main" for a CORBA server.
9 * @author Dale Wilson <wilson_d@ociweb.com>
11 //=============================================================================
13 #ifndef TAO_UTILS_SERVER_MAIN_T_CPP
14 #define TAO_UTILS_SERVER_MAIN_T_CPP
16 #include "tao/Utils/Server_Main.h"
20 #include "ace/Argv_Type_Converter.h"
21 #include "ace/Log_Msg.h"
22 #include "ace/Time_Value.h"
25 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
27 template <typename SERVANT
>
28 TAO::Utils::Server_Main
<SERVANT
>::Server_Main (const char * name
)
33 template <typename SERVANT
>
34 TAO::Utils::Server_Main
<SERVANT
>::~Server_Main ()
38 template <typename SERVANT
>
40 TAO::Utils::Server_Main
<SERVANT
>::run (int argc
, ACE_TCHAR
*argv
[])
49 CORBA::ORB_init (argc
, argv
, name_
);
51 if (! ::CORBA::is_nil(orb
.in ()))
53 // create an instance of the servant object and give it a
54 // chance at the arguments.
56 result
= servant
.parse_args (argc
, argv
);
59 //////////////////////////////////
60 // let the servant register itself
61 result
= servant
.init (orb
.in ());
65 TAOLIB_ERROR ((LM_INFO
,
66 "%T %C (%P|%t) Ready %C\n", name_
, servant
.identity ()));
68 //////////////////////////////////
69 // Run the event loop for the ORB.
70 // Initial run to initialize the orb
71 ACE_Time_Value
tv (1,0);
76 while (result
== 0 && ! quit
)
78 ACE_Time_Value
work_tv (1,0);
79 orb
->perform_work(work_tv
);
80 quit
= servant
.idle (result
);
86 TAOLIB_ERROR ((LM_INFO
,
87 "%T %C (%P|%t) Terminated normally. %C\n",
89 servant
.identity ()));
93 TAOLIB_ERROR ((LM_ERROR
,
94 "%T %C (%P|%t) Registration failed: %m\n", name_
));
100 TAOLIB_ERROR ((LM_ERROR
,
101 "%T %C (%P|%t) ORB manager init failed\n", name_
));
106 catch (const ::CORBA::Exception
& ex
)
108 ex
._tao_print_exception (name_
);
114 TAO_END_VERSIONED_NAMESPACE_DECL
116 #endif //TAO_UTILS_SERVER_MAIN_T_CPP