summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfhunleth <fhunleth@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2002-01-13 06:17:34 +0000
committerfhunleth <fhunleth@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2002-01-13 06:17:34 +0000
commit6a329643958b0642d7e7793edb5c3154b9294895 (patch)
treee01b5280713231330266424092fdcc970d0b1194
parent743b409493dd05ddc51c7c875a5bc46cb5a8a099 (diff)
downloadATCD-6a329643958b0642d7e7793edb5c3154b9294895.tar.gz
Added POA_Hooks
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/POA_Hooks.cpp249
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/POA_Hooks.h119
2 files changed, 368 insertions, 0 deletions
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/POA_Hooks.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/POA_Hooks.cpp
new file mode 100644
index 00000000000..1e1106b13f5
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/POA_Hooks.cpp
@@ -0,0 +1,249 @@
+// This may look like C, but it's really -*- C++ -*-
+//
+// $Id$
+
+#include "POA_Hooks.h"
+#include "PortableGroup_Loader.h"
+#include "tao/Stub.h"
+#include "PortableGroup_Request_Dispatcher.h"
+
+ACE_RCSID(tao, PortableGroup, "$Id$")
+
+TAO_POA_Hooks::TAO_POA_Hooks (PortableGroup_Request_Dispatcher &request_dispatcher) :
+ request_dispatcher_ (request_dispatcher)
+{
+}
+
+TAO_POA_Hooks::~TAO_POA_Hooks (void)
+{
+}
+
+PortableServer::ObjectId *
+TAO_POA_Hooks::create_id_for_reference (
+ TAO_POA &the_poa,
+ CORBA::Object_ptr the_ref
+ TAO_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ PortableServer::NotAGroupObject
+ ))
+{
+
+ // Get the RepositoryId from the Group reference so
+ // we know what kind of reference to make.
+ const char* repository_id = the_ref->_stubobj ()->type_id;
+
+ // Create a temporary object reference and then get the
+ // ObjectId out of it.
+ CORBA::Object_var obj_ref = the_poa.create_reference (repository_id
+ TAO_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ PortableServer::ObjectId_var obj_id = the_poa.reference_to_id (obj_ref.in ()
+ TAO_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ // Associate the object reference with the group reference.
+ this->associate_group_with_ref (the_poa,
+ the_ref,
+ obj_ref.in ()
+ TAO_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ return obj_id._retn ();
+}
+
+int
+TAO_POA_Hooks::find_group_component (const CORBA::Object_ptr the_ref,
+ PortableGroup::TagGroupTaggedComponent &group)
+{
+ const TAO_MProfile& profiles = the_ref->_stubobj ()->base_profiles ();
+ const TAO_Profile* profile;
+ CORBA::ULong slot;
+
+ // Iterate through the tagged profiles, and
+ // create acceptors for the multicast ones.
+ slot = 0;
+ while (profile = profiles.get_profile (slot))
+ {
+ if (this->find_group_component_in_profile (profile, group) == 0)
+ return 0;
+
+ ++slot;
+ }
+
+ // Not found.
+ return -1;
+}
+
+int
+TAO_POA_Hooks::find_group_component_in_profile (const TAO_Profile* profile,
+ PortableGroup::TagGroupTaggedComponent &group)
+{
+ // Iterate through the tagged components looking for
+ // group tag.
+ const TAO_Tagged_Components& components = profile->tagged_components ();
+
+ IOP::TaggedComponent tagged_component;
+ tagged_component.tag = TAO_TAG_GROUP;
+
+ // Try to find it.
+ if (components.get_component (tagged_component) == 0)
+ return -1;
+
+ // Found it.
+ const CORBA::Octet *buf =
+ tagged_component.component_data.get_buffer ();
+
+ TAO_InputCDR in_cdr (ACE_reinterpret_cast (const char*, buf),
+ tagged_component.component_data.length ());
+
+ // Extract the Byte Order.
+ CORBA::Boolean byte_order;
+ if ((in_cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0)
+ return -1;
+ in_cdr.reset_byte_order (ACE_static_cast(int, byte_order));
+
+ if ((in_cdr >> group) == 0)
+ return -1;
+
+ return 0;
+}
+
+int
+TAO_POA_Hooks::create_group_acceptors (CORBA::Object_ptr the_ref,
+ TAO_PortableGroup_Acceptor_Registry &acceptor_registry,
+ TAO_ORB_Core &orb_core
+ TAO_ENV_ARG_DECL)
+{
+ const TAO_MProfile& profiles = the_ref->_stubobj ()->base_profiles ();
+ const TAO_Profile* profile;
+ CORBA::ULong slot;
+ int num = 0;
+
+ // Iterate through the tagged profiles, and
+ // create acceptors for the multicast ones.
+ slot = 0;
+ while (profile = profiles.get_profile (slot))
+ {
+ if (profile->supports_multicast ())
+ {
+ acceptor_registry.open (profile,
+ orb_core
+ TAO_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+ ++num;
+ }
+
+ ++slot;
+ }
+
+ // Return the number of acceptors registered.
+ return num;
+}
+
+
+PortableServer::IDs *
+TAO_POA_Hooks::reference_to_ids (
+ TAO_POA &the_poa,
+ CORBA::Object_ptr the_ref
+ TAO_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ PortableServer::NotAGroupObject
+ ))
+{
+
+ return 0;
+}
+
+void
+TAO_POA_Hooks::associate_group_with_ref (
+ TAO_POA &the_poa,
+ CORBA::Object_ptr group_ref,
+ CORBA::Object_ptr obj_ref
+ TAO_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableServer::NotAGroupObject))
+{
+ // Find the Group Component so that we can extract the Group ID.
+ PortableGroup::TagGroupTaggedComponent *tmp_group_id;
+ ACE_NEW_THROW_EX (tmp_group_id,
+ PortableGroup::TagGroupTaggedComponent,
+ CORBA::NO_MEMORY (
+ CORBA::SystemException::_tao_minor_code (
+ TAO_DEFAULT_MINOR_CODE,
+ ENOMEM),
+ CORBA::COMPLETED_NO));
+ ACE_CHECK;
+
+ PortableGroup::TagGroupTaggedComponent_var group_id = tmp_group_id;
+
+ if (this->find_group_component (group_ref, group_id.inout ()) != 0)
+ {
+ // Group component wasn't found. The group reference
+ // that was passed in must be bogus.
+ ACE_THROW (PortableServer::NotAGroupObject ());
+ }
+
+ // Create the acceptors necessary to receive requests for the
+ // specified group reference.
+ this->create_group_acceptors (group_ref,
+ this->request_dispatcher_.acceptor_registry_,
+ the_poa.orb_core ()
+ TAO_ENV_ARG_PARAMETER);
+
+ ACE_CHECK;
+
+
+ // Add a mapping from GroupId to Object key in the PortableGroup
+ const TAO_ObjectKey &key = obj_ref->_object_key ();
+ this->request_dispatcher_.group_map_.add_groupid_objectkey_pair (
+ group_id._retn (),
+ key
+ TAO_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+}
+
+void
+TAO_POA_Hooks::associate_reference_with_id (
+ TAO_POA &the_poa,
+ CORBA::Object_ptr ref,
+ const PortableServer::ObjectId & oid
+ TAO_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ PortableServer::NotAGroupObject
+ ))
+{
+
+ // Create a reference for the specified ObjectId, since
+ // it is much easier to extract the object key from the
+ // reference.
+ CORBA::Object_var obj_ref = the_poa.id_to_reference (oid
+ TAO_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ // Associate the object reference with the group reference.
+ this->associate_group_with_ref (the_poa,
+ ref,
+ obj_ref.in ()
+ TAO_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+void
+TAO_POA_Hooks::disassociate_reference_with_id (
+ TAO_POA &the_poa,
+ CORBA::Object_ptr ref,
+ const PortableServer::ObjectId & oid
+ TAO_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ PortableServer::NotAGroupObject
+ ))
+{
+}
+
+
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/POA_Hooks.h b/TAO/orbsvcs/orbsvcs/PortableGroup/POA_Hooks.h
new file mode 100644
index 00000000000..a5135765dbf
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/POA_Hooks.h
@@ -0,0 +1,119 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file POA_Hooks.h
+ *
+ * $Id$
+ *
+ * @author Frank Hunleth <fhunleth@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef TAO_POA_HOOKS_H
+#define TAO_POA_HOOKS_H
+#include "ace/pre.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "portablegroup_export.h"
+#include "tao/PortableServer/PortableGroup_Hooks.h"
+#include "orbsvcs/PortableGroupC.h"
+
+// Forward references
+class PortableGroup_Request_Dispatcher;
+class TAO_PortableGroup_Loader;
+class TAO_Profile;
+class TAO_PortableGroup_Acceptor_Registry;
+
+/**
+ * @class TAO_POA_Hooks
+ *
+ * @brief TAO_POA_Hooks
+ *
+ * This class acts as a facade for all of the POA specific methods in the
+ * PortableGroup library.
+ */
+class TAO_PortableGroup_Export TAO_POA_Hooks :
+ public TAO_POA_PortableGroup_Hooks
+{
+public:
+ TAO_POA_Hooks (PortableGroup_Request_Dispatcher &request_dispatcher);
+
+ virtual ~TAO_POA_Hooks (void);
+
+ virtual PortableServer::ObjectId * create_id_for_reference (
+ TAO_POA &the_poa,
+ CORBA::Object_ptr the_ref
+ TAO_ENV_ARG_DECL_WITH_DEFAULTS
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ PortableServer::NotAGroupObject
+ ));
+
+ virtual PortableServer::IDs * reference_to_ids (
+ TAO_POA &the_poa,
+ CORBA::Object_ptr the_ref
+ TAO_ENV_ARG_DECL_WITH_DEFAULTS
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ PortableServer::NotAGroupObject
+ ));
+
+ virtual void associate_reference_with_id (
+ TAO_POA &the_poa,
+ CORBA::Object_ptr ref,
+ const PortableServer::ObjectId & oid
+ TAO_ENV_ARG_DECL_WITH_DEFAULTS
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ PortableServer::NotAGroupObject
+ ));
+
+ virtual void disassociate_reference_with_id (
+ TAO_POA &the_poa,
+ CORBA::Object_ptr ref,
+ const PortableServer::ObjectId & oid
+ TAO_ENV_ARG_DECL_WITH_DEFAULTS
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ PortableServer::NotAGroupObject
+ ));
+
+protected:
+
+ int find_group_component (const CORBA::Object_ptr the_ref,
+ PortableGroup::TagGroupTaggedComponent &group);
+
+ int find_group_component_in_profile (const TAO_Profile* profile,
+ PortableGroup::TagGroupTaggedComponent &group);
+
+ int create_group_acceptors (CORBA::Object_ptr the_ref,
+ TAO_PortableGroup_Acceptor_Registry &acceptor_registry,
+ TAO_ORB_Core &orb_core
+ TAO_ENV_ARG_DECL);
+
+ /// Helper function to associate group references with
+ /// object references.
+ void associate_group_with_ref (
+ TAO_POA &the_poa,
+ CORBA::Object_ptr group_ref,
+ CORBA::Object_ptr obj_ref
+ TAO_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableServer::NotAGroupObject));
+
+
+private:
+ PortableGroup_Request_Dispatcher &request_dispatcher_;
+};
+
+
+#include "ace/post.h"
+#endif /* TAO_POA_HOOKS_H */