GOA.cpp

Go to the documentation of this file.
00001 #include "orbsvcs/PortableGroup/GOA.h"
00002 
00003 
00004 ACE_RCSID (PortableGroup,
00005            GOA,
00006            "GOA.cpp,v 1.10 2006/04/26 13:42:42 mesnier_p Exp")
00007 
00008 
00009 #include "orbsvcs/PortableGroup/PortableGroup_Acceptor_Registry.h"
00010 #include "orbsvcs/PortableGroup/PortableGroup_Request_Dispatcher.h"
00011 
00012 #include "tao/ORB_Core.h"
00013 #include "tao/ORB.h"
00014 #include "tao/Stub.h"
00015 #include "tao/Tagged_Components.h"
00016 #include "tao/Profile.h"
00017 #include "tao/CDR.h"
00018 
00019 #include "ace/Auto_Ptr.h"
00020 
00021 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00022 
00023 PortableServer::ObjectId *
00024 TAO_GOA::create_id_for_reference (CORBA::Object_ptr the_ref
00025                                   ACE_ENV_ARG_DECL)
00026     ACE_THROW_SPEC ((
00027       CORBA::SystemException,
00028       PortableGroup::NotAGroupObject
00029     ))
00030 {
00031   // Get the RepositoryId from the Group reference so
00032   // we know what kind of reference to make.
00033   const char* repository_id = the_ref->_stubobj ()->type_id.in ();
00034 
00035   // Create a temporary object reference and then get the
00036   // ObjectId out of it.
00037   CORBA::Object_var obj_ref = this->create_reference (repository_id
00038                                                       ACE_ENV_ARG_PARAMETER);
00039   ACE_CHECK_RETURN (0);
00040 
00041   PortableServer::ObjectId_var obj_id =
00042     this->reference_to_id (obj_ref.in () ACE_ENV_ARG_PARAMETER);
00043   ACE_CHECK_RETURN (0);
00044 
00045   // Associate the object reference with the group reference.
00046   this->associate_group_with_ref (the_ref,
00047                                   obj_ref.in ()
00048                                   ACE_ENV_ARG_PARAMETER);
00049   ACE_CHECK_RETURN (0);
00050 
00051   return obj_id._retn ();
00052 }
00053 
00054 PortableGroup::IDs *
00055 TAO_GOA::reference_to_ids (CORBA::Object_ptr the_ref
00056                            ACE_ENV_ARG_DECL_NOT_USED)
00057     ACE_THROW_SPEC ((
00058       CORBA::SystemException,
00059       PortableGroup::NotAGroupObject
00060     ))
00061 {
00062   ACE_UNUSED_ARG (the_ref);
00063 
00064   return 0;
00065 }
00066 
00067 void
00068 TAO_GOA::associate_reference_with_id (CORBA::Object_ptr ref,
00069                                       const PortableServer::ObjectId & oid
00070                                       ACE_ENV_ARG_DECL)
00071     ACE_THROW_SPEC ((
00072       CORBA::SystemException,
00073       PortableGroup::NotAGroupObject
00074     ))
00075 {
00076   // Create a reference for the specified ObjectId, since
00077   // it is much easier to extract the object key from the
00078   // reference.
00079   CORBA::Object_var obj_ref = this->id_to_reference (oid
00080                                                      ACE_ENV_ARG_PARAMETER);
00081   ACE_CHECK;
00082 
00083   // Associate the object reference with the group reference.
00084   this->associate_group_with_ref (ref,
00085                                   obj_ref.in ()
00086                                   ACE_ENV_ARG_PARAMETER);
00087   ACE_CHECK;
00088 }
00089 
00090 void
00091 TAO_GOA::disassociate_reference_with_id (CORBA::Object_ptr ref,
00092                                          const PortableServer::ObjectId & oid
00093                                          ACE_ENV_ARG_DECL_NOT_USED)
00094     ACE_THROW_SPEC ((
00095       CORBA::SystemException,
00096       PortableGroup::NotAGroupObject
00097     ))
00098 {
00099   ACE_UNUSED_ARG (ref);
00100   ACE_UNUSED_ARG (oid);
00101 }
00102 
00103 
00104 TAO_GOA::TAO_GOA (const TAO_Root_POA::String &name,
00105                   PortableServer::POAManager_ptr poa_manager,
00106                   const TAO_POA_Policy_Set &policies,
00107                   TAO_Root_POA *parent,
00108                   ACE_Lock &lock,
00109                   TAO_SYNCH_MUTEX &thread_lock,
00110                   TAO_ORB_Core &orb_core,
00111                   TAO_Object_Adapter *object_adapter
00112                   ACE_ENV_ARG_DECL)
00113   : TAO_Regular_POA (name,
00114                      poa_manager,
00115                      policies,
00116                      parent,
00117                      lock,
00118                      thread_lock,
00119                      orb_core,
00120                      object_adapter
00121                      ACE_ENV_ARG_PARAMETER)
00122 {
00123 }
00124 
00125 TAO_GOA::~TAO_GOA (void)
00126 {
00127 }
00128 
00129 TAO_Root_POA *
00130 TAO_GOA::new_POA (const String &name,
00131                   PortableServer::POAManager_ptr poa_manager,
00132                   const TAO_POA_Policy_Set &policies,
00133                   TAO_Root_POA *parent,
00134                   ACE_Lock &lock,
00135                   TAO_SYNCH_MUTEX &thread_lock,
00136                   TAO_ORB_Core &orb_core,
00137                   TAO_Object_Adapter *object_adapter
00138                   ACE_ENV_ARG_DECL)
00139 {
00140   TAO_GOA *poa = 0;
00141 
00142   ACE_NEW_THROW_EX (poa,
00143                     TAO_GOA (name,
00144                              poa_manager,
00145                              policies,
00146                              parent,
00147                              lock,
00148                              thread_lock,
00149                              orb_core,
00150                              object_adapter
00151                              ACE_ENV_ARG_PARAMETER),
00152                     CORBA::NO_MEMORY ());
00153   ACE_CHECK_RETURN (0);
00154 
00155   return poa;
00156 }
00157 
00158 // Standard POA interfaces
00159 PortableServer::POA_ptr
00160 TAO_GOA::create_POA (const char *adapter_name,
00161                         PortableServer::POAManager_ptr poa_manager,
00162                         const CORBA::PolicyList &policies
00163                         ACE_ENV_ARG_DECL)
00164   ACE_THROW_SPEC ((CORBA::SystemException,
00165                    PortableServer::POA::AdapterAlreadyExists,
00166                    PortableServer::POA::InvalidPolicy))
00167 {
00168   PortableServer::POA_ptr poa = this->TAO_Regular_POA::create_POA (adapter_name,
00169                                                            poa_manager,
00170                                                            policies
00171                                                            ACE_ENV_ARG_PARAMETER);
00172   ACE_CHECK_RETURN (poa);
00173   return poa;
00174 }
00175 
00176 PortableServer::POA_ptr
00177 TAO_GOA::find_POA (const char *adapter_name,
00178                       CORBA::Boolean activate_it
00179                       ACE_ENV_ARG_DECL)
00180   ACE_THROW_SPEC ((CORBA::SystemException,
00181                    PortableServer::POA::AdapterNonExistent))
00182 {
00183   PortableServer::POA_ptr poa = this->TAO_Regular_POA::find_POA (adapter_name,
00184                                                          activate_it
00185                                                          ACE_ENV_ARG_PARAMETER);
00186   ACE_CHECK_RETURN (poa);
00187   return poa;
00188 }
00189 
00190 void
00191 TAO_GOA::destroy (CORBA::Boolean etherealize_objects,
00192                      CORBA::Boolean wait_for_completion
00193                      ACE_ENV_ARG_DECL)
00194   ACE_THROW_SPEC ((CORBA::SystemException))
00195 {
00196   this->TAO_Regular_POA::destroy (etherealize_objects,
00197                           wait_for_completion
00198                           ACE_ENV_ARG_PARAMETER);
00199   ACE_CHECK;
00200 }
00201 
00202 
00203 #if (TAO_HAS_MINIMUM_POA == 0)
00204 
00205 PortableServer::ThreadPolicy_ptr
00206 TAO_GOA::create_thread_policy (PortableServer::ThreadPolicyValue value
00207                                   ACE_ENV_ARG_DECL)
00208   ACE_THROW_SPEC ((CORBA::SystemException))
00209 {
00210   PortableServer::ThreadPolicy_ptr policy =
00211     this->TAO_Regular_POA::create_thread_policy (value
00212                                          ACE_ENV_ARG_PARAMETER);
00213   ACE_CHECK_RETURN (policy);
00214   return policy;
00215 }
00216 
00217 #endif /* TAO_HAS_MINIMUM_POA == 0 */
00218 
00219 PortableServer::LifespanPolicy_ptr
00220 TAO_GOA::create_lifespan_policy (PortableServer::LifespanPolicyValue value
00221                                     ACE_ENV_ARG_DECL)
00222   ACE_THROW_SPEC ((CORBA::SystemException))
00223 {
00224   PortableServer::LifespanPolicy_ptr policy =
00225     this->TAO_Regular_POA::create_lifespan_policy (value
00226                                            ACE_ENV_ARG_PARAMETER);
00227   ACE_CHECK_RETURN (policy);
00228   return policy;
00229 }
00230 
00231 PortableServer::IdUniquenessPolicy_ptr
00232 TAO_GOA::create_id_uniqueness_policy (PortableServer::IdUniquenessPolicyValue value
00233                                          ACE_ENV_ARG_DECL)
00234   ACE_THROW_SPEC ((CORBA::SystemException))
00235 {
00236   PortableServer::IdUniquenessPolicy_ptr policy =
00237     this->TAO_Regular_POA::create_id_uniqueness_policy (value
00238                                                 ACE_ENV_ARG_PARAMETER);
00239   ACE_CHECK_RETURN (policy);
00240   return policy;
00241 }
00242 
00243 
00244 PortableServer::IdAssignmentPolicy_ptr
00245 TAO_GOA::create_id_assignment_policy (PortableServer::IdAssignmentPolicyValue value
00246                                          ACE_ENV_ARG_DECL)
00247   ACE_THROW_SPEC ((CORBA::SystemException))
00248 {
00249   PortableServer::IdAssignmentPolicy_ptr policy =
00250     this->TAO_Regular_POA::create_id_assignment_policy (value
00251                                                 ACE_ENV_ARG_PARAMETER);
00252   ACE_CHECK_RETURN (policy);
00253   return policy;
00254 }
00255 
00256 
00257 #if (TAO_HAS_MINIMUM_POA == 0)
00258 
00259 PortableServer::ImplicitActivationPolicy_ptr
00260 TAO_GOA::create_implicit_activation_policy (PortableServer::ImplicitActivationPolicyValue value
00261                                                ACE_ENV_ARG_DECL)
00262   ACE_THROW_SPEC ((CORBA::SystemException))
00263 {
00264   PortableServer::ImplicitActivationPolicy_ptr policy =
00265     this->TAO_Regular_POA::create_implicit_activation_policy (value
00266                                                       ACE_ENV_ARG_PARAMETER);
00267   ACE_CHECK_RETURN (policy);
00268   return policy;
00269 }
00270 
00271 PortableServer::ServantRetentionPolicy_ptr
00272 TAO_GOA::create_servant_retention_policy (PortableServer::ServantRetentionPolicyValue value
00273                                              ACE_ENV_ARG_DECL)
00274   ACE_THROW_SPEC ((CORBA::SystemException))
00275 {
00276   PortableServer::ServantRetentionPolicy_ptr policy =
00277     this->TAO_Regular_POA::create_servant_retention_policy (value
00278                                                     ACE_ENV_ARG_PARAMETER);
00279   ACE_CHECK_RETURN (policy);
00280   return policy;
00281 }
00282 
00283 
00284 PortableServer::RequestProcessingPolicy_ptr
00285 TAO_GOA::create_request_processing_policy (PortableServer::RequestProcessingPolicyValue value
00286                                               ACE_ENV_ARG_DECL)
00287   ACE_THROW_SPEC ((CORBA::SystemException))
00288 {
00289   PortableServer::RequestProcessingPolicy_ptr policy =
00290     this->TAO_Regular_POA::create_request_processing_policy (value
00291                                                      ACE_ENV_ARG_PARAMETER);
00292   ACE_CHECK_RETURN (policy);
00293   return policy;
00294 }
00295 
00296 
00297 #endif /* TAO_HAS_MINIMUM_POA == 0 */
00298 
00299 char *
00300 TAO_GOA::the_name (ACE_ENV_SINGLE_ARG_DECL)
00301   ACE_THROW_SPEC ((CORBA::SystemException))
00302 {
00303   char * name =
00304     this->TAO_Regular_POA::the_name (ACE_ENV_SINGLE_ARG_PARAMETER);
00305   ACE_CHECK_RETURN (name);
00306   return name;
00307 }
00308 
00309 PortableServer::POA_ptr
00310 TAO_GOA::the_parent (ACE_ENV_SINGLE_ARG_DECL)
00311   ACE_THROW_SPEC ((CORBA::SystemException))
00312 {
00313   PortableServer::POA_ptr parent =
00314     this->TAO_Regular_POA::the_parent (ACE_ENV_SINGLE_ARG_PARAMETER);
00315   ACE_CHECK_RETURN (parent);
00316   return parent;
00317 }
00318 
00319 PortableServer::POAList *
00320 TAO_GOA::the_children (ACE_ENV_SINGLE_ARG_DECL)
00321   ACE_THROW_SPEC ((CORBA::SystemException))
00322 {
00323   PortableServer::POAList *children =
00324     this->TAO_Regular_POA::the_children (ACE_ENV_SINGLE_ARG_PARAMETER);
00325   ACE_CHECK_RETURN (children);
00326   return children;
00327 }
00328 
00329 PortableServer::POAManager_ptr
00330 TAO_GOA::the_POAManager (ACE_ENV_SINGLE_ARG_DECL)
00331   ACE_THROW_SPEC ((CORBA::SystemException))
00332 {
00333   PortableServer::POAManager_ptr poa_manager =
00334     this->TAO_Regular_POA::the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER);
00335   ACE_CHECK_RETURN (poa_manager);
00336   return poa_manager;
00337 }
00338 
00339 
00340 #if (TAO_HAS_MINIMUM_POA == 0)
00341 
00342 PortableServer::AdapterActivator_ptr
00343 TAO_GOA::the_activator (ACE_ENV_SINGLE_ARG_DECL)
00344   ACE_THROW_SPEC ((CORBA::SystemException))
00345 {
00346   PortableServer::AdapterActivator_ptr activator =
00347     this->TAO_Regular_POA::the_activator (ACE_ENV_SINGLE_ARG_PARAMETER);
00348   ACE_CHECK_RETURN (activator);
00349   return activator;
00350 }
00351 
00352 void
00353 TAO_GOA::the_activator (PortableServer::AdapterActivator_ptr adapter_activator
00354                            ACE_ENV_ARG_DECL)
00355   ACE_THROW_SPEC ((CORBA::SystemException))
00356 {
00357   this->TAO_Regular_POA::the_activator (adapter_activator
00358                                 ACE_ENV_ARG_PARAMETER);
00359   ACE_CHECK;
00360 }
00361 
00362 PortableServer::ServantManager_ptr
00363 TAO_GOA::get_servant_manager (ACE_ENV_SINGLE_ARG_DECL)
00364   ACE_THROW_SPEC ((CORBA::SystemException,
00365                    PortableServer::POA::WrongPolicy))
00366 {
00367   PortableServer::ServantManager_ptr servant_manager =
00368     this->TAO_Regular_POA::get_servant_manager (ACE_ENV_SINGLE_ARG_PARAMETER);
00369   ACE_CHECK_RETURN (servant_manager);
00370   return servant_manager;
00371 }
00372 
00373 void
00374 TAO_GOA::set_servant_manager (PortableServer::ServantManager_ptr imgr
00375                                  ACE_ENV_ARG_DECL)
00376   ACE_THROW_SPEC ((CORBA::SystemException,
00377                    PortableServer::POA::WrongPolicy))
00378 {
00379   this->TAO_Regular_POA::set_servant_manager (imgr
00380                                       ACE_ENV_ARG_PARAMETER);
00381   ACE_CHECK;
00382 }
00383 
00384 PortableServer::Servant
00385 TAO_GOA::get_servant (ACE_ENV_SINGLE_ARG_DECL)
00386   ACE_THROW_SPEC ((CORBA::SystemException,
00387                    PortableServer::POA::NoServant,
00388                    PortableServer::POA::WrongPolicy))
00389 {
00390   PortableServer::Servant servant =
00391     this->TAO_Regular_POA::get_servant (ACE_ENV_SINGLE_ARG_PARAMETER);
00392   ACE_CHECK_RETURN (servant);
00393   return servant;
00394 }
00395 
00396 void
00397 TAO_GOA::set_servant (PortableServer::Servant servant
00398                          ACE_ENV_ARG_DECL)
00399   ACE_THROW_SPEC ((CORBA::SystemException,
00400                    PortableServer::POA::WrongPolicy))
00401 {
00402   this->TAO_Regular_POA::set_servant (servant
00403                               ACE_ENV_ARG_PARAMETER);
00404   ACE_CHECK;
00405 }
00406 
00407 #endif /* TAO_HAS_MINIMUM_POA == 0 */
00408 
00409 PortableServer::ObjectId *
00410 TAO_GOA::activate_object (PortableServer::Servant p_servant
00411                              ACE_ENV_ARG_DECL)
00412   ACE_THROW_SPEC ((CORBA::SystemException,
00413                    PortableServer::POA::ServantAlreadyActive,
00414                    PortableServer::POA::WrongPolicy))
00415 {
00416   PortableServer::ObjectId *object_id =
00417     this->TAO_Regular_POA::activate_object (p_servant
00418                                     ACE_ENV_ARG_PARAMETER);
00419   ACE_CHECK_RETURN (object_id);
00420   return object_id;
00421 }
00422 
00423 void
00424 TAO_GOA::activate_object_with_id (const PortableServer::ObjectId &id,
00425                                      PortableServer::Servant p_servant
00426                                      ACE_ENV_ARG_DECL)
00427   ACE_THROW_SPEC ((CORBA::SystemException,
00428                    PortableServer::POA::ServantAlreadyActive,
00429                    PortableServer::POA::ObjectAlreadyActive,
00430                    PortableServer::POA::WrongPolicy))
00431 {
00432   this->TAO_Regular_POA::activate_object_with_id (id,
00433                                           p_servant
00434                                           ACE_ENV_ARG_PARAMETER);
00435   ACE_CHECK;
00436 }
00437 
00438 void
00439 TAO_GOA::deactivate_object (const PortableServer::ObjectId &oid
00440                                ACE_ENV_ARG_DECL)
00441   ACE_THROW_SPEC ((CORBA::SystemException,
00442                    PortableServer::POA::ObjectNotActive,
00443                    PortableServer::POA::WrongPolicy))
00444 {
00445   this->TAO_Regular_POA::deactivate_object (oid
00446                                     ACE_ENV_ARG_PARAMETER);
00447   ACE_CHECK;
00448 }
00449 
00450 CORBA::Object_ptr
00451 TAO_GOA::create_reference (const char *intf
00452                               ACE_ENV_ARG_DECL)
00453   ACE_THROW_SPEC ((CORBA::SystemException,
00454                    PortableServer::POA::WrongPolicy))
00455 {
00456   CORBA::Object_ptr obj =
00457     this->TAO_Regular_POA::create_reference (intf
00458                                      ACE_ENV_ARG_PARAMETER);
00459   ACE_CHECK_RETURN (obj);
00460   return obj;
00461 }
00462 
00463 CORBA::Object_ptr
00464 TAO_GOA::create_reference_with_id (const PortableServer::ObjectId &oid,
00465                                    const char *intf
00466                                    ACE_ENV_ARG_DECL)
00467   ACE_THROW_SPEC ((CORBA::SystemException))
00468 {
00469   CORBA::Object_ptr obj =
00470     this->TAO_Regular_POA::create_reference_with_id (oid,
00471                                              intf
00472                                              ACE_ENV_ARG_PARAMETER);
00473   ACE_CHECK_RETURN (obj);
00474   return obj;
00475 }
00476 
00477 PortableServer::ObjectId *
00478 TAO_GOA::servant_to_id (PortableServer::Servant p_servant
00479                            ACE_ENV_ARG_DECL)
00480   ACE_THROW_SPEC ((CORBA::SystemException,
00481                    PortableServer::POA::ServantNotActive,
00482                    PortableServer::POA::WrongPolicy))
00483 {
00484   PortableServer::ObjectId *object_id =
00485     this->TAO_Regular_POA::servant_to_id (p_servant
00486                                   ACE_ENV_ARG_PARAMETER);
00487   ACE_CHECK_RETURN (object_id);
00488   return object_id;
00489 }
00490 
00491 CORBA::Object_ptr
00492 TAO_GOA::servant_to_reference (PortableServer::Servant p_servant
00493                                   ACE_ENV_ARG_DECL)
00494   ACE_THROW_SPEC ((CORBA::SystemException,
00495                    PortableServer::POA::ServantNotActive,
00496                    PortableServer::POA::WrongPolicy))
00497 {
00498   CORBA::Object_ptr obj =
00499     this->TAO_Regular_POA::servant_to_reference (p_servant
00500                                          ACE_ENV_ARG_PARAMETER);
00501   ACE_CHECK_RETURN (obj);
00502   return obj;
00503 }
00504 
00505 
00506 PortableServer::Servant
00507 TAO_GOA::reference_to_servant (CORBA::Object_ptr reference
00508                                   ACE_ENV_ARG_DECL)
00509   ACE_THROW_SPEC ((CORBA::SystemException,
00510                    PortableServer::POA::ObjectNotActive,
00511                    PortableServer::POA::WrongAdapter,
00512                    PortableServer::POA::WrongPolicy))
00513 {
00514   PortableServer::Servant servant =
00515     this->TAO_Regular_POA::reference_to_servant (reference
00516                                          ACE_ENV_ARG_PARAMETER);
00517   ACE_CHECK_RETURN (servant);
00518   return servant;
00519 }
00520 
00521 PortableServer::ObjectId *
00522 TAO_GOA::reference_to_id (CORBA::Object_ptr reference
00523                              ACE_ENV_ARG_DECL)
00524   ACE_THROW_SPEC ((CORBA::SystemException,
00525                    PortableServer::POA::WrongAdapter,
00526                    PortableServer::POA::WrongPolicy))
00527 {
00528   PortableServer::ObjectId *object_id =
00529     this->TAO_Regular_POA::reference_to_id (reference
00530                                     ACE_ENV_ARG_PARAMETER);
00531   ACE_CHECK_RETURN (object_id);
00532   return object_id;
00533 }
00534 
00535 PortableServer::Servant
00536 TAO_GOA::id_to_servant (const PortableServer::ObjectId &oid
00537                            ACE_ENV_ARG_DECL)
00538   ACE_THROW_SPEC ((CORBA::SystemException,
00539                    PortableServer::POA::ObjectNotActive,
00540                    PortableServer::POA::WrongPolicy))
00541 {
00542   PortableServer::Servant servant =
00543     this->TAO_Regular_POA::id_to_servant (oid
00544                                   ACE_ENV_ARG_PARAMETER);
00545   ACE_CHECK_RETURN (servant);
00546   return servant;
00547 }
00548 
00549 CORBA::Object_ptr
00550 TAO_GOA::id_to_reference (const PortableServer::ObjectId &oid
00551                              ACE_ENV_ARG_DECL)
00552   ACE_THROW_SPEC ((CORBA::SystemException,
00553                    PortableServer::POA::ObjectNotActive,
00554                    PortableServer::POA::WrongPolicy))
00555 {
00556   CORBA::Object_ptr obj =
00557     this->TAO_Regular_POA::id_to_reference (oid
00558                                     ACE_ENV_ARG_PARAMETER);
00559   ACE_CHECK_RETURN (obj);
00560   return obj;
00561 }
00562 
00563 CORBA::OctetSeq *
00564 TAO_GOA::id (ACE_ENV_SINGLE_ARG_DECL)
00565   ACE_THROW_SPEC ((CORBA::SystemException))
00566 {
00567   return this->TAO_Regular_POA::id (ACE_ENV_SINGLE_ARG_PARAMETER);
00568 }
00569 
00570 int
00571 TAO_GOA::find_group_component (const CORBA::Object_ptr the_ref,
00572                                PortableGroup::TagGroupTaggedComponent &group)
00573 {
00574   const TAO_MProfile& profiles = the_ref->_stubobj ()->base_profiles ();
00575   const TAO_Profile* profile;
00576   CORBA::ULong slot;
00577 
00578   // Iterate through the tagged profiles, and
00579   // create acceptors for the multicast ones.
00580   slot = 0;
00581   while (0 != (profile = profiles.get_profile (slot)))
00582     {
00583       if (this->find_group_component_in_profile (profile, group) == 0)
00584         return 0;
00585 
00586       ++slot;
00587     }
00588 
00589   // Not found.
00590   return -1;
00591 }
00592 
00593 int
00594 TAO_GOA::find_group_component_in_profile (const TAO_Profile* profile,
00595                                           PortableGroup::TagGroupTaggedComponent &group)
00596 {
00597   // Iterate through the tagged components looking for
00598   // group tag.
00599   const TAO_Tagged_Components& components = profile->tagged_components ();
00600 
00601   IOP::TaggedComponent tagged_component;
00602   tagged_component.tag = IOP::TAG_GROUP;
00603 
00604   // Try to find it.
00605   if (components.get_component (tagged_component) == 0)
00606     return -1;
00607 
00608   // Found it.
00609   const CORBA::Octet *buf =
00610     tagged_component.component_data.get_buffer ();
00611 
00612   TAO_InputCDR in_cdr (reinterpret_cast <const char*> (buf),
00613                        tagged_component.component_data.length ());
00614 
00615   // Extract the Byte Order.
00616   CORBA::Boolean byte_order;
00617   if ((in_cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0)
00618     return -1;
00619   in_cdr.reset_byte_order (static_cast <int> (byte_order));
00620 
00621   if ((in_cdr >> group) == 0)
00622     return -1;
00623 
00624   return 0;
00625 }
00626 
00627 int
00628 TAO_GOA::create_group_acceptors (CORBA::Object_ptr the_ref,
00629                                  TAO_PortableGroup_Acceptor_Registry &acceptor_registry,
00630                                  TAO_ORB_Core &orb_core
00631                                  ACE_ENV_ARG_DECL)
00632 {
00633   const TAO_MProfile& profiles = the_ref->_stubobj ()->base_profiles ();
00634   const TAO_Profile* profile;
00635   CORBA::ULong slot;
00636   int num = 0;
00637 
00638   // Iterate through the tagged profiles, and
00639   // create acceptors for the multicast ones.
00640   slot = 0;
00641   while (0 != (profile = profiles.get_profile (slot)))
00642     {
00643       if (profile->supports_multicast ())
00644         {
00645           acceptor_registry.open (profile,
00646                                   orb_core
00647                                   ACE_ENV_ARG_PARAMETER);
00648           ACE_CHECK_RETURN (0);
00649           ++num;
00650         }
00651 
00652       ++slot;
00653     }
00654 
00655   // Return the number of acceptors registered.
00656   return num;
00657 }
00658 
00659 void
00660 TAO_GOA::associate_group_with_ref (
00661       CORBA::Object_ptr group_ref,
00662       CORBA::Object_ptr obj_ref
00663       ACE_ENV_ARG_DECL)
00664     ACE_THROW_SPEC ((CORBA::SystemException,
00665                      PortableGroup::NotAGroupObject))
00666 {
00667   // Find the Group Component so that we can extract the Group ID.
00668   PortableGroup::TagGroupTaggedComponent *tmp_group_id;
00669   ACE_NEW_THROW_EX (tmp_group_id,
00670                     PortableGroup::TagGroupTaggedComponent,
00671                     CORBA::NO_MEMORY (
00672                       CORBA::SystemException::_tao_minor_code (
00673                         TAO::VMCID,
00674                         ENOMEM),
00675                       CORBA::COMPLETED_NO));
00676   ACE_CHECK;
00677 
00678   PortableGroup::TagGroupTaggedComponent_var group_id = tmp_group_id;
00679 
00680   if (this->find_group_component (group_ref, group_id.inout ()) != 0)
00681     {
00682       // Group component wasn't found.  The group reference
00683       // that was passed in must be bogus.
00684       ACE_THROW (PortableGroup::NotAGroupObject ());
00685     }
00686 
00687   PortableGroup_Request_Dispatcher *rd =
00688     dynamic_cast <PortableGroup_Request_Dispatcher*>(
00689       this->orb_core_.request_dispatcher());
00690 
00691   // Create the acceptors necessary to receive requests for the
00692   // specified group reference.
00693   this->create_group_acceptors (group_ref,
00694                                 rd->acceptor_registry_,
00695                                 this->orb_core_
00696                                 ACE_ENV_ARG_PARAMETER);
00697 
00698   ACE_CHECK;
00699 
00700 
00701   // Add a mapping from GroupId to Object key in the PortableGroup
00702   const TAO::ObjectKey &key =
00703     obj_ref->_stubobj ()->profile_in_use ()->object_key ();
00704   rd->group_map_.add_groupid_objectkey_pair (group_id._retn (),
00705                                              key
00706                                              ACE_ENV_ARG_PARAMETER);
00707   ACE_CHECK;
00708 
00709 }
00710 
00711 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 14:03:33 2006 for TAO_PortableGroup by doxygen 1.3.6