summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwilson_d <wilson_d@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-11-28 23:08:40 +0000
committerwilson_d <wilson_d@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-11-28 23:08:40 +0000
commit426e60f7d49485129a95476ac4738c39c50d94bb (patch)
tree4c337bef2e9870ac5bb9df2ea1e12de66994df9f
parentceb2d2821895344a81faedd2a094b8f92866c681 (diff)
downloadATCD-426e60f7d49485129a95476ac4738c39c50d94bb.tar.gz
ChangeLogTag: Fri Nov 28 16:52:43 2003 Dale Wilson <wilson_d@ociweb.com>
-rw-r--r--TAO/ChangeLog26
-rw-r--r--TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp6
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp75
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.h14
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp95
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h47
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Manipulator.cpp189
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Manipulator.h113
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Support.cpp2
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Support.h2
-rw-r--r--TAO/tao/IORManipulation/IORManipulation.cpp53
-rw-r--r--TAO/tao/IORManipulation/IORManipulation.h15
12 files changed, 424 insertions, 213 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index f56b0bef5f0..7e466ab0678 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,29 @@
+Fri Nov 28 16:52:43 2003 Dale Wilson <wilson_d@ociweb.com>
+
+ * tao/IORManipulation/IORManipulation.h:
+ * tao/IORManipulation/IORManipulation.cpp:
+ Use meaningful argument names to reduce confusion.
+ Add comment warning about inconsistent argument order.
+
+ * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Manipulator.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Manipulator.cpp:
+ New files factor out IOGR creation and manipulation
+ from PG_Object_Group and PG_ObjectGroupManager
+
+ * orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp:
+ IOGR stuff factored out.
+
+ * orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp:
+
+
+ * orbsvcs/orbsvcs/PortableGroup/PG_Properties_Support.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Properties_Support.cpp:
+ Fuzz from last checkin.
+
+
Fri Nov 28 11:36:06 2003 Dale Wilson <wilson_d@ociweb.com>
* orbsvcs/tests/FT_App/demo.pl:
diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp
index 980460362a3..3dc03c87b82 100644
--- a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp
+++ b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp
@@ -711,6 +711,7 @@ TAO::FT_ReplicationManager::set_primary_member (
, FT::BadReplicationStyle
))
{
+ 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))
@@ -734,7 +735,7 @@ TAO::FT_ReplicationManager::set_primary_member (
{
ACE_THROW_RETURN (PortableGroup::ObjectGroupNotFound (), PortableGroup::ObjectGroup::_nil ());
}
- return result._retn ();
+ METHOD_RETURN (TAO::FT_ReplicationManager::set_primary_member) result._retn ();
}
PortableGroup::ObjectGroup_ptr
@@ -963,7 +964,7 @@ TAO::FT_ReplicationManager::create_object (
// entry in our object group map
// first find the properties for this type of object group
- TAO_PG::Properties_Decoder * typeid_properties
+ TAO_PG::Properties_Decoder * typeid_properties
= this->properties_support_.find_typeid_properties (
type_id
ACE_ENV_ARG_PARAMETER);
@@ -972,6 +973,7 @@ TAO::FT_ReplicationManager::create_object (
TAO::PG_Object_Group * objectGroup
= TAO::PG_Object_Group::create (
this->orb_.in (),
+ this->poa_.in (),
obj.in (),
type_id,
the_criteria,
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp
index 9255610bcb7..cefa02aecd5 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp
@@ -19,9 +19,9 @@ TAO_PG_ObjectGroupManager::TAO_PG_ObjectGroupManager (void)
object_group_map_ (TAO_PG_MAX_OBJECT_GROUPS),
location_map_ (TAO_PG_MAX_LOCATIONS),
generic_factory_ (0),
- lock_ (),
- lock_ogid_ (),
- next_ogid_ (1) // don't use ogid 0
+ lock_ ()
+// , lock_ogid_ (),
+// next_ogid_ (1) // don't use ogid 0
{
}
@@ -505,32 +505,6 @@ TAO_PG_ObjectGroupManager::get_object_group_ref_from_id (
PortableGroup::ObjectGroup::_duplicate (group_entry->object_group.in ());
}
-
-
-void TAO_PG_ObjectGroupManager::allocate_ogid (PortableGroup::ObjectGroupId & ogid)
-{
- ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->lock_ogid_);
- //@@ NOTE: as always, ACE_GUARD_XXXX does the wrong thing if the lock fails
-
- // The numerical value used for the ObjectId increases
- // monotonically.
-
- ogid = this->next_ogid_;
- this->next_ogid_ += 1;
-}
-
-PortableServer::ObjectId * TAO_PG_ObjectGroupManager::convert_ogid_to_oid (PortableGroup::ObjectGroupId ogid)
-{
- // 4294967295 -- Largest 32 bit unsigned integer
- char oid_str[11];
- ACE_OS::snprintf (oid_str, sizeof(oid_str),
- "%lu",
- ACE_static_cast (ACE_UINT32,ogid));
- oid_str[sizeof(oid_str) - 1] = '\0';
-
- return PortableServer::string_to_ObjectId (oid_str);
-}
-
PortableGroup::ObjectGroup_ptr
TAO_PG_ObjectGroupManager::create_object_group (
const char * type_id,
@@ -539,29 +513,13 @@ TAO_PG_ObjectGroupManager::create_object_group (
PortableGroup::ObjectGroupId & group_id
ACE_ENV_ARG_DECL)
{
- allocate_ogid(group_id);
- PortableServer::ObjectId_var oid = convert_ogid_to_oid (group_id);
-
- // Create a reference for the ObjectGroup corresponding to the
- // RepositoryId of the object being created.
- CORBA::Object_var object_group =
- this->poa_->create_reference_with_id (group_id,
- type_id
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (CORBA::Object::_nil ());
-
- PortableGroup::TagGroupTaggedComponent tag_component;
-
- tag_component.component_version.major = (CORBA::Octet) 1;
- tag_component.component_version.minor = (CORBA::Octet) 0;
- tag_component.group_domain_id = domain_id;
- tag_component.object_group_id = group_id;
- tag_component.object_group_ref_version = 0;
-
- // Set the property
- TAO::PG_Utils::set_tagged_component (object_group,
- tag_component);
- ACE_CHECK_RETURN (CORBA::Object::_nil ());
+ CORBA::Object_var object_group = manipulator_.create_object_group (
+ type_id,
+ domain_id,
+ the_criteria,
+ group_id
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (PortableGroup::ObjectGroup::_nil());
TAO_PG_ObjectGroup_Map_Entry * group_entry = 0;
ACE_NEW_THROW_EX (group_entry,
@@ -674,22 +632,15 @@ TAO_PG_ObjectGroupManager::member_count (
int
TAO_PG_ObjectGroupManager::init (CORBA::ORB_ptr orb, PortableServer::POA_ptr p)
{
+ int result = 0;
+
ACE_ASSERT (CORBA::is_nil (this->orb_.in ()) && !CORBA::is_nil (orb));
this->orb_ = CORBA::ORB::_duplicate (orb);
ACE_ASSERT (CORBA::is_nil (this->poa_.in ()) && !CORBA::is_nil (p));
this->poa_ = PortableServer::POA::_duplicate (p);
- int result = 0;
-
- // 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_TRY_CHECK;
-
- this->iorm_ = TAO_IOP::TAO_IOR_Manipulation::_narrow (
- IORM.in () ACE_ENV_ARG_PARAMETER);
- ACE_TRY_CHECK;
+ result = manipulator_.init (orb, p);
return result;
}
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.h
index 64f1500b8ba..5be2b00d523 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.h
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.h
@@ -24,11 +24,10 @@
#include "PG_ObjectGroup_Map.h"
#include "PG_Location_Map.h"
-
+#include "PG_Object_Group_Manipulator.h"
#include "tao/PortableServer/Key_Adapters.h"
#include "tao/PortableServer/PortableServerC.h"
-#include "tao/IORManipulation/IORManip_Loader.h"
/// Forward declarations
class TAO_PG_GenericFactory;
@@ -302,8 +301,8 @@ private:
/// Reference to the POA that created the object group references.
PortableServer::POA_var poa_;
- /// The ORBs IORManipulation object
- TAO_IOP::TAO_IOR_Manipulation_var iorm_;
+ /// The ObjectGroup Manipulation object
+ TAO::PG_Object_Group_Manipulator manipulator_;
/// The underlying table that contains all object group
/// information.
@@ -320,15 +319,8 @@ private:
/// Lock used to synchronize access to the underlying tables.
TAO_SYNCH_MUTEX lock_;
- /// Lock used to synchronize access to next_ogid_.
- TAO_SYNCH_MUTEX lock_ogid_;
-
- /// Next ogid to be allocated.
- PortableGroup::ObjectGroupId next_ogid_;
-
};
-
#include /**/ "ace/post.h"
#endif /* TAO_PG_OBJECT_GROUP_MANAGER_H */
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp
index 6997a38d145..4a1e40e664d 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp
@@ -10,13 +10,6 @@
#include <orbsvcs/PortableGroup/PG_Operators.h> // Borrow operator == on CosNaming::Name
#include <orbsvcs/PortableGroup/PG_Utils.h>
-/**
- * The single POA used to manage object groups
- */
-//static
-PortableServer::POA_var TAO::PG_Object_Group::poa_;
-
-
TAO::PG_Object_Group::MemberInfo::MemberInfo (
CORBA::Object_ptr member,
const PortableGroup::Location & location)
@@ -59,7 +52,7 @@ TAO::PG_Object_Group::MemberInfo::~MemberInfo ()
TAO::PG_Object_Group::PG_Object_Group (
CORBA::ORB_ptr orb,
- TAO_IOP::TAO_IOR_Manipulation_ptr iorm,
+ TAO::PG_Object_Group_Manipulator * manipulator,
CORBA::Object_ptr empty_group,
const PortableGroup::TagGroupTaggedComponent & tagged_component,
const char * type_id,
@@ -67,7 +60,7 @@ TAO::PG_Object_Group::PG_Object_Group (
TAO_PG::Properties_Decoder * type_properties)
: internals_()
, orb_ (CORBA::ORB::_duplicate (orb))
- , iorm_ (TAO_IOP::TAO_IOR_Manipulation::_duplicate(iorm))
+ , manipulator_ (manipulator)
, empty_ (1)
, role_ (type_id)
, tagged_component_ (tagged_component)
@@ -85,23 +78,20 @@ TAO::PG_Object_Group::PG_Object_Group (
//static
TAO::PG_Object_Group * TAO::PG_Object_Group::create (
CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
CORBA::Object_ptr empty_group, // empty group as created by ObjectManager
const char * type_id,
const PortableGroup::Criteria & the_criteria,
TAO_PG::Properties_Decoder * type_properties
ACE_ENV_ARG_DECL)
{
- //@@ Might be worthwhile making iorm_ static
- // rather than resolving it for each new group.
- TAO_IOP::TAO_IOR_Manipulation_var iorm;
- // Get an object reference for the ORB's IORManipulation object.
- CORBA::Object_var iorm_obj = orb->resolve_initial_references (
- TAO_OBJID_IORMANIPULATION ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (0);
- iorm = TAO_IOP::TAO_IOR_Manipulation::_narrow (
- iorm_obj.in () ACE_ENV_ARG_PARAMETER);
+ TAO::PG_Object_Group_Manipulator * manipulator = 0;
+ ACE_NEW_THROW_EX (manipulator,
+ TAO::PG_Object_Group_Manipulator (),
+ CORBA::NO_MEMORY ());
+ int init_ok = manipulator->init (orb, poa ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (0);
- if (CORBA::is_nil (iorm.in ()))
+ if(init_ok)
{
if (TAO_debug_level > 3)
{
@@ -128,7 +118,7 @@ TAO::PG_Object_Group * TAO::PG_Object_Group::create (
objectGroup,
TAO::PG_Object_Group (
orb,
- iorm.in(),
+ manipulator,
empty_group,
tagged_component,
type_id,
@@ -142,6 +132,8 @@ TAO::PG_Object_Group * TAO::PG_Object_Group::create (
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())
@@ -152,6 +144,8 @@ TAO::PG_Object_Group::~PG_Object_Group ()
}
}
+
+
#if 0 // may want this again someday
/////////////////////
// q&d debug function
@@ -276,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->iorm_->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;
}
@@ -289,7 +283,7 @@ void TAO::PG_Object_Group::add_member (
// Now merge the list into one new IOGR
PortableGroup::ObjectGroup_var new_reference =
- this->iorm_->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);
@@ -348,18 +342,9 @@ int TAO::PG_Object_Group::set_primary_member (
}
info->is_primary_ = 1;
- //remove primary
- int sts = this->iorm_->is_primary_set (prop, this->reference_.in () ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (0);
- if (sts)
- {
- (void)this->iorm_->remove_primary_tag (prop, this->reference_.in () ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (0);
- }
-
- sts = this->iorm_->set_primary (prop, info->member_.in (), this->reference_.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 (! sts)
+ if (! set_ok)
{
if (TAO_debug_level > 3)
{
@@ -415,7 +400,7 @@ void TAO::PG_Object_Group::remove_member (
if (this->members_.current_size() > 0)
{
this->reference_ =
- this->iorm_->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
@@ -571,48 +556,6 @@ void TAO::PG_Object_Group::distribute_iogr (ACE_ENV_ARG_DECL)
}
}
-#if 0 // debug code
-void TAO::PG_Object_Group::dump_membership (TAO_IOP::TAO_IOR_Manipulation_ptr iorm, const char * label, PortableGroup::ObjectGroup_ptr member) const
-{
- FT::TagFTGroupTaggedComponent ft_tag_component;
- TAO_FT_IOGR_Property prop (ft_tag_component);
- if (iorm->is_primary_set (&prop, member))
- {
- ACE_DEBUG ( (LM_DEBUG,
- ACE_TEXT ("%T %n (%P|%t) - %s: PRIMARY member.\n"),
- label
- ));
- }
- else
- {
- ACE_DEBUG ( (LM_DEBUG,
- ACE_TEXT ("%T %n (%P|%t) - %s: backup member.\n"),
- label
- ));
- }
-
- PortableGroup::TagGroupTaggedComponent tag_component;
- if (TAO::PG_Utils::get_tagged_component (member, tag_component))
- {
- ACE_DEBUG ( (LM_DEBUG,
- ACE_TEXT ("%T %n (%P|%t) - %s: Group: .")
- ACE_TEXT (" version: %u\n"),
-
- label,
- tag_component.object_group_ref_version
- ));
- }
- else
- {
- ACE_DEBUG ( (LM_DEBUG,
- ACE_TEXT ("%T %n (%P|%t) - %s: No group information found.\n"),
- label
- ));
- }
-}
-#endif // debug code
-
-
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class ACE_Hash_Map_Manager_Ex <
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h
index 84d6cadf72b..a793b214190 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h
@@ -40,11 +40,18 @@ namespace TAO
#include <ace/Hash_Map_Manager_T.h>
#include "PG_Location_Hash.h"
#include "PG_Location_Equal_To.h"
-#include <tao/IORManipulation/IORC.h>
+#include "PG_Object_Group_Manipulator.h"
/////////////////////
// Forward references
+namespace TAO_IOP
+{
+ class TAO_IOR_Property;
+}
+
+////////////////
+// Class declarations
namespace TAO
{
/**
@@ -110,7 +117,7 @@ namespace TAO
private:
PG_Object_Group (
CORBA::ORB_ptr orb,
- TAO_IOP::TAO_IOR_Manipulation_ptr iorm,
+ TAO::PG_Object_Group_Manipulator * manipulator,
CORBA::Object_ptr empty_group,
const PortableGroup::TagGroupTaggedComponent & tag_component,
const char * type_id,
@@ -118,16 +125,6 @@ namespace TAO
TAO_PG::Properties_Decoder * type_properties);
public:
- /**
- * Static creation method needed because exceptions can happen.
- */
- static PG_Object_Group * create (
- CORBA::ORB_ptr orb,
- CORBA::Object_ptr empty_group, // empty group as created by ObjectManager
- const char * type_id,
- const PortableGroup::Criteria & the_criteria,
- TAO_PG::Properties_Decoder * type_properties
- ACE_ENV_ARG_DECL);
/// Destructor
~PG_Object_Group ();
@@ -198,8 +195,6 @@ namespace TAO
ACE_THROW_SPEC ( (CORBA::SystemException,
PortableGroup::ObjectNotAdded));
-
-
/**
* set the replica at the given location to be primary.
* Note: This should return void and throw FT::PrimaryNotSet
@@ -230,7 +225,6 @@ namespace TAO
int increment_version ();
void distribute_iogr (ACE_ENV_ARG_DECL);
-
/////////////////////////
// Forbidden methods
private:
@@ -243,20 +237,20 @@ namespace TAO
// Static Methods
public:
/**
- * Set the poa to be used to manage object groups
- * Note: this is NOT the poa used to create object group members.
- * @param poa the poa to use
+ * Static creation method needed because exceptions can happen.
*/
- static void set_poa (PortableServer::POA_ptr poa);
+ static PG_Object_Group * create (
+ CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ CORBA::Object_ptr empty_group, // empty group as created by ObjectManager
+ const char * type_id,
+ const PortableGroup::Criteria & the_criteria,
+ TAO_PG::Properties_Decoder * type_properties
+ ACE_ENV_ARG_DECL);
///////////////
// Static Data
private:
- /**
- * The POA used to manage object groups
- */
- static PortableServer::POA_var poa_;
-
///////////////
// Data Members
@@ -270,8 +264,8 @@ namespace TAO
CORBA::ORB_var orb_;
- // The ORB's IORManipulation object
- TAO_IOP::TAO_IOR_Manipulation_var iorm_;
+ // The object group manipulator
+ TAO::PG_Object_Group_Manipulator * manipulator_;
/// boolean true if empty group
int empty_;
@@ -294,7 +288,6 @@ namespace TAO
*/
PortableGroup::ObjectGroup_var reference_;
-
/**
* The CORBA object id assigned to this object group
*/
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Manipulator.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Manipulator.cpp
new file mode 100644
index 00000000000..e59d4817983
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Manipulator.cpp
@@ -0,0 +1,189 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file PG_Object_Group_Manipulator.cpp
+ *
+ * $Id$
+ *
+ * @author Dale Wilson <wilson_d@ociweb.com>
+ */
+//=============================================================================
+
+#include "PG_Object_Group_Manipulator.h"
+#include "PG_Utils.h"
+
+#include "tao/debug.h"
+
+ACE_RCSID (PortableGroup,
+ PG_Object_Group_Manipulator,
+ "$Id$")
+
+TAO::PG_Object_Group_Manipulator::PG_Object_Group_Manipulator ()
+ : orb_ (CORBA::ORB::_nil ())
+ , poa_ (PortableServer::POA::_nil ())
+ , iorm_ ()
+ , lock_ogid_ ()
+ , next_ogid_ (1) // don't use ogid 0
+{
+}
+
+TAO::PG_Object_Group_Manipulator::~PG_Object_Group_Manipulator ()
+{
+}
+
+void TAO::PG_Object_Group_Manipulator::allocate_ogid (PortableGroup::ObjectGroupId & ogid)
+{
+ ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->lock_ogid_);
+
+ // The numerical value used for the ObjectId increases
+ // monotonically.
+
+ ogid = this->next_ogid_;
+ this->next_ogid_ += 1;
+}
+
+PortableServer::ObjectId * TAO::PG_Object_Group_Manipulator::convert_ogid_to_oid (PortableGroup::ObjectGroupId ogid) const
+{
+ // 4294967295 -- Largest 32 bit unsigned integer
+ char oid_str[11];
+ ACE_OS::snprintf (oid_str, sizeof(oid_str),
+ "%lu",
+ ACE_static_cast (ACE_UINT32,ogid));
+ oid_str[sizeof(oid_str) - 1] = '\0';
+
+ return PortableServer::string_to_ObjectId (oid_str);
+}
+
+PortableGroup::ObjectGroup_ptr
+TAO::PG_Object_Group_Manipulator::create_object_group (
+ const char * type_id,
+ const char * domain_id,
+ const PortableGroup::Criteria & the_criteria,
+ PortableGroup::ObjectGroupId & group_id
+ ACE_ENV_ARG_DECL)
+{
+ allocate_ogid(group_id);
+ PortableServer::ObjectId_var oid = convert_ogid_to_oid (group_id);
+
+ // Create a reference for the ObjectGroup
+ CORBA::Object_var object_group =
+ this->poa_->create_reference_with_id (group_id,
+ type_id
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (CORBA::Object::_nil ());
+
+ PortableGroup::TagGroupTaggedComponent tag_component;
+
+ tag_component.component_version.major = (CORBA::Octet) 1;
+ tag_component.component_version.minor = (CORBA::Octet) 0;
+ tag_component.group_domain_id = domain_id;
+ tag_component.object_group_id = group_id;
+ tag_component.object_group_ref_version = 0;
+
+ // Set the property
+ TAO::PG_Utils::set_tagged_component (object_group,
+ tag_component);
+ ACE_CHECK_RETURN (CORBA::Object::_nil ());
+
+ return object_group._retn ();
+}
+
+int
+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));
+ this->orb_ = CORBA::ORB::_duplicate (orb);
+
+ ACE_ASSERT (CORBA::is_nil (this->poa_.in ()) && !CORBA::is_nil (poa));
+ this->poa_ = PortableServer::POA::_duplicate (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);
+
+ this->iorm_ = TAO_IOP::TAO_IOR_Manipulation::_narrow (
+ IORM.in () ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN(-1);
+
+ return 0;
+}
+
+int TAO::PG_Object_Group_Manipulator::set_primary (
+ TAO_IOP::TAO_IOR_Property * prop,
+ PortableGroup::ObjectGroup_ptr group,
+ CORBA::Object_ptr new_primary
+ ACE_ENV_ARG_DECL) const
+{
+ int sts = this->iorm_->is_primary_set (prop, group ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+ if (sts)
+ {
+ (void)this->iorm_->remove_primary_tag (prop, group ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+ }
+ /////note: iorm takes it's parameters in the "wrong" order for this call
+ return this->iorm_->set_primary (prop, new_primary, group ACE_ENV_ARG_PARAMETER);
+}
+
+PortableGroup::ObjectGroup_ptr TAO::PG_Object_Group_Manipulator::merge_iors(
+ TAO_IOP::TAO_IOR_Manipulation::IORList & list ACE_ENV_ARG_DECL) const
+{
+ return this->iorm_->merge_iors (list ACE_ENV_ARG_PARAMETER);
+}
+
+PortableGroup::ObjectGroup_ptr TAO::PG_Object_Group_Manipulator::remove_profiles(
+ PortableGroup::ObjectGroup_ptr group,
+ PortableGroup::ObjectGroup_ptr profile
+ ACE_ENV_ARG_DECL) const
+{
+ return this->iorm_->remove_profiles(group, profile ACE_ENV_ARG_PARAMETER);
+}
+
+void dump_membership (const char * label, PortableGroup::ObjectGroup_ptr member)
+{
+#if 0
+ PortableGroup::TagFTGroupTaggedComponent ft_tag_component;
+ TAO_FT_IOGR_Property prop (ft_tag_component);
+ if (this->iorm_->is_primary_set (&prop, member))
+ {
+ ACE_DEBUG ( (LM_DEBUG,
+ ACE_TEXT ("%T %n (%P|%t) - %s: PRIMARY member.\n"),
+ label
+ ));
+ }
+ else
+ {
+ ACE_DEBUG ( (LM_DEBUG,
+ ACE_TEXT ("%T %n (%P|%t) - %s: backup member.\n"),
+ label
+ ));
+ }
+
+ PortableGroup::TagGroupTaggedComponent tag_component;
+ if (TAO::PG_Utils::get_tagged_component (member, tag_component))
+ {
+ ACE_DEBUG ( (LM_DEBUG,
+ ACE_TEXT ("%T %n (%P|%t) - %s: Group: .")
+ ACE_TEXT (" version: %u\n"),
+
+ label,
+ tag_component.object_group_ref_version
+ ));
+ }
+ else
+ {
+ ACE_DEBUG ( (LM_DEBUG,
+ ACE_TEXT ("%T %n (%P|%t) - %s: No group information found.\n"),
+ label
+ ));
+ }
+#endif
+}
+
+#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
+
+#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
+
+#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Manipulator.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Manipulator.h
new file mode 100644
index 00000000000..4f99ac244ec
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Manipulator.h
@@ -0,0 +1,113 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file PG_Object_Group_Manipulator.h
+ *
+ * $Id$
+ *
+ * @author Dale Wilson <wilson_d@ociweb.com>
+ */
+//=============================================================================
+
+
+#ifndef TAO_PG_OBJECT_GROUP_CREATOR_H
+#define TAO_PG_OBJECT_GROUP_CREATOR_H
+
+#include /**/ "ace/pre.h"
+#include "orbsvcs/PortableGroupS.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include <tao/IORManipulation/IORManip_Loader.h>
+
+namespace TAO
+{
+
+ /**
+ * @class TAO::PG_Object_Group_Manipulator
+ *
+ * @brief PortableGroup::ObjectGroupManager implementation.
+ *
+ * The ObjectGroupManager provides the interface necessary to
+ * facilitate application-controlled object group membership.
+ */
+ class TAO_PortableGroup_Export PG_Object_Group_Manipulator
+ {
+ public:
+
+ /// Constructor.
+ PG_Object_Group_Manipulator ();
+
+ /// Destructor.
+ ~PG_Object_Group_Manipulator ();
+
+ /**
+ * Initializes the group creator.
+ */
+ int init (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa ACE_ENV_ARG_DECL);
+
+ /**
+ * Create an empty object group.
+ */
+ PortableGroup::ObjectGroup_ptr create_object_group (
+ const char * type_id,
+ const char * domain_id,
+ const PortableGroup::Criteria & the_criteria,
+ PortableGroup::ObjectGroupId & group_id
+ ACE_ENV_ARG_DECL);
+
+ PortableGroup::ObjectGroup_ptr remove_profiles (
+ PortableGroup::ObjectGroup_ptr group,
+ PortableGroup::ObjectGroup_ptr profile
+ ACE_ENV_ARG_DECL) const;
+
+ PortableGroup::ObjectGroup_ptr merge_iors (
+ TAO_IOP::TAO_IOR_Manipulation::IORList & iors ACE_ENV_ARG_PARAMETER) const;
+
+ int set_primary (
+ TAO_IOP::TAO_IOR_Property * prop,
+ PortableGroup::ObjectGroup_ptr reference,
+ CORBA::Object_ptr new_primary
+ ACE_ENV_ARG_DECL) const;
+
+ void dump_membership (const char * label, PortableGroup::ObjectGroup_ptr member) const;
+
+ private:
+
+ /**
+ * Allocate an ogid for a new object group
+ */
+ void allocate_ogid (PortableGroup::ObjectGroupId & ogid);
+
+ /**
+ * convert numeric OGID to Sequence<Octet> oid
+ */
+ PortableServer::ObjectId * convert_ogid_to_oid (PortableGroup::ObjectGroupId ogid) const;
+
+ private:
+
+ /// The orb
+ CORBA::ORB_var orb_;
+
+ /// Reference to the POA that created the object group references.
+ PortableServer::POA_var poa_;
+
+ /// The ORBs IORManipulation object
+ TAO_IOP::TAO_IOR_Manipulation_var iorm_;
+
+ /// Lock used to synchronize access to next_ogid_.
+ TAO_SYNCH_MUTEX lock_ogid_;
+
+ /// Next ogid to be allocated.
+ PortableGroup::ObjectGroupId next_ogid_;
+
+ };
+} //namespace TAO
+
+
+#include /**/ "ace/post.h"
+
+#endif /* TAO::PG_OBJECT_GROUP_CREATOR_H */
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Support.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Support.cpp
index 1ca445a5066..9df10e2c48d 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Support.cpp
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Support.cpp
@@ -119,7 +119,7 @@ TAO::PG_Properties_Support::remove_type_properties (
}
-TAO_PG::Properties_Decoder *
+TAO_PG::Properties_Decoder *
TAO::PG_Properties_Support::find_typeid_properties (
const char *type_id
ACE_ENV_ARG_PARAMETER)
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Support.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Support.h
index a35a6717749..2c8e9e8c7f9 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Support.h
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Support.h
@@ -47,7 +47,7 @@ namespace TAO
void set_type_properties (
const char *type_id,
const PortableGroup::Properties & overrides
- ACE_ENV_ARG_DECL)
+ ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((
CORBA::SystemException,
PortableGroup::InvalidProperty,
diff --git a/TAO/tao/IORManipulation/IORManipulation.cpp b/TAO/tao/IORManipulation/IORManipulation.cpp
index a3da3d21beb..07ba2a3e9e0 100644
--- a/TAO/tao/IORManipulation/IORManipulation.cpp
+++ b/TAO/tao/IORManipulation/IORManipulation.cpp
@@ -148,7 +148,7 @@ TAO_IOR_Manipulation_impl::add_profiles (
CORBA::Object_ptr
TAO_IOR_Manipulation_impl::remove_profiles (
- CORBA::Object_ptr ior1,
+ CORBA::Object_ptr group,
CORBA::Object_ptr ior2
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((
@@ -160,14 +160,14 @@ TAO_IOR_Manipulation_impl::remove_profiles (
{
// First verify they are the same type!
CORBA::String_var id =
- CORBA::string_dup (ior1->_stubobj ()->type_id.in ());
+ CORBA::string_dup (group->_stubobj ()->type_id.in ());
if (id.in () && ior2->_stubobj ()->type_id.in () &&
ACE_OS::strcmp (id.in (), ior2->_stubobj ()->type_id.in ()))
ACE_THROW_RETURN (TAO_IOP::Invalid_IOR (),
CORBA::Object::_nil ());
- // Since we are removing from ior1 ...
- CORBA::ULong count = ior1->_stubobj ()->base_profiles ().profile_count ();
+ // Since we are removing from group ...
+ CORBA::ULong count = group->_stubobj ()->base_profiles ().profile_count ();
// make sure we have some profiles
if (count == 0 ||
@@ -178,7 +178,7 @@ TAO_IOR_Manipulation_impl::remove_profiles (
// initialize with estimated pfile count.
TAO_MProfile Diff_Profiles (count);
- auto_ptr<TAO_MProfile> tmp_pfiles (ior1->_stubobj ()->make_profiles ());
+ auto_ptr<TAO_MProfile> tmp_pfiles (group->_stubobj ()->make_profiles ());
if (Diff_Profiles.add_profiles (tmp_pfiles.get ()) < 0)
ACE_THROW_RETURN (TAO_IOP::Invalid_IOR (),
CORBA::Object::_nil ());
@@ -232,54 +232,55 @@ TAO_IOR_Manipulation_impl::remove_profiles (
CORBA::Boolean
TAO_IOR_Manipulation_impl::set_property (
TAO_IOP::TAO_IOR_Property_ptr prop,
- CORBA::Object_ptr ior
+ CORBA::Object_ptr group
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
TAO_IOP::Invalid_IOR,
TAO_IOP::Duplicate))
{
// make sure we have some profiles
- if (ior->_stubobj ()->base_profiles ().profile_count () == 0)
+ if (group->_stubobj ()->base_profiles ().profile_count () == 0)
ACE_THROW_RETURN (TAO_IOP::Invalid_IOR (),
0);
// Call the implementation object to
- return prop->set_property (ior
+ return prop->set_property (group
ACE_ENV_ARG_PARAMETER);
}
+//@@ note awkward argument order
CORBA::Boolean
TAO_IOR_Manipulation_impl::set_primary (
TAO_IOP::TAO_IOR_Property_ptr prop,
- CORBA::Object_ptr ior1,
- CORBA::Object_ptr ior2
+ CORBA::Object_ptr new_primary,
+ CORBA::Object_ptr group
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
TAO_IOP::Invalid_IOR,
TAO_IOP::Duplicate,
TAO_IOP::MultiProfileList))
{
- // make sure we have some profiles in IOR2
- if (ior2->_stubobj ()->base_profiles ().profile_count () == 0)
+ // make sure we have some profiles in GROUP
+ if (group->_stubobj ()->base_profiles ().profile_count () == 0)
ACE_THROW_RETURN (TAO_IOP::Invalid_IOR (),
0);
- // Make sure we have only one profile in IOR1
+ // Make sure we have only one profile in new_primary
// @@ Will fail if the object has been
- /*if (ior1->_stubobj ()->base_profiles ().profile_count () > 1)
+ /*if (new_primary->_stubobj ()->base_profiles ().profile_count () > 1)
ACE_THROW_RETURN (TAO_IOP::MultiProfileList (),
0);*/
// Call the callback object to do the rest of the processing.
- return prop->set_primary (ior1,
- ior2
+ return prop->set_primary (new_primary,
+ group
ACE_ENV_ARG_PARAMETER);
}
CORBA::Object_ptr
TAO_IOR_Manipulation_impl::get_primary (
TAO_IOP::TAO_IOR_Property_ptr prop,
- CORBA::Object_ptr ior
+ CORBA::Object_ptr group
ACE_ENV_ARG_DECL
)
ACE_THROW_SPEC ((
@@ -288,35 +289,35 @@ TAO_IOR_Manipulation_impl::get_primary (
))
{
// make sure we have some profiles in IOR
- if (ior->_stubobj ()->base_profiles ().profile_count () == 0)
+ if (group->_stubobj ()->base_profiles ().profile_count () == 0)
ACE_THROW_RETURN (TAO_IOP::NotFound (), 0);
// @@ Bala: this was throwing TAO_IOP::Invalid_IOR, but it was not
// in the throw spec, that will result in a CORBA::UNKNOWN at
// run-time (if it does not crash). Any idea about what is going on
// here?
- return prop->get_primary (ior
+ return prop->get_primary (group
ACE_ENV_ARG_PARAMETER);
}
CORBA::Boolean
TAO_IOR_Manipulation_impl::is_primary_set (
TAO_IOP::TAO_IOR_Property_ptr prop,
- CORBA::Object_ptr ior
+ CORBA::Object_ptr group
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
- return prop->is_primary_set (ior ACE_ENV_ARG_PARAMETER);
+ return prop->is_primary_set (group ACE_ENV_ARG_PARAMETER);
}
CORBA::Boolean
TAO_IOR_Manipulation_impl:: remove_primary_tag (
TAO_IOP::TAO_IOR_Property_ptr prop,
- CORBA::Object_ptr ior
+ CORBA::Object_ptr group
ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((CORBA::SystemException))
+ ACE_THROW_SPEC ((CORBA::SystemException))
{
- return prop->remove_primary_tag (ior ACE_ENV_ARG_PARAMETER);
+ return prop->remove_primary_tag (group ACE_ENV_ARG_PARAMETER);
}
CORBA::ULong
@@ -352,13 +353,13 @@ TAO_IOR_Manipulation_impl::is_in_ior (
CORBA::ULong
TAO_IOR_Manipulation_impl::get_profile_count (
- CORBA::Object_ptr ior
+ CORBA::Object_ptr group
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
TAO_IOP::EmptyProfileList))
{
CORBA::ULong count;
- count = ior->_stubobj ()->base_profiles ().profile_count ();
+ count = group->_stubobj ()->base_profiles ().profile_count ();
if (count == 0)
ACE_THROW_RETURN (TAO_IOP::EmptyProfileList (),
diff --git a/TAO/tao/IORManipulation/IORManipulation.h b/TAO/tao/IORManipulation/IORManipulation.h
index 7388a46f7ad..61b05ca2a86 100644
--- a/TAO/tao/IORManipulation/IORManipulation.h
+++ b/TAO/tao/IORManipulation/IORManipulation.h
@@ -77,7 +77,7 @@ public:
));
virtual CORBA::Object_ptr remove_profiles (
- CORBA::Object_ptr ior1,
+ CORBA::Object_ptr group,
CORBA::Object_ptr ior2
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
ACE_THROW_SPEC ((
@@ -89,7 +89,7 @@ public:
virtual CORBA::Boolean set_property (
TAO_IOP::TAO_IOR_Property_ptr prop,
- CORBA::Object_ptr ior
+ CORBA::Object_ptr group
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
ACE_THROW_SPEC ((
@@ -98,10 +98,11 @@ public:
TAO_IOP::Duplicate
));
+ // @@ note awkward argument order
virtual CORBA::Boolean set_primary (
TAO_IOP::TAO_IOR_Property_ptr prop,
- CORBA::Object_ptr ior1,
- CORBA::Object_ptr ior2
+ CORBA::Object_ptr new_primary,
+ CORBA::Object_ptr group
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
ACE_THROW_SPEC ((
@@ -113,7 +114,7 @@ public:
virtual CORBA::Object_ptr get_primary (
TAO_IOP::TAO_IOR_Property_ptr prop,
- CORBA::Object_ptr ior
+ CORBA::Object_ptr group
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
ACE_THROW_SPEC ((
@@ -123,7 +124,7 @@ public:
virtual CORBA::Boolean is_primary_set (
TAO_IOP::TAO_IOR_Property_ptr prop,
- CORBA::Object_ptr ior
+ CORBA::Object_ptr group
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
ACE_THROW_SPEC ((
@@ -148,7 +149,7 @@ public:
));
virtual CORBA::ULong get_profile_count (
- CORBA::Object_ptr ior
+ CORBA::Object_ptr group
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
ACE_THROW_SPEC ((
CORBA::SystemException,