1 #include "Notifier_Server.h"
2 #include "Event_CommC.h"
4 #include "tao/ORB_Core.h"
7 Notifier_Server::Notifier_Server (void)
13 Notifier_Server::~Notifier_Server (void)
18 Notifier_Server::close (void)
22 // disconnect all the consumers.
23 this->servant_
.disconnect ("notifier shutdown.");
26 CosNaming::Name
notifier_obj_name (1);
27 notifier_obj_name
.length (1);
28 notifier_obj_name
[0].id
=
29 CORBA::string_dup (NOTIFIER_BIND_NAME
);
31 this->naming_server_
->unbind (notifier_obj_name
);
33 // Instruct the ORB to shutdown.
34 this->orb_manager_
.orb ()->shutdown ();
36 catch (const CORBA::Exception
&)
44 // The naming service is initialized and the naming context as well as
45 // the object name is bound to the naming server.
48 Notifier_Server::init_naming_service (void)
52 CORBA::ORB_var orb
= this->orb_manager_
.orb ();
56 if (this->naming_server_
.init (orb
.in ()) == -1)
57 ACE_ERROR_RETURN ((LM_ERROR
,
58 "Failed to initialize TAO_Naming_Server\n"),
61 // Register the object implementation with the POA.
62 Event_Comm::Notifier_var notifier_obj
=
63 this->servant_
._this ();
66 CosNaming::Name
notifier_obj_name (1);
67 notifier_obj_name
.length (1);
68 notifier_obj_name
[0].id
=
69 CORBA::string_dup (NOTIFIER_BIND_NAME
);
71 // Now, attach the object name to the context.
72 this->naming_server_
->bind (notifier_obj_name
,
75 catch (const CORBA::Exception
& ex
)
77 ex
._tao_print_exception ("Notifier_Server::init_naming_service\n");
85 // Initialize the server.
87 Notifier_Server::init (int argc
,
90 // Call the init of <TAO_ORB_Manager> to initialize the ORB and
91 // create the child poa under the root POA.
93 if (this->orb_manager_
.init_child_poa (argc
,
97 ACE_ERROR_RETURN ((LM_ERROR
,
102 this->orb_manager_
.activate_poa_manager ();
104 // Activate the servant in the POA.
105 CORBA::String_var str
=
106 this->orb_manager_
.activate_under_child_poa (NOTIFIER_BIND_NAME
,
109 return this->init_naming_service ();
113 Notifier_Server::run (void)
115 ACE_DEBUG ((LM_DEBUG
,
116 "Running the notifier server...\n"));
118 // Run the main event loop for the ORB.
119 this->orb_manager_
.run ();
125 Notifier_Server::reactor (void)
127 return TAO_ORB_Core_instance ()->reactor ();