#include <PG_FactoryRegistry.h>
Collaboration diagram for TAO::PG_FactoryRegistry:
Public Member Functions | |
PG_FactoryRegistry (const char *name="FactoryRegistry") | |
Constructor. | |
virtual | ~PG_FactoryRegistry (void) |
virtual Destructor | |
int | parse_args (int argc, char *argv[]) |
int | init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) |
void | init (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa ACE_ENV_ARG_DECL) |
int | fini (ACE_ENV_SINGLE_ARG_DECL) |
int | idle (int &result ACE_ENV_ARG_DECL) |
const char * | identity () const |
::PortableGroup::FactoryRegistry_ptr | reference () |
virtual void | _remove_ref (ACE_ENV_SINGLE_ARG_DECL) |
virtual void | register_factory (const char *role, const char *type_id, const PortableGroup::FactoryInfo &factory_info ACE_ENV_ARG_DECL) throw ( CORBA::SystemException , PortableGroup::MemberAlreadyPresent , PortableGroup::TypeConflict) |
virtual void | unregister_factory (const char *role, const PortableGroup::Location &location ACE_ENV_ARG_DECL) throw (CORBA::SystemException, PortableGroup::MemberNotFound) |
virtual void | unregister_factory_by_role (const char *role ACE_ENV_ARG_DECL) throw (CORBA::SystemException) |
virtual void | unregister_factory_by_location (const PortableGroup::Location &location ACE_ENV_ARG_DECL) throw (CORBA::SystemException) |
virtual::PortableGroup::FactoryInfos * | list_factories_by_role (const char *role, CORBA::String_out type_id ACE_ENV_ARG_DECL) throw (CORBA::SystemException) |
virtual::PortableGroup::FactoryInfos * | list_factories_by_location (const PortableGroup::Location &location ACE_ENV_ARG_DECL) throw (CORBA::SystemException) |
Private Types | |
typedef ACE_Null_Mutex | MapMutex |
typedef ACE_Hash_Map_Manager< ACE_CString, RoleInfo *, MapMutex > | RegistryType |
typedef ACE_Hash_Map_Entry< ACE_CString, RoleInfo * > | RegistryType_Entry |
typedef ACE_Hash_Map_Iterator< ACE_CString, RoleInfo *, MapMutex > | RegistryType_Iterator |
typedef ACE_Guard< TAO_SYNCH_MUTEX > | InternalGuard |
enum | { LIVE, DEACTIVATED, GONE } |
Private Member Functions | |
int | write_ior_file (const char *outputFile, const char *ior) |
Private Attributes | |
ACE_CString | identity_ |
TAO_SYNCH_MUTEX | internals_ |
CORBA::ORB_var | orb_ |
PortableServer::POA_var | poa_ |
PortableServer::ObjectId_var | object_id_ |
CORBA::Object_var | this_obj_ |
CORBA::String_var | ior_ |
const char * | ior_output_file_ |
const char * | ns_name_ |
CosNaming::NamingContext_var | naming_context_ |
CosNaming::Name | this_name_ |
int | quit_on_idle_ |
enum TAO::PG_FactoryRegistry:: { ... } | quit_state_ |
int | linger_ |
RegistryType | registry_ |
Definition at line 54 of file PG_FactoryRegistry.h.
|
Definition at line 201 of file PG_FactoryRegistry.h. |
|
Definition at line 64 of file PG_FactoryRegistry.h. |
|
Definition at line 65 of file PG_FactoryRegistry.h. |
|
Definition at line 66 of file PG_FactoryRegistry.h. Referenced by list_factories_by_location(), and unregister_factory_by_location(). |
|
Definition at line 67 of file PG_FactoryRegistry.h. Referenced by list_factories_by_location(), and unregister_factory_by_location(). |
|
State of the quit process Definition at line 250 of file PG_FactoryRegistry.h.
00250 {LIVE, DEACTIVATED, GONE} quit_state_; |
|
Constructor.
Definition at line 45 of file PG_FactoryRegistry.cpp.
00045 : identity_(name) 00046 , orb_ (0) 00047 , poa_ (0) 00048 , object_id_ (0) 00049 , this_obj_ (0) 00050 , ior_output_file_(0) 00051 , ns_name_(0) 00052 , naming_context_(0) 00053 , this_name_(1) 00054 , quit_on_idle_(0) 00055 , quit_state_(LIVE) 00056 , linger_(0) 00057 { 00058 } 00059 |
|
virtual Destructor
Definition at line 61 of file PG_FactoryRegistry.cpp.
00061 { 00062 } 00063 |
|
Definition at line 116 of file PG_FactoryRegistry.cpp. References GONE, and quit_state_.
00116 { 00117 this->quit_state_ = GONE; 00118 } 00119 |
|
Prepare to exit.
Definition at line 140 of file PG_FactoryRegistry.cpp. References ACE_ENV_ARG_PARAMETER, ior_output_file_, ns_name_, this_name_, and ACE_OS::unlink().
00140 { 00141 if (this->ior_output_file_ != 0) 00142 { 00143 ACE_OS::unlink (this->ior_output_file_); 00144 this->ior_output_file_ = 0; 00145 } 00146 if (this->ns_name_ != 0) 00147 { 00148 this->naming_context_->unbind (this_name_ 00149 ACE_ENV_ARG_PARAMETER); 00150 this->ns_name_ = 0; 00151 } 00152 return 0; 00153 } 00154 |
|
Identify this object.
Definition at line 111 of file PG_FactoryRegistry.cpp. References identity_. Referenced by unregister_factory(), unregister_factory_by_location(), and unregister_factory_by_role().
00111 { 00112 return this->identity_.c_str(); 00113 } 00114 |
|
Processing to happen when the ORB's event loop is idle.
Definition at line 121 of file PG_FactoryRegistry.cpp. References GONE, and quit_state_.
00121 { 00122 result = 0; 00123 int quit = 0; 00124 if (this->quit_state_ == GONE) 00125 { 00126 if (linger_ < 2) 00127 { 00128 ++linger_; 00129 } 00130 else 00131 { 00132 quit = 1; 00133 } 00134 } 00135 return quit; 00136 } 00137 |
|
alternative init using designated poa Definition at line 157 of file PG_FactoryRegistry.cpp. References CORBA::ORB::_duplicate(), ACE_ASSERT, ACE_CHECK, ACE_ENV_ARG_PARAMETER, and this_obj_.
00157 { 00158 ACE_ASSERT (CORBA::is_nil (this->orb_.in ())); 00159 ACE_ASSERT (CORBA::is_nil (this->poa_.in ())); 00160 this->orb_ = CORBA::ORB::_duplicate (orb); 00161 this->poa_ = PortableServer::POA::_duplicate (poa); 00162 ACE_ASSERT ( ! CORBA::is_nil (this->orb_.in ())); 00163 ACE_ASSERT ( ! CORBA::is_nil (this->poa_.in ())); 00164 00165 // Register with the POA. 00166 this->object_id_ = this->poa_->activate_object (this ACE_ENV_ARG_PARAMETER); 00167 ACE_CHECK; 00168 00169 // find my identity as a corba object 00170 this->this_obj_ = 00171 this->poa_->id_to_reference (object_id_.in () 00172 ACE_ENV_ARG_PARAMETER); 00173 ACE_CHECK; 00174 00175 // and create a ior string 00176 this->ior_ = this->orb_->object_to_string (this->this_obj_.in () 00177 ACE_ENV_ARG_PARAMETER); 00178 ACE_CHECK; 00179 00180 } 00181 |
|
Initialize this object.
Definition at line 183 of file PG_FactoryRegistry.cpp. References CORBA::ORB::_duplicate(), ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_ERROR_RETURN, ACE_TEXT(), identity_, ior_output_file_, CORBA::is_nil(), LM_ERROR, ns_name_, CORBA::string_dup(), TAO_OBJID_ROOTPOA, this_name_, this_obj_, and write_ior_file().
00184 { 00185 int result = 0; 00186 00187 this->orb_ = CORBA::ORB::_duplicate (orb); 00188 00189 // Use the ROOT POA for now 00190 CORBA::Object_var poa_object = 00191 this->orb_->resolve_initial_references (TAO_OBJID_ROOTPOA 00192 ACE_ENV_ARG_PARAMETER); 00193 ACE_CHECK_RETURN (-1); 00194 00195 if (CORBA::is_nil (poa_object.in ())) 00196 ACE_ERROR_RETURN ((LM_ERROR, 00197 ACE_TEXT (" (%P|%t) Unable to initialize the POA.\n")), 00198 -1); 00199 00200 // Get the POA object. 00201 this->poa_ = 00202 PortableServer::POA::_narrow (poa_object.in () 00203 ACE_ENV_ARG_PARAMETER); 00204 00205 ACE_CHECK_RETURN (-1); 00206 00207 if (CORBA::is_nil (this->poa_.in())) 00208 { 00209 ACE_ERROR_RETURN ((LM_ERROR, 00210 ACE_TEXT (" (%P|%t) Unable to narrow the POA.\n")), 00211 -1); 00212 } 00213 00214 PortableServer::POAManager_var poa_manager = 00215 this->poa_->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); 00216 ACE_CHECK_RETURN(-1); 00217 00218 poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); 00219 ACE_CHECK_RETURN(-1); 00220 00221 // Register with the POA. 00222 this->object_id_ = this->poa_->activate_object (this ACE_ENV_ARG_PARAMETER); 00223 ACE_CHECK_RETURN(-1); 00224 00225 // find my identity as a corba object 00226 this->this_obj_ = 00227 this->poa_->id_to_reference (object_id_.in () 00228 ACE_ENV_ARG_PARAMETER); 00229 ACE_CHECK_RETURN(-1); 00230 00231 00232 // and create a ior string 00233 this->ior_ = this->orb_->object_to_string (this->this_obj_.in () 00234 ACE_ENV_ARG_PARAMETER); 00235 ACE_CHECK_RETURN(-1); 00236 00237 00238 if (this->ior_output_file_ != 0) 00239 { 00240 this->identity_ = "file:"; 00241 this->identity_ += this->ior_output_file_; 00242 result = write_ior_file (this->ior_output_file_, 00243 this->ior_.in ()); 00244 } 00245 00246 if (this->ns_name_ != 0) 00247 { 00248 this->identity_ = "name:"; 00249 this->identity_ += this->ns_name_; 00250 00251 CORBA::Object_var naming_obj = 00252 this->orb_->resolve_initial_references ("NameService" ACE_ENV_ARG_PARAMETER); 00253 ACE_CHECK_RETURN(-1); 00254 00255 if (CORBA::is_nil(naming_obj.in ())){ 00256 ACE_ERROR_RETURN ((LM_ERROR, 00257 "%T %n (%P|%t) Unable to find the Naming Service\n"), 00258 1); 00259 } 00260 00261 this->naming_context_ = 00262 CosNaming::NamingContext::_narrow (naming_obj.in () ACE_ENV_ARG_PARAMETER); 00263 ACE_CHECK_RETURN(-1); 00264 00265 this->this_name_.length (1); 00266 this->this_name_[0].id = CORBA::string_dup (this->ns_name_); 00267 00268 this->naming_context_->rebind (this->this_name_, this->this_obj_.in() //CORBA::Object::_duplicate(this_obj) 00269 ACE_ENV_ARG_PARAMETER); 00270 ACE_CHECK_RETURN(-1); 00271 } 00272 00273 return result; 00274 } 00275 |
|
Definition at line 669 of file PG_FactoryRegistry.cpp. References ACE_CHECK_RETURN, ACE_NEW_THROW_EX, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::begin(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::end(), PortableGroup::FactoryInfos, TAO::PG_FactoryRegistry::RoleInfo::infos_, ACE_Hash_Map_Entry< ACE_CString, RoleInfo * >::int_id_, list_factories_by_location(), PortableGroup::Location, METHOD_ENTRY, METHOD_RETURN, registry_, RegistryType_Entry, RegistryType_Iterator, and PortableGroup::FactoryInfo::the_location. Referenced by list_factories_by_location().
00673 { 00674 METHOD_ENTRY(TAO::PG_FactoryRegistry::list_factories_by_location); 00675 ::PortableGroup::FactoryInfos_var result; 00676 ACE_NEW_THROW_EX (result, ::PortableGroup::FactoryInfos(this->registry_.current_size()), 00677 CORBA::NO_MEMORY (TAO::VMCID, CORBA::COMPLETED_NO)); 00678 00679 ACE_CHECK_RETURN (0); 00680 00681 size_t result_length = 0; 00682 00683 // iterate through the registery 00684 for (RegistryType_Iterator it = this->registry_.begin(); 00685 it != this->registry_.end(); 00686 ++it) 00687 { 00688 RegistryType_Entry & entry = *it; 00689 RoleInfo * role_info = entry.int_id_; 00690 00691 PortableGroup::FactoryInfos & found_infos = role_info->infos_; 00692 // iterate through the entry for this type 00693 int found = 0; 00694 size_t length = found_infos.length(); 00695 for (size_t nInfo = 0; !found && nInfo < length; ++nInfo) 00696 { 00697 PortableGroup::FactoryInfo & info = found_infos[nInfo]; 00698 if (info.the_location == location) 00699 { 00700 found = 1; 00701 result_length += 1; 00702 result->length(result_length); 00703 (*result)[result_length-1] = info; 00704 } 00705 } 00706 } 00707 00708 METHOD_RETURN(TAO::PG_FactoryRegistry::list_factories_by_location) result._retn(); 00709 } 00710 |
|
Definition at line 635 of file PG_FactoryRegistry.cpp. References ACE_CHECK_RETURN, ACE_ERROR, ACE_NEW_THROW_EX, PortableGroup::FactoryInfos, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::find(), TAO::PG_FactoryRegistry::RoleInfo::infos_, list_factories_by_role(), LM_INFO, METHOD_ENTRY, METHOD_RETURN, registry_, CORBA::string_dup(), and TAO::PG_FactoryRegistry::RoleInfo::type_id_. Referenced by list_factories_by_role().
00640 { 00641 METHOD_ENTRY(TAO::PG_FactoryRegistry::list_factories_by_role); 00642 00643 // allocate stucture to be returned. 00644 PortableGroup::FactoryInfos_var result = 0; 00645 ACE_NEW_THROW_EX (result, ::PortableGroup::FactoryInfos(), 00646 CORBA::NO_MEMORY (TAO::VMCID, CORBA::COMPLETED_NO)); 00647 00648 ACE_CHECK_RETURN (0); 00649 00650 RoleInfo * role_info = 0; 00651 if (this->registry_.find(role, role_info) == 0) 00652 { 00653 type_id = CORBA::string_dup(role_info->type_id_.c_str()); 00654 (*result) = role_info->infos_; 00655 } 00656 else 00657 { 00658 type_id = CORBA::string_dup(""); 00659 ACE_ERROR(( LM_INFO, 00660 "%s: list_factories_by_role: unknown role %s\n", 00661 this->identity_.c_str(), 00662 role 00663 )); 00664 } 00665 METHOD_RETURN(TAO::PG_FactoryRegistry::list_factories_by_role) result._retn(); 00666 } 00667 |
|
Parse command line arguments.
Definition at line 68 of file PG_FactoryRegistry.cpp. References ACE_ERROR_RETURN, ior_output_file_, LM_ERROR, ns_name_, and quit_on_idle_.
00068 { 00069 ACE_Get_Opt get_opts (argc, argv, "o:n:q"); 00070 int c; 00071 00072 while ((c = get_opts ()) != -1) 00073 { 00074 switch (c) 00075 { 00076 case 'o': 00077 { 00078 this->ior_output_file_ = get_opts.opt_arg (); 00079 break; 00080 } 00081 case 'n': 00082 { 00083 this->ns_name_ = get_opts.opt_arg(); 00084 break; 00085 } 00086 case 'q': 00087 { 00088 this->quit_on_idle_ = 1; 00089 break; 00090 } 00091 00092 case '?': 00093 // fall thru 00094 default: 00095 ACE_ERROR_RETURN ((LM_ERROR, 00096 "usage: %s" 00097 " -o <registry ior file>" 00098 " -n <name to use to register with name service>" 00099 " -q{uit on idle}" 00100 "\n", 00101 argv [0]), 00102 -1); 00103 break; 00104 } 00105 } 00106 // Indicates sucessful parsing of the command line 00107 return 0; 00108 } 00109 |
|
An object reference to the this object. Duplicated by the call so it may (and probably should) be assigned to a _var.. Definition at line 278 of file PG_FactoryRegistry.cpp.
00278 {
00279 // narrow and duplicate
00280 return ::PortableGroup::FactoryRegistry::_narrow(this->this_obj_.in ());
00281 }
00282
|
|
Definition at line 305 of file PG_FactoryRegistry.cpp. References ACE_AUTO_PTR_RESET, ACE_CHECK, ACE_DEBUG, ACE_ERROR, ACE_NEW_THROW_EX, ACE_THROW, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::bind(), PortableGroup::FactoryInfos, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::find(), ACE_Auto_Basic_Ptr< X >::get(), TAO::PG_FactoryRegistry::RoleInfo::infos_, LM_DEBUG, LM_ERROR, METHOD_ENTRY, METHOD_RETURN, register_factory(), registry_, ACE_Auto_Basic_Ptr< X >::release(), PortableGroup::FactoryInfo::the_location, and TAO::PG_FactoryRegistry::RoleInfo::type_id_. Referenced by register_factory().
00314 { 00315 METHOD_ENTRY(TAO::PG_FactoryRegistry::register_factory); 00316 00317 RoleInfo * role_info = 0; 00318 auto_ptr<RoleInfo> safe_entry; 00319 if (this->registry_.find(role, role_info) != 0) 00320 { 00321 ACE_DEBUG(( LM_DEBUG, 00322 "%s: adding new role: %s:%s\n", 00323 this->identity_.c_str(), role, type_id)); 00324 00325 // Note the 5. It's a guess about the number of factories 00326 // that might exist for any particular role object. 00327 // todo: make it a parameter. 00328 ACE_NEW_THROW_EX (role_info, 00329 RoleInfo(5), 00330 CORBA::NO_MEMORY()); 00331 ACE_CHECK; 00332 00333 ACE_AUTO_PTR_RESET (safe_entry, role_info, RoleInfo); 00334 role_info->type_id_ = type_id; 00335 } 00336 else 00337 { 00338 if (role_info->type_id_ != type_id) 00339 { 00340 ACE_THROW ( PortableGroup::TypeConflict() ); 00341 } 00342 } 00343 00344 PortableGroup::FactoryInfos & infos = role_info->infos_;; 00345 size_t length = infos.length(); 00346 for (size_t nInfo = 0; nInfo < length; ++nInfo) 00347 { 00348 PortableGroup::FactoryInfo & info = infos[nInfo]; 00349 if (info.the_location == factory_info.the_location) 00350 { 00351 ACE_ERROR(( LM_ERROR, 00352 "%s: Attempt to register duplicate location %s for role: %s\n" , 00353 this->identity_.c_str(), 00354 static_cast<const char *> (info.the_location[0].id), 00355 role)); 00356 ACE_THROW (PortableGroup::MemberAlreadyPresent() ); 00357 } 00358 } 00359 00360 infos.length(length + 1); 00361 infos[length] = factory_info; 00362 00363 if (safe_entry.get() != 0) 00364 { 00365 this->registry_.bind(role, safe_entry.release()); 00366 } 00367 00368 ACE_DEBUG(( LM_DEBUG, 00369 "%s: Added factory: [%d] %s@%s \n", 00370 this->identity_.c_str(), 00371 static_cast<int> (length + 1), 00372 role, 00373 static_cast<const char *> (factory_info.the_location[0].id) 00374 )); 00375 00376 METHOD_RETURN(TAO::PG_FactoryRegistry::register_factory); 00377 } 00378 |
|
Definition at line 380 of file PG_FactoryRegistry.cpp. References ACE_ASSERT, ACE_DEBUG, ACE_ENV_ARG_PARAMETER, ACE_ERROR, ACE_THROW, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::current_size(), PortableGroup::FactoryInfos, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::find(), identity(), TAO::PG_FactoryRegistry::RoleInfo::infos_, LIVE, LM_ERROR, LM_INFO, PortableGroup::Location, METHOD_ENTRY, METHOD_RETURN, quit_on_idle_, quit_state_, registry_, PortableGroup::FactoryInfo::the_location, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::unbind(), and unregister_factory(). Referenced by unregister_factory().
00385 { 00386 METHOD_ENTRY(TAO::PG_FactoryRegistry::unregister_factory); 00387 00388 RoleInfo * role_info = 0; 00389 if (this->registry_.find(role, role_info) == 0) 00390 { 00391 PortableGroup::FactoryInfos & infos = role_info->infos_; 00392 int found = 0; 00393 size_t length = infos.length(); 00394 for (size_t nInfo = 0; !found && nInfo < length; ++nInfo) 00395 { 00396 PortableGroup::FactoryInfo & info = infos[nInfo]; 00397 if (info.the_location == location) 00398 { 00399 found = 1; 00400 00401 ACE_ERROR(( LM_INFO, 00402 "%s: Unregistering factory %s@%s\n", 00403 this->identity_.c_str(), 00404 role, 00405 static_cast<const char *> (location[0].id) 00406 )); 00407 if (length > 1) 00408 { 00409 // if this is not the last entry 00410 if (nInfo + 1 < length) 00411 { 00412 // move last entry into newly-emptied slot 00413 infos[nInfo] = infos[length - 1]; 00414 nInfo = length -1; 00415 } 00416 infos.length(nInfo); 00417 } 00418 else 00419 { 00420 ACE_ASSERT ( length == 1 ); 00421 if (this->registry_.unbind (role) == 0) 00422 { 00423 ACE_DEBUG(( LM_INFO, 00424 "%s: No more factories registered for %s\n", 00425 this->identity_.c_str(), 00426 role 00427 )); 00428 delete role_info; 00429 } 00430 else 00431 { 00432 ACE_ERROR ((LM_ERROR, 00433 "%s: LOGIC ERROR AT " __FILE__ " (%d): Entry to be deleted disappeared\n", 00434 this->identity_.c_str(), 00435 __LINE__)); 00436 } 00437 } 00438 } 00439 } 00440 } 00441 else 00442 { 00443 ACE_ERROR(( LM_ERROR, 00444 "%s, Attempt to unregister factory for unknown role %s\n", 00445 this->identity_.c_str(), 00446 role 00447 )); 00448 ACE_THROW ( PortableGroup::MemberNotFound() ); 00449 } 00450 00451 ////////////////////// 00452 // request complete 00453 // check quit-on-idle 00454 if (registry_.current_size() == 0 && quit_state_ == LIVE) 00455 { 00456 ACE_ERROR(( LM_INFO, 00457 "%s is idle\n", 00458 identity() 00459 )); 00460 if (quit_on_idle_) 00461 { 00462 this->poa_->deactivate_object (this->object_id_.in () 00463 ACE_ENV_ARG_PARAMETER); 00464 quit_state_ = DEACTIVATED; 00465 } 00466 } 00467 00468 METHOD_RETURN(TAO::PG_FactoryRegistry::unregister_factory); 00469 } 00470 |
|
Definition at line 520 of file PG_FactoryRegistry.cpp. References ACE_ASSERT, ACE_CString, ACE_ENV_ARG_PARAMETER, ACE_ERROR, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::begin(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::current_size(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::end(), ACE_Hash_Map_Entry< ACE_CString, RoleInfo * >::ext_id_, PortableGroup::FactoryInfos, identity(), TAO::PG_FactoryRegistry::RoleInfo::infos_, ACE_Hash_Map_Entry< ACE_CString, RoleInfo * >::int_id_, LIVE, LM_ERROR, LM_INFO, PortableGroup::Location, METHOD_ENTRY, METHOD_RETURN, ACE_Vector< T, DEFAULT_SIZE >::push_back(), quit_on_idle_, quit_state_, registry_, RegistryType_Entry, RegistryType_Iterator, ACE_Vector< T, DEFAULT_SIZE >::size(), PortableGroup::FactoryInfo::the_location, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::unbind(), and unregister_factory_by_location(). Referenced by unregister_factory_by_location().
00524 { 00525 METHOD_ENTRY(TAO::PG_FactoryRegistry::unregister_factory_by_location); 00526 00527 //////////////////////////////////////////// 00528 // a vector of roles that need to be deleted. 00529 ACE_Vector<ACE_CString> emptyRoles; 00530 00531 // iterate through the registery 00532 for (RegistryType_Iterator it = this->registry_.begin(); 00533 it != this->registry_.end(); 00534 ++it) 00535 { 00536 RegistryType_Entry & entry = *it; 00537 ACE_CString & role = entry.ext_id_; 00538 RoleInfo * role_info = entry.int_id_; 00539 00540 PortableGroup::FactoryInfos & infos = role_info->infos_; 00541 // ACE_ERROR((LM_INFO, "unregister_factory_by_location: Checking role %s\n", role.c_str() )); 00542 00543 int found = 0; 00544 size_t length = infos.length(); 00545 for (size_t nInfo = 0; !found && nInfo < length; ++nInfo) 00546 { 00547 PortableGroup::FactoryInfo & info = infos[nInfo]; 00548 if (info.the_location == location) 00549 { 00550 00551 ACE_ERROR((LM_INFO, 00552 "%s: Unregister_factory_by_location: Removing: [%d] %s@%s\n", 00553 this->identity_.c_str(), 00554 static_cast<int> (nInfo), 00555 role.c_str(), 00556 static_cast<const char *> (location[0].id) 00557 )); 00558 found = 1; 00559 if (length > 1) 00560 { 00561 while (nInfo + 1 < length) 00562 { 00563 ACE_ERROR((LM_INFO, 00564 "%s: Unregister_factory_by_location: Move: [%d] %s to [%d]\n", 00565 this->identity_.c_str(), 00566 (int)nInfo + 1, role.c_str(), (int)nInfo 00567 )); 00568 infos[nInfo] = infos[nInfo + 1]; 00569 nInfo += 1; 00570 } 00571 ACE_ERROR((LM_INFO, 00572 "%s: unregister_factory_by_location: New length [%d] %s\n", 00573 this->identity_.c_str(), 00574 (int)nInfo, role.c_str() 00575 )); 00576 infos.length(nInfo); 00577 } 00578 else 00579 { 00580 ACE_ERROR((LM_INFO, 00581 "%s: Removed all entries for %s\n", 00582 this->identity_.c_str(), 00583 role.c_str() 00584 )); 00585 ACE_ASSERT ( length == 1 ); 00586 // remember entries to be deleted 00587 emptyRoles.push_back(entry.ext_id_); 00588 } 00589 } 00590 } 00591 } 00592 00593 // now remove any roles that became empty 00594 00595 for (size_t nRole = 0; nRole < emptyRoles.size(); ++nRole) 00596 { 00597 ACE_ERROR((LM_INFO, 00598 "%s: Remove role %s\n", 00599 this->identity_.c_str(), 00600 emptyRoles[nRole].c_str() 00601 )); 00602 RoleInfo * role_info; 00603 if (this->registry_.unbind(emptyRoles[nRole], role_info) == 0) 00604 { 00605 delete role_info; 00606 } 00607 else 00608 { 00609 ACE_ERROR ((LM_ERROR, 00610 "%s: LOGIC ERROR AT " __FILE__ " (%d): Role to be deleted disappeared\n", 00611 this->identity_.c_str(), 00612 __LINE__)); 00613 } 00614 } 00615 ////////////////////////// 00616 // If all types are gone... 00617 if (registry_.current_size() == 0 && quit_state_ == LIVE) 00618 { 00619 ACE_ERROR(( LM_INFO, 00620 "%s is idle\n", 00621 identity() 00622 )); 00623 if (quit_on_idle_) 00624 { 00625 this->poa_->deactivate_object (this->object_id_.in () 00626 ACE_ENV_ARG_PARAMETER); 00627 quit_state_ = DEACTIVATED; 00628 } 00629 } 00630 00631 METHOD_RETURN(TAO::PG_FactoryRegistry::unregister_factory_by_location); 00632 } 00633 |
|
Definition at line 472 of file PG_FactoryRegistry.cpp. References ACE_DEBUG, ACE_ENV_ARG_PARAMETER, ACE_ERROR, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::current_size(), identity(), LIVE, LM_DEBUG, LM_INFO, METHOD_ENTRY, METHOD_RETURN, quit_on_idle_, quit_state_, registry_, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::unbind(), and unregister_factory_by_role(). Referenced by unregister_factory_by_role().
00476 { 00477 METHOD_ENTRY(TAO::PG_FactoryRegistry::unregister_factory_by_role); 00478 00479 RoleInfo * role_info = 0; 00480 if (this->registry_.unbind(role, role_info) == 0) 00481 { 00482 ACE_DEBUG(( LM_DEBUG, 00483 "%s: Unregistering all factories for role %s\n", 00484 this->identity_.c_str(), 00485 role 00486 )); 00487 // delete the entire set of factories for this location. 00488 delete role_info; 00489 } 00490 else 00491 { 00492 ACE_ERROR(( LM_INFO, 00493 "%s: Unregister_factory_by_role: unknown role: %s\n", 00494 this->identity_.c_str(), 00495 role 00496 )); 00497 } 00498 00499 ///////////////////// 00500 // Function complete 00501 // check quit options 00502 if (registry_.current_size() == 0 && quit_state_ == LIVE) 00503 { 00504 ACE_ERROR(( LM_INFO, 00505 "%s is idle\n", 00506 identity() 00507 )); 00508 if (quit_on_idle_) 00509 { 00510 this->poa_->deactivate_object (this->object_id_.in () 00511 ACE_ENV_ARG_PARAMETER); 00512 quit_state_ = DEACTIVATED; 00513 } 00514 } 00515 00516 METHOD_RETURN(TAO::PG_FactoryRegistry::unregister_factory_by_role); 00517 } 00518 |
|
Write this factory's IOR to a file Definition at line 715 of file PG_FactoryRegistry.cpp. References ACE_ERROR, ACE_OS::fclose(), ACE_OS::fopen(), ACE_OS::fprintf(), and LM_ERROR. Referenced by init().
00715 { 00716 int result = -1; 00717 FILE* out = ACE_OS::fopen (outputFile, "w"); 00718 if (out) 00719 { 00720 ACE_OS::fprintf (out, "%s", ior); 00721 ACE_OS::fclose (out); 00722 result = 0; 00723 } 00724 else 00725 { 00726 ACE_ERROR ((LM_ERROR, 00727 "Open failed for %s\n", outputFile 00728 )); 00729 } 00730 return result; 00731 } 00732 |
|
A human-readable string to distinguish this from other Notifiers. Definition at line 190 of file PG_FactoryRegistry.h. Referenced by identity(), and init(). |
|
Protect internal state. Mutex should be locked by corba methods, or by external (public) methods before calling implementation methods. Implementation methods should assume the mutex is locked if necessary. Definition at line 200 of file PG_FactoryRegistry.h. |
|
IOR of this object as assigned by poa. Definition at line 226 of file PG_FactoryRegistry.h. |
|
A file to which the factory's IOR should be written. Definition at line 231 of file PG_FactoryRegistry.h. Referenced by fini(), init(), and parse_args(). |
|
Definition at line 252 of file PG_FactoryRegistry.h. |
|
Definition at line 238 of file PG_FactoryRegistry.h. |
|
A name to be used to register the factory with the name service. Definition at line 236 of file PG_FactoryRegistry.h. Referenced by fini(), init(), and parse_args(). |
|
The CORBA object id assigned to this object. Definition at line 216 of file PG_FactoryRegistry.h. |
|
The orb Definition at line 206 of file PG_FactoryRegistry.h. |
|
The POA used to activate this object. Definition at line 211 of file PG_FactoryRegistry.h. |
|
Quit on idle flag. Definition at line 245 of file PG_FactoryRegistry.h. Referenced by parse_args(), unregister_factory(), unregister_factory_by_location(), and unregister_factory_by_role(). |
|
State of the quit process Referenced by _remove_ref(), idle(), unregister_factory(), unregister_factory_by_location(), and unregister_factory_by_role(). |
|
Definition at line 254 of file PG_FactoryRegistry.h. Referenced by list_factories_by_location(), list_factories_by_role(), register_factory(), unregister_factory(), unregister_factory_by_location(), and unregister_factory_by_role(). |
|
Definition at line 240 of file PG_FactoryRegistry.h. |
|
This objects identity as a CORBA object. Definition at line 221 of file PG_FactoryRegistry.h. Referenced by init(). |