diff options
author | wilson_d <wilson_d@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-11-30 18:16:56 +0000 |
---|---|---|
committer | wilson_d <wilson_d@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-11-30 18:16:56 +0000 |
commit | 3d011b8ab662d7ada26caaca352252ba9f8ba91f (patch) | |
tree | bfbc2e8552e128aaac851da46d3c8a7540cae4e1 | |
parent | 9931bb4e27ddde10ccbf57c05b6ee4b25225a413 (diff) | |
download | ATCD-3d011b8ab662d7ada26caaca352252ba9f8ba91f.tar.gz |
ChangeLogTag: Sun Nov 30 11:53:38 2003 Dale Wilson <wilson_d@ociweb.com>
14 files changed, 794 insertions, 486 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index ef970dcf01e..30ddf16d77b 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,36 @@ +Sun Nov 30 11:53:38 2003 Dale Wilson <wilson_d@ociweb.com> + + * orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.h: + * orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.cpp: + New: support for implementing a GenericFactory for groups. + + * orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h: + * orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp: + Remove all dependancies on PG_PropertyManager, PG_GenericFactory, + and PG_ObjectGroupManager. Uses PG_Properties_Support and + PG_Group_Factory (which uses PG_Object_Groups) instead. + + * orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.h: + * orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.cpp: + Add an init method for use when it's not stand-alone. + + * orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp: + Initialize Group Manipulator (probably moot since I intend + to back out all changes to ObjectGroupManager.) + + * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h: + * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp: + Revise for use with Group_Factory. + + * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Manipulator.h: + * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Manipulator.cpp: + Init was throwing exception and returning status. + Changed to report all errors via excepton. + + * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.h: + * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.cpp: + Removed this file. It became part of PG_Group_Factory. + Fri Nov 28 18:04:32 2003 Dale Wilson <wilson_d@ociweb.com> * orbsvcs/orbsvcs/PortableGroup/PG_Properties_Decoder.h: diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp index 3dc03c87b82..710d13b638b 100644 --- a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp +++ b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp @@ -33,9 +33,6 @@ ACE_RCSID (FT_ReplicationManager, "$Id$") -#define SUPPORT_OLD_PROPERTY_MANAGER -//#define USE_OLD_PROPERTY_MANAGER - // Use this macro at the beginning of CORBA methods // to aid in debugging. #define METHOD_ENTRY(name) \ @@ -66,6 +63,8 @@ ACE_RCSID (FT_ReplicationManager, } \ return /* value goes here */ +#define TODO +//#define TODO int todo; // warn on todos TAO::FT_ReplicationManager::FT_ReplicationManager () : orb_ (CORBA::ORB::_nil ()) @@ -74,9 +73,6 @@ TAO::FT_ReplicationManager::FT_ReplicationManager () , ns_name_ (0) , naming_context_ (CosNaming::NamingContext::_nil ()) , replication_manager_ref_ (FT::ReplicationManager::_nil ()) - , object_group_manager_ () - , property_manager_ (object_group_manager_) - , generic_factory_ (this->object_group_manager_, this->property_manager_) , fault_notifier_ (FT::FaultNotifier::_nil ()) , fault_notifier_ior_string_ (0) , fault_consumer_ () @@ -141,6 +137,8 @@ const char * TAO::FT_ReplicationManager::identity () const int TAO::FT_ReplicationManager::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) { + int result = 0; + if (TAO_debug_level > 1) { ACE_DEBUG ( (LM_DEBUG, @@ -149,29 +147,8 @@ int TAO::FT_ReplicationManager::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) )); } - int result = 0; - this->orb_ = CORBA::ORB::_duplicate (orb); - // Create our Property Validator and set it on the Property Manager. - TAO::FT_Property_Validator * property_validator = 0; - ACE_NEW_RETURN (property_validator, TAO::FT_Property_Validator (), -1); - if (property_validator != 0) - { - this->property_manager_.init (property_validator); - } - else - { - ACE_ERROR_RETURN ( (LM_ERROR, - ACE_TEXT ( - "%T %n (%P|%t) - " - "Could not create Property Validator.\n")), - -1); - } - - - // initialize the FactoryRegistry - this->factory_registry_.init (this->orb_.in () ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); + this->orb_ = CORBA::ORB::_duplicate (orb); // Get the RootPOA. CORBA::Object_var poa_obj = this->orb_->resolve_initial_references ( @@ -181,25 +158,19 @@ int TAO::FT_ReplicationManager::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) poa_obj.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); - // Initialize the Object Group Manager. - result = this->object_group_manager_.init ( - this->orb_.in (), this->poa_.in ()); - if (result != 0) - { - if (TAO_debug_level > 3) - { - ACE_ERROR ( (LM_ERROR, - ACE_TEXT ( - "%T %n (%P|%t) - " - "Could not initialize the Object Group Manager.\n"))); - } - return -1; - } + + // initialize the FactoryRegistry + this->factory_registry_.init (this->orb_.in (), this->poa_.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + // @@: do we want to use the same poa to create object groups? + this->group_factory_.init (this->orb_.in (), this->poa_.in ()); // Activate ourself in the POA. PortableServer::ObjectId_var oid = this->poa_->activate_object ( this ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); + CORBA::Object_var this_obj = this->poa_->id_to_reference ( oid.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); @@ -519,9 +490,18 @@ char * TAO::FT_ReplicationManager::type_id ( PortableGroup::ObjectGroup_ptr object_group ACE_ENV_ARG_DECL) { - // Delegate to our ObjectGroupManager. - return this->object_group_manager_.type_id ( - object_group ACE_ENV_ARG_PARAMETER); + char * result = 0; + TAO::PG_Object_Group * group = 0; + if (this->group_factory_.find_group (object_group, group)) + { + result = group->get_type_id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + } + else + { + ACE_THROW_RETURN (PortableGroup::ObjectGroupNotFound (), 0); + } + return result; } ////////////////////////////////////////////////////// @@ -535,11 +515,6 @@ TAO::FT_ReplicationManager::set_default_properties ( PortableGroup::InvalidProperty, PortableGroup::UnsupportedProperty)) { -#ifdef SUPPORT_OLD_PROPERTY_MANAGER - this->property_manager_.set_default_properties (props - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; -#endif //SUPPORT_OLD_PROPERTY_MANAGER this->properties_support_.set_default_properties (props); //@@ validate properties? @@ -550,14 +525,8 @@ TAO::FT_ReplicationManager::get_default_properties ( ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ( (CORBA::SystemException)) { -#ifdef USE_OLD_PROPERTY_MANAGER - return - this->property_manager_.get_default_properties ( - ACE_ENV_SINGLE_ARG_PARAMETER); -#else // USE_OLD_PROPERTY_MANAGER return this->properties_support_.get_default_properties ( ACE_ENV_SINGLE_ARG_PARAMETER); -#endif //USE _OLD_PROPERTY_MANAGER } void @@ -568,11 +537,6 @@ TAO::FT_ReplicationManager::remove_default_properties ( PortableGroup::InvalidProperty, PortableGroup::UnsupportedProperty)) { -#ifdef SUPPORT_OLD_PROPERTY_MANAGER - this->property_manager_.remove_default_properties (props - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; -#endif //SUPPORT_OLD_PROPERTY_MANAGER this->properties_support_.remove_default_properties (props ACE_ENV_ARG_PARAMETER); } @@ -586,12 +550,6 @@ TAO::FT_ReplicationManager::set_type_properties ( PortableGroup::InvalidProperty, PortableGroup::UnsupportedProperty)) { -#ifdef SUPPORT_OLD_PROPERTY_MANAGER - this->property_manager_.set_type_properties (type_id, - overrides - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; -#endif //SUPPORT_OLD_PROPERTY_MANAGER this->properties_support_.set_type_properties ( type_id, overrides @@ -604,15 +562,8 @@ TAO::FT_ReplicationManager::get_type_properties ( ACE_ENV_ARG_DECL) ACE_THROW_SPEC ( (CORBA::SystemException)) { -#ifdef USE_OLD_PROPERTY_MANAGER - return - this->property_manager_.get_type_properties (type_id - ACE_ENV_ARG_PARAMETER); -#else // USE_OLD_PROPERTY_MANAGER return this->properties_support_.get_type_properties (type_id ACE_ENV_ARG_PARAMETER); - -#endif //USE_OLD_PROPERTY_MANAGER } void @@ -624,11 +575,6 @@ TAO::FT_ReplicationManager::remove_type_properties ( PortableGroup::InvalidProperty, PortableGroup::UnsupportedProperty)) { -#ifdef SUPPORT_OLD_PROPERTY_MANAGER - this->property_manager_.remove_type_properties (type_id, - props - ACE_ENV_ARG_PARAMETER); -#endif //SUPPORT_OLD_PROPERTY_MANAGER this->properties_support_.remove_type_properties ( type_id, props @@ -645,15 +591,9 @@ TAO::FT_ReplicationManager::set_properties_dynamically ( PortableGroup::InvalidProperty, PortableGroup::UnsupportedProperty)) { -#ifdef SUPPORT_OLD_PROPERTY_MANAGER - this->property_manager_.set_properties_dynamically (object_group, - overrides - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; -#endif //SUPPORT_OLD_PROPERTY_MANAGER TAO::PG_Object_Group * group = 0; - if (this->object_group_map_.find_group (object_group, group)) + if (this->group_factory_.find_group (object_group, group)) { group->set_properties_dynamically (overrides ACE_ENV_ARG_PARAMETER); ACE_CHECK; @@ -671,16 +611,11 @@ TAO::FT_ReplicationManager::get_properties ( ACE_THROW_SPEC ( (CORBA::SystemException, PortableGroup::ObjectGroupNotFound)) { -#ifdef USE_OLD_PROPERTY_MANAGER - return - this->property_manager_.get_properties (object_group - ACE_ENV_ARG_PARAMETER); -#else // USE_OLD_PROPERTY_MANAGER PortableGroup::Properties_var result; ACE_NEW_THROW_EX (result, PortableGroup::Properties(), CORBA::NO_MEMORY ()); TAO::PG_Object_Group * group = 0; - if (this->object_group_map_.find_group (object_group, group)) + if (this->group_factory_.find_group (object_group, group)) { group->get_properties (result ACE_ENV_ARG_PARAMETER); ACE_CHECK; @@ -690,7 +625,6 @@ TAO::FT_ReplicationManager::get_properties ( ACE_THROW (PortableGroup::ObjectGroupNotFound ()); } return result._retn(); -#endif // USE_OLD_PROPERTY_MANAGER } @@ -714,7 +648,7 @@ TAO::FT_ReplicationManager::set_primary_member ( METHOD_ENTRY (TAO::FT_ReplicationManager::set_primary_member); PortableGroup::ObjectGroup_var result = PortableGroup::ObjectGroup::_nil(); TAO::PG_Object_Group * group = 0; - if (this->object_group_map_.find_group (object_group, group)) + if (this->group_factory_.find_group (object_group, group)) { PortableGroup::TagGroupTaggedComponent tag_component; @@ -753,14 +687,10 @@ TAO::FT_ReplicationManager::create_member ( PortableGroup::InvalidCriteria, PortableGroup::CannotMeetCriteria)) { - return - this->object_group_manager_.create_member (object_group, - the_location, - type_id, - the_criteria - ACE_ENV_ARG_PARAMETER); - -//@@ int todo; + PortableGroup::ObjectGroup_var result = PortableGroup::ObjectGroup::_nil(); +TODO +//@@ TODO + return result._retn(); } @@ -780,16 +710,8 @@ TAO::FT_ReplicationManager::add_member ( // Find the object group corresponding to this IOGR TAO::PG_Object_Group * group = 0; - if (this->object_group_map_.find_group (object_group, group)) + if (this->group_factory_.find_group (object_group, group)) { - // add the member to the OGM's group information - // assign the (meaningless) result to a var. so we'll release it. - PortableGroup::ObjectGroup_var new_ogm_group = this->object_group_manager_.add_member ( - object_group, - the_location, - member - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (result._retn ()); /////////////////////// // Now we do it again using @@ -832,21 +754,11 @@ TAO::FT_ReplicationManager::remove_member ( // Find the object group corresponding to this IOGR TAO::PG_Object_Group * group = 0; - if (this->object_group_map_.find_group (object_group, group)) + if (this->group_factory_.find_group (object_group, group)) { group->remove_member(the_location ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (result._retn ()); result = group->reference (); - - // @@ warning: if the remove_member call below is unsuccessful - // the parallel object group information will be out of synch - // Unifying the Object group management will fix this. - (void) this->object_group_manager_.remove_member ( - object_group, - the_location - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (PortableGroup::ObjectGroup::_nil ()); - } else { @@ -862,9 +774,9 @@ TAO::FT_ReplicationManager::locations_of_members ( ACE_THROW_SPEC ( (CORBA::SystemException, PortableGroup::ObjectGroupNotFound)) { - return - this->object_group_manager_.locations_of_members (object_group - ACE_ENV_ARG_PARAMETER); + TODO + return 0; + } PortableGroup::ObjectGroups * @@ -873,9 +785,8 @@ TAO::FT_ReplicationManager::groups_at_location ( ACE_ENV_ARG_DECL) ACE_THROW_SPEC ( (CORBA::SystemException)) { - return - this->object_group_manager_.groups_at_location (the_location - ACE_ENV_ARG_PARAMETER); + TODO + return 0; } PortableGroup::ObjectGroupId @@ -885,9 +796,8 @@ TAO::FT_ReplicationManager::get_object_group_id ( ACE_THROW_SPEC ( (CORBA::SystemException, PortableGroup::ObjectGroupNotFound)) { - return - this->object_group_manager_.get_object_group_id (object_group - ACE_ENV_ARG_PARAMETER); + TODO + return 0; } PortableGroup::ObjectGroup_ptr @@ -897,9 +807,9 @@ TAO::FT_ReplicationManager::get_object_group_ref ( ACE_THROW_SPEC ( (CORBA::SystemException, PortableGroup::ObjectGroupNotFound)) { - return - this->object_group_manager_.get_object_group_ref (object_group - ACE_ENV_ARG_PARAMETER); + PortableGroup::ObjectGroup_var result = PortableGroup::ObjectGroup::_nil(); + TODO + return result._retn(); } PortableGroup::ObjectGroup_ptr @@ -911,9 +821,9 @@ TAO::FT_ReplicationManager::get_object_group_ref_from_id ( , PortableGroup::ObjectGroupNotFound )) { - return - this->object_group_manager_.get_object_group_ref_from_id (group_id - ACE_ENV_ARG_PARAMETER); + PortableGroup::ObjectGroup_var result = PortableGroup::ObjectGroup::_nil(); + TODO + return result._retn(); } CORBA::Object_ptr @@ -925,10 +835,9 @@ TAO::FT_ReplicationManager::get_member_ref ( PortableGroup::ObjectGroupNotFound, PortableGroup::MemberNotFound)) { - return - this->object_group_manager_.get_member_ref (object_group, - the_location - ACE_ENV_ARG_PARAMETER); + CORBA::Object_var result = CORBA::Object::_nil(); + TODO + return result._retn(); } @@ -950,20 +859,9 @@ TAO::FT_ReplicationManager::create_object ( { METHOD_ENTRY (TAO::FT_ReplicationManager::create_object) - // Start with the LB-oriented create_object - // which actually creates an object group - CORBA::Object_var obj = this->generic_factory_.create_object ( - type_id, - the_criteria, - factory_creation_id - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (CORBA::Object::_nil ()); - //////////////////////////////// - // then create the corresponding - // entry in our object group map - - // first find the properties for this type of object group + // find the properties for this + // type of object group TAO_PG::Properties_Decoder * typeid_properties = this->properties_support_.find_typeid_properties ( type_id @@ -971,43 +869,28 @@ TAO::FT_ReplicationManager::create_object ( ACE_CHECK_RETURN (CORBA::Object::_nil ()); TAO::PG_Object_Group * objectGroup - = TAO::PG_Object_Group::create ( - this->orb_.in (), - this->poa_.in (), - obj.in (), + = this->group_factory_.create_group ( type_id, the_criteria, typeid_properties ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (CORBA::Object::_nil ()); - this->object_group_map_.insert_group (objectGroup->get_object_group_id (), objectGroup); - - if (TAO_debug_level > 1) - { - PortableGroup::ObjectGroupId factory_id; - if ((*factory_creation_id) >>= factory_id) - { - PortableGroup::ObjectGroupId ogid = objectGroup->get_object_group_id (); - if (factory_id != ogid) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT("Sanity check failed: Factory creation id[%u] != object group id[%u]\n"), - ACE_static_cast (unsigned, factory_id), - ACE_static_cast (unsigned, ogid) - )); - } - } - else - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT("Sanity check failed: Factory creation id is not an object group id\n") - )); - } - - } + // Allocate a new FactoryCreationId for use as an "out" parameter. + PortableGroup::GenericFactory::FactoryCreationId_var factory_id = 0; + ACE_NEW_THROW_EX (factory_id, + PortableGroup::GenericFactory::FactoryCreationId, + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO_DEFAULT_MINOR_CODE, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + PortableGroup::ObjectGroupId group_id = objectGroup->get_object_group_id (); + *factory_id <<= group_id; + factory_creation_id = factory_id._retn(); - METHOD_RETURN (TAO::FT_ReplicationManager::create_object) obj._retn (); + METHOD_RETURN (TAO::FT_ReplicationManager::create_object) objectGroup->reference (); } void @@ -1018,9 +901,16 @@ TAO::FT_ReplicationManager::delete_object ( PortableGroup::ObjectNotFound)) { - this->generic_factory_.delete_object (factory_creation_id - ACE_ENV_ARG_PARAMETER); - -//@@ int todo; - ACE_CHECK; + PortableGroup::ObjectGroupId group_id = 0; + if (factory_creation_id >>= group_id) + { + this->group_factory_.delete_group ( + group_id + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + else + { + ACE_THROW (PortableGroup::ObjectNotFound ()); + } } diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h index 17140753f35..00f6d0079b5 100644 --- a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h +++ b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h @@ -23,15 +23,17 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include <orbsvcs/FT_ReplicationManagerS.h> -#include <orbsvcs/PortableGroup/PG_PropertyManager.h> -#include <orbsvcs/PortableGroup/PG_GenericFactory.h> -#include <orbsvcs/PortableGroup/PG_ObjectGroupManager.h> +//#include <orbsvcs/PortableGroup/PG_PropertyManager.h> +//#include <orbsvcs/PortableGroup/PG_GenericFactory.h> +//#include <orbsvcs/PortableGroup/PG_ObjectGroupManager.h> +// Note: the new, improved versions... +//#include <orbsvcs/PortableGroup/PG_Object_Group_Map.h> +#include <orbsvcs/PortableGroup/PG_Properties_Support.h> +#include <orbsvcs/PortableGroup/PG_Group_Factory.h> + #include <orbsvcs/PortableGroup/PG_FactoryRegistry.h> #include <orbsvcs/FT_ReplicationManager/FT_FaultConsumer.h> -// Note: the new, improved versions... -#include <orbsvcs/PortableGroup/PG_Object_Group_Map.h> -#include <orbsvcs/PortableGroup/PG_Properties_Support.h> namespace TAO { @@ -448,28 +450,8 @@ namespace TAO /// A human-readable string to identify this Replication Manager. ACE_CString identity_; - /// The ObjectGroupManager that implements the functionality - /// necessary for application-controlled object group membership. - TAO_PG_ObjectGroupManager object_group_manager_; - - /// The PropertyManager that is reponsible for parsing all criteria, - /// and keeping track of property-type_id associations. - TAO_PG_PropertyManager property_manager_; - - /// The GenericFactory responsible for creating all object groups. - TAO_PG_GenericFactory generic_factory_; - + TAO::PG_Group_Factory group_factory_; - // @@ The PortableGroup::ObjectGroupManager contains information about object groups - // in a TAO_PG_ObjectGroup_Map object. Unfortunatly this doesn't contain - // then information necessary to manage IOGRs. Originally I planned to extend that - // structure to support fault tolerance, but I ran into a large number of side effects - // as I changed that structure, so as an interim step I defined a new collection: - // TAO::PG_Object_Group_Map. The similarity in names is intentional. I still hope - // to replace the TAO_PG_ObjectGroup_Map int the ObjectGroupManager a with TAO::PG_Object_Group_Map - // but not right now. Dale Wilson wilson_d@ociweb.com - /// A container for our object group information - TAO::PG_Object_Group_Map object_group_map_; TAO::PG_Properties_Support properties_support_; diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.cpp index c6638b2edab..e7c0929c9cc 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.cpp @@ -147,6 +147,33 @@ int TAO::PG_FactoryRegistry::fini (ACE_ENV_SINGLE_ARG_DECL) return 0; } + +void TAO::PG_FactoryRegistry::init (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa ACE_ENV_ARG_DECL) +{ + ACE_ASSERT (CORBA::is_nil (this->orb_.in ())); + ACE_ASSERT (CORBA::is_nil (this->poa_.in ())); + this->orb_ = CORBA::ORB::_duplicate (orb); + this->poa_ = PortableServer::POA::_duplicate (poa); + ACE_ASSERT ( ! CORBA::is_nil (this->orb_.in ())); + ACE_ASSERT ( ! CORBA::is_nil (this->poa_.in ())); + + // Register with the POA. + this->object_id_ = this->poa_->activate_object (this ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // find my identity as a corba object + this->this_obj_ = + this->poa_->id_to_reference (object_id_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // and create a ior string + this->ior_ = this->orb_->object_to_string (this->this_obj_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + +} + int TAO::PG_FactoryRegistry::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) { int result = 0; diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.h index d240f291299..e3d848eb1ea 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.h +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.h @@ -83,6 +83,11 @@ namespace TAO int init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL); /** + * alternative init using designated poa + */ + void init (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa ACE_ENV_ARG_DECL); + + /** * Prepare to exit. * @return zero for success; nonzero is process return code for failure. */ diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.cpp new file mode 100644 index 00000000000..5e4861d3684 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.cpp @@ -0,0 +1,423 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file PG_Group_Factory.cpp + * + * $Id$ + * + * @author Dale Wilson <wilson_d@ociweb.com> + */ +//============================================================================= + +#include "PG_Group_Factory.h" +#include "PG_Property_Utils.h" +#include "PG_conf.h" +#include "orbsvcs/PortableGroupC.h" +#include "PG_Object_Group.h" +#include <orbsvcs/orbsvcs/PortableGroup/PG_Utils.h> + +//#include "PG_Properties_Encoder.h" +//#include "PG_Properties_Decoder.h" + + +ACE_RCSID (PortableGroup, + PG_Group_Factory::, + "$Id$") + + +TAO::PG_Group_Factory::PG_Group_Factory () + : orb_ (CORBA::ORB::_nil()) + , poa_ (PortableServer::POA::_nil()) + , manipulator_ () + , domain_id_ ("default-domain") + +{ +} + +TAO::PG_Group_Factory::~PG_Group_Factory (void) +{ + // todo: destroy all members +} + + +void TAO::PG_Group_Factory::init ( + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa ACE_ENV_ARG_DECL) +{ + ACE_ASSERT (CORBA::is_nil (this->orb_.in ())); + ACE_ASSERT (CORBA::is_nil (this->poa_.in ())); + + this->orb_ = CORBA::ORB::_duplicate(orb); + this->poa_ = PortableServer::POA::_duplicate (poa); + + ACE_ASSERT (!CORBA::is_nil (this->orb_.in ())); + ACE_ASSERT (!CORBA::is_nil (this->poa_.in ())); + + this->manipulator_.init (orb, poa ACE_ENV_ARG_PARAMETER); +// ACE_CHECK; +} + + +TAO::PG_Object_Group * TAO::PG_Group_Factory::create_group ( + const char * type_id, + const PortableGroup::Criteria & the_criteria, + TAO_PG::Properties_Decoder * typeid_properties + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableGroup::NoFactory, + PortableGroup::ObjectNotCreated, + PortableGroup::InvalidCriteria, + PortableGroup::InvalidProperty, + PortableGroup::CannotMeetCriteria)) +{ + /////////////////////////////////// + // Create an empty group reference + + PortableGroup::ObjectGroupId group_id = 0; + PortableGroup::ObjectGroup_var empty_group = + this->manipulator_.create_object_group ( + type_id, + this->domain_id_, + group_id + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + // pick up the object group information as assigned by + // ObjectGroupManager + + PortableGroup::TagGroupTaggedComponent tagged_component; + if (! TAO::PG_Utils::get_tagged_component (empty_group, tagged_component)) + { + delete empty_group; + ACE_THROW_RETURN (PortableGroup::ObjectNotCreated(), 0); + } + + TAO::PG_Object_Group * objectGroup = 0; + + ACE_NEW_THROW_EX ( + objectGroup, + TAO::PG_Object_Group ( + this->orb_.in (), +// this->poa_.in (), + this->manipulator_, + empty_group.in (), + tagged_component, + type_id, + the_criteria, + typeid_properties + ), + CORBA::NO_MEMORY()); + + if (this->group_map_.bind (group_id, objectGroup) != 0) + { + delete empty_group; + delete objectGroup; + ACE_THROW_RETURN (PortableGroup::ObjectNotCreated(), 0); + } + return objectGroup; +} + + +#if 0 +Initialize object group + + PortableGroup::ObjectGroup_var object_group = PortableGroup::ObjectGroup::_nil(); + + PortableGroup::Properties_var properties = + this->property_manager_.get_type_properties (type_id + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + + PortableGroup::MembershipStyleValue membership_style = + TAO_PG_MEMBERSHIP_STYLE; + PortableGroup::FactoriesValue factory_infos(0); + + PortableGroup::InitialNumberMembersValue initial_number_members = + TAO_PG_INITIAL_NUMBER_MEMBERS; + PortableGroup::MinimumNumberMembersValue minimum_number_members = + TAO_PG_MINIMUM_NUMBER_MEMBERS; + + // Make sure the criteria for the object group being created are + // valid. + this->process_criteria (type_id, + the_criteria, + membership_style, + factory_infos, + initial_number_members, + minimum_number_members + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + + + PortableGroup::ObjectGroupId group_id; +// PortableGroup::ObjectGroup_var + object_group = + this->object_group_manager_.create_object_group (type_id, // in + this->domain_id_, // in + the_criteria, // in + group_id // out + ACE_ENV_ARG_PARAMETER); + + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + + // Allocate a new FactoryCreationId for use as an "out" parameter. + PortableGroup::GenericFactory::FactoryCreationId_var factory_id = 0; + ACE_NEW_THROW_EX (factory_id, + PortableGroup::GenericFactory::FactoryCreationId, + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO_DEFAULT_MINOR_CODE, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + *factory_id <<= group_id; + + + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + + + TAO_PG_Factory_Set factory_set; + + const CORBA::ULong factory_infos_count = factory_infos.length (); + + ACE_TRY + { + if (factory_infos_count > 0 + && membership_style == PortableGroup::MEMB_INF_CTRL) + { + this->populate_object_group (object_group.in (), + type_id, + factory_infos, + minimum_number_members, + factory_set + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, + guard, + this->lock_, + CORBA::Object::_nil ()); + + + if (this->factory_map_.bind (group_id, factory_set) != 0) + ACE_TRY_THROW (PortableGroup::ObjectNotCreated ()); + } + } + ACE_CATCHANY + { + this->delete_object_i (factory_set, + 1 /* Ignore exceptions */ + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + this->object_group_manager_.destroy_object_group (group_id + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_RE_THROW; + } + ACE_ENDTRY; + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + + factory_creation_id = factory_id._retn(); + return result; +} +#endif + + +void TAO::PG_Group_Factory::delete_group (PortableGroup::ObjectGroup_ptr object_group + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableGroup::ObjectNotFound)) +{ + if (! destroy_group (object_group)) + { + ACE_THROW (PortableGroup::ObjectNotFound ()); + } +} + + +void TAO::PG_Group_Factory::delete_group (PortableGroup::ObjectGroupId group_id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableGroup::ObjectNotFound)) +{ + if (! destroy_group (group_id)) + { + ACE_THROW (PortableGroup::ObjectNotFound ()); + } +} + + + + +PortableGroup::GenericFactory::FactoryCreationId * +TAO::PG_Group_Factory::create_member ( + PortableGroup::ObjectGroup_ptr object_group, + const PortableGroup::FactoryInfo & factory_info, + const char * type_id, + const CORBA::Boolean propagate_member_already_present + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableGroup::NoFactory, + PortableGroup::ObjectNotCreated, + PortableGroup::InvalidCriteria, + PortableGroup::InvalidProperty, + PortableGroup::CannotMeetCriteria, + PortableGroup::MemberAlreadyPresent)) +{ + PortableGroup::GenericFactory::FactoryCreationId_var fcid; + +#if 0 + CORBA::Object_var member = + factory_info.the_factory->create_object (type_id, + factory_info.the_criteria, + fcid.out () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + ACE_TRY + { + // @@ Should an "_is_a()" be performed here? While it + // appears to be the right thing to do, it can be + // expensive. + // + // Make sure an Object of the correct type was created. + // It is possible that an object of the wrong type was + // created if the type_id parameter does not match the + // type of object the GenericFactory creates. + CORBA::Boolean right_type_id = + member->_is_a (type_id + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // @todo Strategize this -- e.g. strict type checking. + if (!right_type_id) + { + // An Object of incorrect type was created. Delete + // it, and throw a NoFactory exception. + factory_info.the_factory->delete_object (fcid.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_TRY_THROW (PortableGroup::NoFactory (factory_info.the_location, + type_id)); + } + + this->object_group_manager_._tao_add_member ( + object_group, + factory_info.the_location, + member.in (), + type_id, + propagate_member_already_present + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + // If the member reference is not nil, then the factory + // was successfully invoked. Since an exception was + // thrown, clean up the up created member. + if (!CORBA::is_nil (member.in ())) + { + factory_info.the_factory->delete_object (fcid.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + + ACE_RE_THROW; + } + ACE_ENDTRY; + ACE_CHECK_RETURN (0); +#endif + return fcid._retn (); +} + + // insert group. Take ownership +int TAO::PG_Group_Factory::insert_group ( ::TAO::PG_Object_Group * group) +{ + return insert_group (group->get_object_group_id(), group); +} + +int TAO::PG_Group_Factory::insert_group (PortableGroup::ObjectGroupId group_id, ::TAO::PG_Object_Group * group) +{ + return (this->group_map_.bind (group_id, group) == 0); +} + +int TAO::PG_Group_Factory::find_group (PortableGroup::ObjectGroupId group_id, ::TAO::PG_Object_Group *& group) const +{ + return (this->group_map_.find (group_id , group) == 0); +} + +int TAO::PG_Group_Factory::find_group (PortableGroup::ObjectGroup_ptr object_group, ::TAO::PG_Object_Group *& group) const +{ + int result = 0; + PortableGroup::TagGroupTaggedComponent tc; + if (TAO::PG_Utils::get_tagged_component (object_group, tc)) + { + result = find_group (tc.object_group_id, group); + } + return result; +} + +int TAO::PG_Group_Factory::destroy_group (PortableGroup::ObjectGroupId group_id) +{ + ::TAO::PG_Object_Group * group; + int result = (this->group_map_.unbind (group_id, group) == 0); + if (result) + { + delete group; + } + return result; +} + +int TAO::PG_Group_Factory::destroy_group (PortableGroup::ObjectGroup_ptr object_group) +{ + PortableGroup::TagGroupTaggedComponent tc; + TAO::PG_Utils::get_tagged_component (object_group, tc); + return destroy_group (tc.object_group_id); +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + + template class ACE_Hash_Map_Manager_Ex< + PortableGroup::ObjectGroupId, + ::TAO::PG_Object_Group *, + ACE_Hash<ACE_UINT64>, + ACE_Equal_To<ACE_UINT64>, + TAO_SYNCH_MUTEX>; + + template class ACE_Hash_Map_Entry < + PortableGroup::ObjectGroupId, + ::TAO::PG_Object_Group *>; + + template class ACE_Hash_Map_Iterator_Ex < + PortableGroup::ObjectGroupId, + ::TAO::PG_Object_Group *, + ACE_Hash<ACE_UINT64>, + ACE_Equal_To<ACE_UINT64>, + TAO_SYNCH_MUTEX>; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +# pragma instantiate ACE_Hash_Map_Manager_Ex< + PortableGroup::ObjectGroupId, + ::TAO::PG_Object_Group *, + ACE_Hash<ACE_UINT64>, + ACE_Equal_To<ACE_UINT64>, + TAO_SYNCH_MUTEX>; + +# pragma instantiate ACE_Hash_Map_Entry < + PortableGroup::ObjectGroupId, + ::TAO::PG_Object_Group *>; + +# pragma instantiate ACE_Hash_Map_Iterator_Ex < + PortableGroup::ObjectGroupId, + ::TAO::PG_Object_Group *, + ACE_Hash<ACE_UINT64>, + ACE_Equal_To<ACE_UINT64>, + TAO_SYNCH_MUTEX>; + +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.h new file mode 100644 index 00000000000..95b6672c0fb --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.h @@ -0,0 +1,181 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file PG_Group_Factory.h + * + * $Id$ + * + * @author Dale Wilson <wilson_d@ociweb.com> + */ +//============================================================================= + +#ifndef TAO_PG_GROUP_FACTORY_H +#define TAO_PG_GROUP_FACTORY_H + +#include /**/ <ace/pre.h> + +#include <ace/ACE.h> + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include <tao/PortableServer/PortableServerC.h> +#include <orbsvcs/PortableGroupC.h> +#include "PG_Object_Group_Manipulator.h" + +////////////////// +// Forward reference +namespace TAO_PG +{ + class Properties_Decoder; +} // namespace TAO_PG + + + +namespace TAO +{ + ///////////////////// + // forward references + class PG_Object_Group; + + /** + * class PG_Group_Factory + */ + class TAO_PortableGroup_Export PG_Group_Factory + { + //////////////////////////////////////////////////////////// + // typedef private implementation classes + typedef ACE_Hash_Map_Manager_Ex< + PortableGroup::ObjectGroupId, + ::TAO::PG_Object_Group *, + ACE_Hash<ACE_UINT64>, + ACE_Equal_To<ACE_UINT64>, + TAO_SYNCH_MUTEX> Group_Map; + + typedef ACE_Hash_Map_Entry <PortableGroup::ObjectGroupId, ::TAO::PG_Object_Group *> Group_Map_Entry; + + typedef ACE_Hash_Map_Iterator_Ex < + PortableGroup::ObjectGroupId, + ::TAO::PG_Object_Group *, + ACE_Hash<ACE_UINT64>, + ACE_Equal_To<ACE_UINT64>, + TAO_SYNCH_MUTEX> Group_Map_Iterator; + + public: + + /// Constructor. + PG_Group_Factory (); + + /// Destructor. + ~PG_Group_Factory (); + + void init (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa ACE_ENV_ARG_DECL); + + + TAO::PG_Object_Group * create_group ( + const char * type_id, + const PortableGroup::Criteria & the_criteria, + TAO_PG::Properties_Decoder * typeid_properties + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableGroup::NoFactory, + PortableGroup::ObjectNotCreated, + PortableGroup::InvalidCriteria, + PortableGroup::InvalidProperty, + PortableGroup::CannotMeetCriteria)); + + + void delete_group (PortableGroup::ObjectGroup_ptr object_group + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableGroup::ObjectNotFound)); + + + void delete_group (PortableGroup::ObjectGroupId group_id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableGroup::ObjectNotFound)); + + /** + * Create a new object group member using the supplied FactoryInfo + * and RepositoryId and add it to the given object group. + * @note This method is only used by the infrastructure. + */ + PortableGroup::GenericFactory::FactoryCreationId * create_member ( + PortableGroup::ObjectGroup_ptr object_group, + const PortableGroup::FactoryInfo & factory_info, + const char * type_id, + const CORBA::Boolean propagate_member_already_present + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableGroup::NoFactory, + PortableGroup::ObjectNotCreated, + PortableGroup::InvalidCriteria, + PortableGroup::InvalidProperty, + PortableGroup::CannotMeetCriteria, + PortableGroup::MemberAlreadyPresent)); + + + /** + * insert existing group. Take ownership + * note: uses group id extracted from group object + * @return bool true if insertion successful + */ + int insert_group ( ::TAO::PG_Object_Group * group); + + /** + * insert group. Take ownership + * @return bool true if insertion successful + */ + int insert_group (PortableGroup::ObjectGroupId group_id, ::TAO::PG_Object_Group * group); + + /** + * find group + * @return bool true if found + */ + int find_group (PortableGroup::ObjectGroupId group_id, ::TAO::PG_Object_Group *& group) const; + + /** + * find group + * note: uses group id extracted from object_group + * @return bool true if found + */ + int find_group (PortableGroup::ObjectGroup_ptr object_group, ::TAO::PG_Object_Group *& group) const; + + /** + * remove group from map and delete it. + * @return bool true if found + */ + int destroy_group (PortableGroup::ObjectGroupId object_group_id); + + /** + * remove group from map and delete it. + * note: uses group id extracted from object_group + * @return bool true if found + */ + int destroy_group (PortableGroup::ObjectGroup_ptr object_group); + + private: + + private: + + CORBA::ORB_var orb_; + + /// Reference to the POA used to create object group references. + PortableServer::POA_var poa_; + + ::TAO::PG_Object_Group_Manipulator manipulator_; + + const char * domain_id_; + + Group_Map group_map_; + + + }; +} // namespace TAO + +#include /**/ "ace/post.h" + +#endif /* TAO_PG_GROUP_FACTORY_H */ diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp index d12a83c3c95..bab30deaa82 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp @@ -629,19 +629,22 @@ TAO_PG_ObjectGroupManager::member_count ( } int -TAO_PG_ObjectGroupManager::init (CORBA::ORB_ptr orb, PortableServer::POA_ptr p) +TAO_PG_ObjectGroupManager::init (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa) { int result = 0; - ACE_ASSERT (CORBA::is_nil (this->orb_.in ()) && !CORBA::is_nil (orb)); + ACE_ASSERT (CORBA::is_nil (this->orb_.in ())); + ACE_ASSERT (CORBA::is_nil (this->poa_.in ())); this->orb_ = CORBA::ORB::_duplicate (orb); + this->poa_ = PortableServer::POA::_duplicate (poa); - ACE_ASSERT (CORBA::is_nil (this->poa_.in ()) && !CORBA::is_nil (p)); - this->poa_ = PortableServer::POA::_duplicate (p); + ACE_ASSERT (! CORBA::is_nil (this->orb_.in ())); + ACE_ASSERT (! CORBA::is_nil (this->poa_.in ())); - result = manipulator_.init (orb, p); + manipulator_.init (orb, poa ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); - return result; + return 0; } diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp index 4a1e40e664d..f8a3e2edd14 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp @@ -50,14 +50,15 @@ TAO::PG_Object_Group::MemberInfo::~MemberInfo () } } + TAO::PG_Object_Group::PG_Object_Group ( - CORBA::ORB_ptr orb, - TAO::PG_Object_Group_Manipulator * manipulator, - CORBA::Object_ptr empty_group, - const PortableGroup::TagGroupTaggedComponent & tagged_component, - const char * type_id, - const PortableGroup::Criteria & the_criteria, - TAO_PG::Properties_Decoder * type_properties) + CORBA::ORB_ptr orb, + TAO::PG_Object_Group_Manipulator & manipulator, + CORBA::Object_ptr empty_group, + const PortableGroup::TagGroupTaggedComponent & tagged_component, + const char * type_id, + const PortableGroup::Criteria & the_criteria, + TAO_PG::Properties_Decoder * type_properties) : internals_() , orb_ (CORBA::ORB::_duplicate (orb)) , manipulator_ (manipulator) @@ -75,6 +76,7 @@ TAO::PG_Object_Group::PG_Object_Group ( { } +#if 0 //static TAO::PG_Object_Group * TAO::PG_Object_Group::create ( CORBA::ORB_ptr orb, @@ -128,12 +130,10 @@ TAO::PG_Object_Group * TAO::PG_Object_Group::create ( CORBA::NO_MEMORY()); return objectGroup; } - +#endif TAO::PG_Object_Group::~PG_Object_Group () { - delete manipulator_; - manipulator_ = 0; for (MemberMap_Iterator it = this->members_.begin(); it != this->members_.end(); this->members_.begin()) @@ -270,7 +270,7 @@ void TAO::PG_Object_Group::add_member ( { // remove the original profile. It's a dummy entry supplied by create_object. cleaned = - this->manipulator_->remove_profiles (cleaned.in (), this->reference_.in () ACE_ENV_ARG_PARAMETER); + this->manipulator_.remove_profiles (cleaned.in (), this->reference_.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK; this->empty_ = 0; } @@ -283,7 +283,7 @@ void TAO::PG_Object_Group::add_member ( // Now merge the list into one new IOGR PortableGroup::ObjectGroup_var new_reference = - this->manipulator_->merge_iors (iors ACE_ENV_ARG_PARAMETER); + this->manipulator_.merge_iors (iors ACE_ENV_ARG_PARAMETER); ACE_CHECK; CORBA::Object_var member_ior = this->orb_->string_to_object (member_ior_string ACE_ENV_ARG_PARAMETER); @@ -342,7 +342,7 @@ int TAO::PG_Object_Group::set_primary_member ( } info->is_primary_ = 1; - int set_ok = this->manipulator_->set_primary (prop, this->reference_.in (), info->member_.in () ACE_ENV_ARG_PARAMETER); + int set_ok = this->manipulator_.set_primary (prop, this->reference_.in (), info->member_.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (0); if (! set_ok) { @@ -400,7 +400,7 @@ void TAO::PG_Object_Group::remove_member ( if (this->members_.current_size() > 0) { this->reference_ = - this->manipulator_->remove_profiles (this->reference_.in (), info->member_.in () ACE_ENV_ARG_PARAMETER); + this->manipulator_.remove_profiles (this->reference_.in (), info->member_.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK; } else diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h index 4cbba398ede..9442b30e432 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h @@ -111,23 +111,18 @@ namespace TAO TAO_PG_Location_Equal_To, MemberMapMutex> MemberMap_Iterator; - /** - * Private constructor -- use static create method. - * NOTE: gcc complains about private constructor so - * make it protected. Now it really should complain - * about non-virtual destructor, but it's not that smart. - */ - protected: + ///////////////////// + // Construct/Destruct + public: PG_Object_Group ( CORBA::ORB_ptr orb, - TAO::PG_Object_Group_Manipulator * manipulator, + TAO::PG_Object_Group_Manipulator & manipulator, CORBA::Object_ptr empty_group, - const PortableGroup::TagGroupTaggedComponent & tag_component, + const PortableGroup::TagGroupTaggedComponent & tagged_component, const char * type_id, const PortableGroup::Criteria & the_criteria, TAO_PG::Properties_Decoder * type_properties); - public: /// Destructor ~PG_Object_Group (); @@ -239,6 +234,7 @@ namespace TAO ///////////////// // Static Methods public: +#if 0 /** * Static creation method needed because exceptions can happen. */ @@ -250,7 +246,7 @@ namespace TAO const PortableGroup::Criteria & the_criteria, TAO_PG::Properties_Decoder * type_properties ACE_ENV_ARG_DECL); - +#endif /////////////// // Static Data private: @@ -268,7 +264,7 @@ namespace TAO CORBA::ORB_var orb_; // The object group manipulator - TAO::PG_Object_Group_Manipulator * manipulator_; + TAO::PG_Object_Group_Manipulator & manipulator_; /// boolean true if empty group int empty_; diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Manipulator.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Manipulator.cpp index 631c7a8ba0a..6c86aaec4f8 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Manipulator.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Manipulator.cpp @@ -88,7 +88,7 @@ TAO::PG_Object_Group_Manipulator::create_object_group ( return object_group._retn (); } -int +void TAO::PG_Object_Group_Manipulator::init (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa ACE_ENV_ARG_DECL) { ACE_ASSERT (CORBA::is_nil (this->orb_.in ()) && !CORBA::is_nil (orb)); @@ -100,13 +100,11 @@ TAO::PG_Object_Group_Manipulator::init (CORBA::ORB_ptr orb, PortableServer::POA_ // Get an object reference for the ORBs IORManipulation object! CORBA::Object_var IORM = this->orb_->resolve_initial_references ( TAO_OBJID_IORMANIPULATION, 0 ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN(-1); + ACE_CHECK; this->iorm_ = TAO_IOP::TAO_IOR_Manipulation::_narrow ( IORM.in () ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN(-1); - - return 0; +// ACE_CHECK; } int TAO::PG_Object_Group_Manipulator::set_primary ( diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Manipulator.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Manipulator.h index 020b17d194e..e4a18ce8c72 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Manipulator.h +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Manipulator.h @@ -11,8 +11,8 @@ //============================================================================= -#ifndef TAO_PG_OBJECT_GROUP_CREATOR_H -#define TAO_PG_OBJECT_GROUP_CREATOR_H +#ifndef TAO_PG_OBJECT_GROUP_MANIPULATOR_H +#define TAO_PG_OBJECT_GROUP_MANIPULATOR_H #include /**/ "ace/pre.h" #include "orbsvcs/PortableGroupS.h" @@ -47,7 +47,7 @@ namespace TAO /** * Initializes the group creator. */ - int init (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa ACE_ENV_ARG_DECL); + void init (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa ACE_ENV_ARG_DECL); /** * Create an empty object group. diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.cpp deleted file mode 100644 index ae80e54c94f..00000000000 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.cpp +++ /dev/null @@ -1,120 +0,0 @@ -// -*- C++ -*- -// -//============================================================================= -/** - * @file PG_Object_Group_Map.cpp - * - * $Id$ - * - * Container for TAO::PG_Object_Groups indexed by ObjectGroupId - * Note this was developed as part of FT CORBA - * @@ For now its but one of several parallel containers for object group information - * @@ TODO: Combine these parallel containers into a single one that consolidates everything - * @@ known about object groups. - * @author Dale Wilson <wilson_d@ociweb.com> - */ -//============================================================================= - -#include "PG_Object_Group_Map.h" -#include "PG_Object_Group.h" -#include <orbsvcs/orbsvcs/PortableGroup/PG_Utils.h> - -TAO::PG_Object_Group_Map::PG_Object_Group_Map () -{ -} - -TAO::PG_Object_Group_Map::~PG_Object_Group_Map () -{ - // todo: destroy all members -} - -////////////////////////////////////////////////////// -// PG_Object_Group_Map public methods - - - // insert group. Take ownership -int TAO::PG_Object_Group_Map::insert_group ( ::TAO::PG_Object_Group * group) -{ - return insert_group (group->get_object_group_id(), group); -} - -int TAO::PG_Object_Group_Map::insert_group (PortableGroup::ObjectGroupId group_id, ::TAO::PG_Object_Group * group) -{ - return (this->bind (group_id, group) == 0); -} - -int TAO::PG_Object_Group_Map::find_group (PortableGroup::ObjectGroupId group_id, ::TAO::PG_Object_Group *& group) const -{ - return (this->find (group_id , group) == 0); -} - -int TAO::PG_Object_Group_Map::find_group (PortableGroup::ObjectGroup_ptr object_group, ::TAO::PG_Object_Group *& group) const -{ - int result = 0; - PortableGroup::TagGroupTaggedComponent tc; - if (TAO::PG_Utils::get_tagged_component (object_group, tc)) - { - result = find_group (tc.object_group_id, group); - } - return result; -} - -int TAO::PG_Object_Group_Map::destroy_group (PortableGroup::ObjectGroupId group_id) -{ - ::TAO::PG_Object_Group * group; - int result = (this->unbind (group_id, group) == 0); - if (result) - { - delete group; - } - return result; -} - -int TAO::PG_Object_Group_Map::destroy_group (PortableGroup::ObjectGroup_ptr object_group) -{ - PortableGroup::TagGroupTaggedComponent tc; - TAO::PG_Utils::get_tagged_component (object_group, tc); - return destroy_group (tc.object_group_id); -} - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - - template class ACE_Hash_Map_Manager_Ex< - PortableGroup::ObjectGroupId, - ::TAO::PG_Object_Group *, - ACE_Hash<ACE_UINT64>, - ACE_Equal_To<ACE_UINT64>, - TAO_SYNCH_MUTEX>; - - template class ACE_Hash_Map_Entry < - PortableGroup::ObjectGroupId, - ::TAO::PG_Object_Group *>; - - template class ACE_Hash_Map_Iterator_Ex < - PortableGroup::ObjectGroupId, - ::TAO::PG_Object_Group *, - ACE_Hash<ACE_UINT64>, - ACE_Equal_To<ACE_UINT64>, - TAO_SYNCH_MUTEX>; - -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) - -# pragma instantiate ACE_Hash_Map_Manager_Ex< - PortableGroup::ObjectGroupId, - ::TAO::PG_Object_Group *, - ACE_Hash<ACE_UINT64>, - ACE_Equal_To<ACE_UINT64>, - TAO_SYNCH_MUTEX>; - -# pragma instantiate ACE_Hash_Map_Entry < - PortableGroup::ObjectGroupId, - ::TAO::PG_Object_Group *>; - -# pragma instantiate ACE_Hash_Map_Iterator_Ex < - PortableGroup::ObjectGroupId, - ::TAO::PG_Object_Group *, - ACE_Hash<ACE_UINT64>, - ACE_Equal_To<ACE_UINT64>, - TAO_SYNCH_MUTEX>; - -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.h deleted file mode 100644 index 53043af9fab..00000000000 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.h +++ /dev/null @@ -1,110 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file PG_Object_Group_Map.h - * - * $Id$ - * - * Container for TAO::PG_Object_Groups indexed by ObjectGroupId - * Note this was developed as part of FT CORBA - * @@ For now its but one of several parallel containers for object group information - * @@ TODO: Combine these parallel containers into a single one that consolidates everything - * @@ known about object groups. - * @author Dale Wilson <wilson_d@ociweb.com> - */ -//============================================================================= - - -#ifndef TAO_PG_OBJECT_GROUP_MAP_H -#define TAO_PG_OBJECT_GROUP_MAP_H - -#include /**/ "ace/pre.h" -#include "orbsvcs/PortableGroupS.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -//////////////////////////////////////////////////// -// Forward reference to class(es) defined in this header -namespace TAO -{ - class PG_Object_Group_Map; -} // namespace TAO - -//#include "PG_Object_Group.h" -namespace TAO -{ - class PG_Object_Group; -} // namespace TAO - -namespace TAO -{ - /** - * class TAO::PG_Object_Group_Map - * A container of Object_Groups indexed by ObjectGroupId - */ - class TAO_PortableGroup_Export PG_Object_Group_Map - : public ACE_Hash_Map_Manager_Ex< - PortableGroup::ObjectGroupId, - ::TAO::PG_Object_Group *, - ACE_Hash<ACE_UINT64>, - ACE_Equal_To<ACE_UINT64>, - TAO_SYNCH_MUTEX> - { - public: - typedef ACE_Hash_Map_Entry <PortableGroup::ObjectGroupId, ::TAO::PG_Object_Group *> Entry; - typedef ACE_Hash_Map_Iterator_Ex < - PortableGroup::ObjectGroupId, - ::TAO::PG_Object_Group *, - ACE_Hash<ACE_UINT64>, - ACE_Equal_To<ACE_UINT64>, - TAO_SYNCH_MUTEX> Iterator; - - /// Constructor. - PG_Object_Group_Map (); - - /// Destructor. - virtual ~PG_Object_Group_Map (); - - /// insert existing group. Take ownership - /// note: uses group id extracted from group object - /// @return bool true if insertion successful - int insert_group ( ::TAO::PG_Object_Group * group); - - /// insert group. Take ownership - /// @return bool true if insertion successful - int insert_group (PortableGroup::ObjectGroupId group_id, ::TAO::PG_Object_Group * group); - - /// find group - /// @return bool true if found - int find_group (PortableGroup::ObjectGroupId group_id, ::TAO::PG_Object_Group *& group) const; - - /// find group - /// note: uses group id extracted from object_group - /// @return bool true if found - int find_group (PortableGroup::ObjectGroup_ptr object_group, ::TAO::PG_Object_Group *& group) const; - - /// remove group from map and delete it. - /// @return bool true if found - int destroy_group (PortableGroup::ObjectGroupId object_group_id); - - /// remove group from map and delete it. - /// note: uses group id extracted from object_group - /// @return bool true if found - int destroy_group (PortableGroup::ObjectGroup_ptr object_group); - - //////////////////////////// - // Implementation methods - private: - - /////// - // Data - private: - }; -} // namespace TAO - -#include /**/ "ace/post.h" - -#endif /* TAO_PG_OBJECT_GROUP_MAP_H */ |