Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / orbsvcs / tests / Notify / lib / LookupManager.cpp
blobc06c2834a62483e07b13bedfbf2cfb4a0556741b
1 #include "LookupManager.h"
2 #include "ace/OS_NS_string.h"
5 #include "Name.h"
7 TAO_Notify_Tests_LookupManager::TAO_Notify_Tests_LookupManager ()
8 : app_ (0)
9 , activation_manager_ (0)
10 , priority_mapping_ (0)
14 TAO_Notify_Tests_LookupManager::~TAO_Notify_Tests_LookupManager ()
18 void
19 TAO_Notify_Tests_LookupManager::init (CORBA::ORB_ptr orb)
21 orb_ = CORBA::ORB::_duplicate (orb);
23 this->resolve (this->root_poa_, TAO_Notify_Tests_Name::root_poa);
25 this->resolve (this->naming_, TAO_Notify_Tests_Name::naming_service);
28 void
29 TAO_Notify_Tests_LookupManager::_register (CORBA::Object_ptr obj, const char* obj_name)
31 CosNaming::Name_var name =
32 this->naming_->to_name (obj_name);
33 //@@ Warning: this is rebind..
34 this->naming_->rebind (name.in (),
35 obj);
37 ACE_DEBUG ((LM_DEBUG, "Registered %s with Naming Service\n", obj_name));
40 void
41 TAO_Notify_Tests_LookupManager::_register (TAO_Notify_Tests_Driver_Base* app)
43 this->app_ = app;
46 void
47 TAO_Notify_Tests_LookupManager::resolve (TAO_Notify_Tests_Driver_Base*& app)
49 app = this->app_;
52 void
53 TAO_Notify_Tests_LookupManager::_register (TAO_Notify_Tests_Activation_Manager* activation_manager)
55 this->activation_manager_ = activation_manager;
58 void
59 TAO_Notify_Tests_LookupManager::resolve (TAO_Notify_Tests_Activation_Manager*& activation_manager)
61 activation_manager = this->activation_manager_;
64 void
65 TAO_Notify_Tests_LookupManager::_register (TAO_Notify_Tests_Priority_Mapping* priority_mapping)
67 this->priority_mapping_ = priority_mapping;
70 void
71 TAO_Notify_Tests_LookupManager::resolve (TAO_Notify_Tests_Priority_Mapping* &priority_mapping)
73 priority_mapping = this->priority_mapping_;
76 void
77 TAO_Notify_Tests_LookupManager::resolve (CORBA::ORB_var& orb)
79 orb = this->orb_;
82 void
83 TAO_Notify_Tests_LookupManager::resolve (PortableServer::POA_var& poa)
85 poa = this->root_poa_;
88 void
89 TAO_Notify_Tests_LookupManager::resolve (CosNaming::NamingContextExt_var& naming)
91 naming = this->naming_;
94 void
95 TAO_Notify_Tests_LookupManager::resolve (PortableServer::POA_var& poa, const char *poa_name)
97 if (ACE_OS::strcmp (poa_name, TAO_Notify_Tests_Name::root_poa) == 0)
99 CORBA::Object_ptr poa_object =
100 this->orb_->resolve_initial_references(TAO_Notify_Tests_Name::root_poa);
102 if (CORBA::is_nil (poa_object))
104 ACE_ERROR ((LM_ERROR,
105 " (%P|%t) Unable to resolve the Root POA.\n"));
106 return;
109 poa = PortableServer::POA::_narrow (poa_object);
111 this->root_poa_ = poa;
113 else
115 poa = root_poa_->find_POA (poa_name, 0);
119 void
120 TAO_Notify_Tests_LookupManager::resolve (CosNaming::NamingContextExt_var& naming, const char *naming_name)
122 CORBA::Object_var naming_obj =
123 this->orb_->resolve_initial_references (naming_name);
125 // Need to check return value for errors.
126 if (CORBA::is_nil (naming_obj.in ()))
127 throw CORBA::UNKNOWN ();
129 this->naming_ = CosNaming::NamingContextExt::_narrow (naming_obj.in ());
131 CosNaming::NamingContextExt::_duplicate (this->naming_.in ());
133 naming = this->naming_;
136 CORBA::Object_ptr
137 TAO_Notify_Tests_LookupManager::resolve_object (const char* obj_name)
139 CosNaming::Name name (1);
140 name.length (1);
141 name[0].id = CORBA::string_dup (obj_name);
143 CORBA::Object_var obj =
144 this->naming_->resolve (name);
146 return obj._retn ();
149 void
150 TAO_Notify_Tests_LookupManager::resolve (CosNotifyChannelAdmin::EventChannelFactory_var& ecf, const char * factory_name)
152 CORBA::Object_var object = this->resolve_object (factory_name);
154 ecf = CosNotifyChannelAdmin::EventChannelFactory::_narrow (object.in());
157 void
158 TAO_Notify_Tests_LookupManager::resolve (CosNotifyChannelAdmin::EventChannel_var& ec, const char * channel_name)
160 CORBA::Object_var object = this->resolve_object (channel_name);
162 ec = CosNotifyChannelAdmin::EventChannel::_narrow (object.in());
165 void
166 TAO_Notify_Tests_LookupManager::resolve (CosNotifyChannelAdmin::SupplierAdmin_var& sa, const char * admin_name)
168 CORBA::Object_var object = this->resolve_object (admin_name);
170 sa = CosNotifyChannelAdmin::SupplierAdmin::_narrow (object.in());
173 void
174 TAO_Notify_Tests_LookupManager::resolve (CosNotifyChannelAdmin::ConsumerAdmin_var& ca , const char * admin_name)
176 CORBA::Object_var object = this->resolve_object (admin_name);
178 ca = CosNotifyChannelAdmin::ConsumerAdmin::_narrow (object.in());
181 void
182 TAO_Notify_Tests_LookupManager::resolve (CosNotifyComm::StructuredPushSupplier_var& supplier, const char *supplier_name)
184 CORBA::Object_var object = this->resolve_object (supplier_name);
186 supplier = CosNotifyComm::StructuredPushSupplier::_narrow (object.in());
189 void
190 TAO_Notify_Tests_LookupManager::resolve (CosNotifyComm::StructuredPushConsumer_var& consumer, const char * consumer_name)
192 CORBA::Object_var object = this->resolve_object (consumer_name);
194 consumer = CosNotifyComm::StructuredPushConsumer::_narrow (object.in());
197 void
198 TAO_Notify_Tests_LookupManager::resolve (CosNotifyFilter::FilterFactory_var& ff, const char *filter_factory_name)
200 CORBA::Object_var object = this->resolve_object (filter_factory_name);
202 ff = CosNotifyFilter::FilterFactory::_narrow (object.in());
205 void
206 TAO_Notify_Tests_LookupManager::resolve (CosNotifyFilter::Filter_var& filter, const char *filter_name)
208 CORBA::Object_var object = this->resolve_object (filter_name);
210 filter = CosNotifyFilter::Filter::_narrow (object.in());
213 void
214 TAO_Notify_Tests_LookupManager::resolve (CosNotifyFilter::FilterAdmin_var& filter_admin, const char *filter_admin_name)
216 CORBA::Object_var object = this->resolve_object (filter_admin_name);
218 filter_admin = CosNotifyFilter::FilterAdmin::_narrow (object.in());
221 ACE_SINGLETON_TEMPLATE_INSTANTIATE(ACE_Singleton, TAO_Notify_Tests_LookupManager, TAO_SYNCH_MUTEX);