1 #include "Consumer_Handler.h"
2 #include "tao/ORB_Core.h"
4 Consumer_Handler::Consumer_Handler ()
13 Consumer_Handler::init (int argc
,
15 ShutdownCallback
*_shutdowncallback
)
17 const char *filtering_criteria
= "";
19 // First see if we have any environment variables.
21 ACE_OS::getenv ("FILTERING_CRITERIA");
23 // Then override these variables with command-line arguments if
25 filtering_criteria
= argc
> 1 ? ACE_TEXT_ALWAYS_CHAR(argv
[1]) : "";
30 this->orb_
= CORBA::ORB_init (argc
, argv
);
32 CORBA::Object_var poa_object
=
33 this->orb_
->resolve_initial_references ("RootPOA");
35 PortableServer::POA_var poa
=
36 PortableServer::POA::_narrow (poa_object
.in ());
38 PortableServer::POAManager_var poa_manager
=
39 poa
->the_POAManager ();
41 poa_manager
->activate ();
43 // Save the Shutdown callback.
44 this->shutdowncallback
= _shutdowncallback
;
45 // Set the ShutdownCallback callback object
46 // in the Consumer object implementation.
47 this->receiver_i_
.set (_shutdowncallback
);
51 this->receiver_i_
._this ();
54 if (this->get_notifier () == -1)
55 ACE_ERROR_RETURN ((LM_ERROR
,
56 " (%P|%t) Unable to get the notifier "
57 "the TAO_Naming_Client.\n"),
60 // Subscribe ourselves with the notifier's broker.
61 this->notifier_
->subscribe (this->receiver_
.in (),
64 catch (const CORBA::Exception
& ex
)
66 ex
._tao_print_exception ("Consumer_Handler::init\n");
74 Consumer_Handler::get_notifier ()
78 // Initialization of the naming service.
79 if (naming_services_client_
.init (orb_
.in ()) != 0)
80 ACE_ERROR_RETURN ((LM_ERROR
,
81 " (%P|%t) Unable to initialize "
82 "the TAO_Naming_Client.\n"),
85 CosNaming::Name
notifier_ref_name (1);
86 notifier_ref_name
.length (1);
87 notifier_ref_name
[0].id
= CORBA::string_dup (NOTIFIER_BIND_NAME
);
89 CORBA::Object_var notifier_obj
=
90 this->naming_services_client_
->resolve (notifier_ref_name
);
92 // The CORBA::Object_var object is downcast to Notifier_var
93 // using the <_narrow> method.
95 Event_Comm::Notifier::_narrow (notifier_obj
.in ());
97 catch (const CORBA::Exception
& ex
)
99 ex
._tao_print_exception ("Consumer_Handler::get_notifier\n");
107 Consumer_Handler::close ()
109 this->orb_
->shutdown ();
113 Consumer_Handler::shutdown ()
115 ACE_ASSERT (this->shutdowncallback
!= 0);
117 this->shutdowncallback
->close ();
121 Consumer_Handler::run ()
123 ACE_DEBUG ((LM_DEBUG
,
124 "Running the Consumer...\n"));
131 catch (const CORBA::Exception
&)
138 Consumer_Handler::reactor()
140 // @@ Please see if there's a way to get to the Reactor without
141 // using the TAO_ORB_Core_instance().
142 return TAO_ORB_Core_instance ()->reactor ();
145 Event_Comm::Consumer_ptr
146 Consumer_Handler::receiver ()
148 return this->receiver_
.in ();
151 Event_Comm::Notifier_ptr
152 Consumer_Handler::notifier ()
154 return this->notifier_
.in ();