Root_POA.cpp

Go to the documentation of this file.
00001 // $Id: Root_POA.cpp 81663 2008-05-09 12:43:47Z johnnyw $
00002 
00003 #include "tao/PortableServer/Root_POA.h"
00004 #include "tao/PortableServer/Regular_POA.h"
00005 
00006 #include "tao/PortableServer/ThreadPolicy.h"
00007 #include "tao/PortableServer/LifespanPolicy.h"
00008 #include "tao/PortableServer/IdAssignmentPolicy.h"
00009 #include "tao/PortableServer/IdUniquenessPolicy.h"
00010 #include "tao/PortableServer/ImplicitActivationPolicy.h"
00011 #include "tao/PortableServer/RequestProcessingPolicy.h"
00012 #include "tao/PortableServer/ServantRetentionPolicy.h"
00013 #include "tao/PortableServer/Active_Object_Map.h"
00014 #include "tao/PortableServer/Default_Acceptor_Filter.h"
00015 #include "tao/PortableServer/ORT_Adapter.h"
00016 #include "tao/PortableServer/ORT_Adapter_Factory.h"
00017 #include "tao/PortableServer/POA_Current_Impl.h"
00018 #include "tao/PortableServer/Servant_Upcall.h"
00019 #include "tao/PortableServer/AdapterActivatorC.h"
00020 #include "tao/PortableServer/Non_Servant_Upcall.h"
00021 #include "tao/PortableServer/POAManager.h"
00022 #include "tao/PortableServer/POAManagerFactory.h"
00023 #include "tao/PortableServer/ServantManagerC.h"
00024 #include "tao/PortableServer/poa_macros.h"
00025 #include "tao/PortableServer/POA_Guard.h"
00026 #include "tao/PortableServer/Creation_Time.h"
00027 #include "tao/PortableServer/RequestProcessingStrategy.h"
00028 #include "tao/PortableServer/LifespanStrategy.h"
00029 #include "tao/PortableServer/IdUniquenessStrategy.h"
00030 #include "tao/PortableServer/IdAssignmentStrategy.h"
00031 #include "tao/PortableServer/ServantRetentionStrategy.h"
00032 #include "tao/PortableServer/ImplicitActivationStrategy.h"
00033 #include "tao/PortableServer/ThreadStrategy.h"
00034 #include "tao/PortableServer/Acceptor_Filter_Factory.h"
00035 #include "tao/PortableServer/Network_Priority_Hook.h"
00036 
00037 #include "tao/StringSeqC.h"
00038 #include "tao/PortableInterceptorC.h"
00039 #include "tao/PolicyC.h"
00040 #include "tao/ORB_Core.h"
00041 #include "tao/ORB.h"
00042 #include "tao/Server_Strategy_Factory.h"
00043 #include "tao/Acceptor_Registry.h"
00044 #include "tao/Thread_Lane_Resources.h"
00045 #include "tao/Exception.h"
00046 #include "tao/Stub.h"
00047 #include "tao/Profile.h"
00048 #include "tao/TSS_Resources.h"
00049 #include "tao/IORInterceptor_Adapter.h"
00050 #include "tao/debug.h"
00051 
00052 // auto_ptr class
00053 #include "ace/Auto_Ptr.h"
00054 #include "ace/Dynamic_Service.h"
00055 #include "ace/OS_NS_netdb.h"
00056 #include "ace/OS_NS_string.h"
00057 #include "ace/OS_NS_unistd.h"
00058 #include "ace/Log_Msg.h"
00059 
00060 #if !defined (__ACE_INLINE__)
00061 # include "tao/PortableServer/Root_POA.inl"
00062 #endif /* ! __ACE_INLINE__ */
00063 
00064 ACE_RCSID (PortableServer,
00065            Root_POA,
00066            "$Id: Root_POA.cpp 81663 2008-05-09 12:43:47Z johnnyw $")
00067 
00068 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00069 
00070 // This is the TAO_Object_key-prefix that is appended to all TAO Object keys.
00071 // It's an array of octets representing ^t^a^o/0 in octal.
00072 CORBA::Octet const
00073 TAO_Root_POA::objectkey_prefix [TAO_Root_POA::TAO_OBJECTKEY_PREFIX_SIZE] = {
00074   024, // octal for ^t
00075   001, // octal for ^a
00076   017, // octal for ^o
00077   000
00078 };
00079 
00080 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
00081 
00082 PortableServer::ThreadPolicy_ptr
00083 TAO_Root_POA::create_thread_policy (PortableServer::ThreadPolicyValue value)
00084 {
00085   TAO::Portable_Server::ThreadPolicy *policy = 0;
00086   ACE_NEW_THROW_EX (policy,
00087                     TAO::Portable_Server::ThreadPolicy (value),
00088                     CORBA::NO_MEMORY ());
00089 
00090   return policy;
00091 }
00092 
00093 #endif /* TAO_HAS_MINIMUM_POA == 0 && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO) */
00094 
00095 #if !defined (CORBA_E_MICRO)
00096 
00097 PortableServer::LifespanPolicy_ptr
00098 TAO_Root_POA::create_lifespan_policy (PortableServer::LifespanPolicyValue value)
00099 {
00100   TAO::Portable_Server::LifespanPolicy *policy = 0;
00101   ACE_NEW_THROW_EX (policy,
00102                     TAO::Portable_Server::LifespanPolicy (value),
00103                     CORBA::NO_MEMORY ());
00104 
00105   return policy;
00106 }
00107 
00108 #endif
00109 
00110 #if !defined (CORBA_E_MICRO)
00111 PortableServer::IdUniquenessPolicy_ptr
00112 TAO_Root_POA::create_id_uniqueness_policy (PortableServer::IdUniquenessPolicyValue value)
00113 {
00114   TAO::Portable_Server::IdUniquenessPolicy *policy = 0;
00115   ACE_NEW_THROW_EX (policy,
00116                     TAO::Portable_Server::IdUniquenessPolicy (value),
00117                     CORBA::NO_MEMORY ());
00118 
00119   return policy;
00120 }
00121 #endif
00122 
00123 #if !defined (CORBA_E_MICRO)
00124 PortableServer::IdAssignmentPolicy_ptr
00125 TAO_Root_POA::create_id_assignment_policy (PortableServer::IdAssignmentPolicyValue value)
00126 {
00127   TAO::Portable_Server::IdAssignmentPolicy *policy = 0;
00128   ACE_NEW_THROW_EX (policy,
00129                     TAO::Portable_Server::IdAssignmentPolicy (value),
00130                     CORBA::NO_MEMORY ());
00131 
00132   return policy;
00133 }
00134 #endif
00135 
00136 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
00137 
00138 PortableServer::ImplicitActivationPolicy_ptr
00139 TAO_Root_POA::create_implicit_activation_policy (PortableServer::ImplicitActivationPolicyValue value)
00140 {
00141   TAO::Portable_Server::ImplicitActivationPolicy *policy = 0;
00142   ACE_NEW_THROW_EX (policy,
00143                     TAO::Portable_Server::ImplicitActivationPolicy (value),
00144                     CORBA::NO_MEMORY ());
00145 
00146   return policy;
00147 }
00148 
00149 PortableServer::ServantRetentionPolicy_ptr
00150 TAO_Root_POA::create_servant_retention_policy (PortableServer::ServantRetentionPolicyValue value)
00151 {
00152   TAO::Portable_Server::ServantRetentionPolicy *policy = 0;
00153   ACE_NEW_THROW_EX (policy,
00154                     TAO::Portable_Server::ServantRetentionPolicy (value),
00155                     CORBA::NO_MEMORY ());
00156 
00157   return policy;
00158 }
00159 
00160 PortableServer::RequestProcessingPolicy_ptr
00161 TAO_Root_POA::create_request_processing_policy (PortableServer::RequestProcessingPolicyValue value)
00162 {
00163   TAO::Portable_Server::RequestProcessingPolicy *policy = 0;
00164   ACE_NEW_THROW_EX (policy,
00165                     TAO::Portable_Server::RequestProcessingPolicy (value),
00166                     CORBA::NO_MEMORY ());
00167 
00168   return policy;
00169 }
00170 
00171 #endif /* TAO_HAS_MINIMUM_POA == 0 */
00172 
00173 void
00174 TAO_Root_POA::set_obj_ref_factory (
00175   PortableInterceptor::ObjectReferenceFactory *current_factory)
00176 {
00177   TAO::ORT_Adapter *adapter = this->ORT_adapter ();
00178 
00179   if (adapter)
00180     {
00181       // Activate a different factory
00182       this->ort_adapter_->set_obj_ref_factory (current_factory);
00183     }
00184 }
00185 
00186 TAO_Root_POA::TAO_Root_POA (const TAO_Root_POA::String &name,
00187                             PortableServer::POAManager_ptr poa_manager,
00188                             const TAO_POA_Policy_Set &policies,
00189                             TAO_Root_POA *parent,
00190                             ACE_Lock &lock,
00191                             TAO_SYNCH_MUTEX &thread_lock,
00192                             TAO_ORB_Core &orb_core,
00193                             TAO_Object_Adapter *object_adapter)
00194   : name_ (name),
00195     poa_manager_ (* (dynamic_cast <TAO_POA_Manager*> (poa_manager))),
00196 
00197 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
00198     poa_manager_factory_ (* (object_adapter->poa_manager_factory_)),
00199 #endif
00200 
00201     tagged_component_ (),
00202     tagged_component_id_ (),
00203     profile_id_array_ (0),
00204     policies_ (policies),
00205     ort_adapter_ (0),
00206     adapter_state_ (PortableInterceptor::HOLDING),
00207     network_priority_hook_ (0),
00208 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
00209     adapter_activator_ (),
00210 #endif /* TAO_HAS_MINIMUM_POA == 0 */
00211     children_ (),
00212     lock_ (lock),
00213     orb_core_ (orb_core),
00214     object_adapter_ (object_adapter),
00215     cleanup_in_progress_ (false),
00216     outstanding_requests_ (0),
00217     outstanding_requests_condition_ (thread_lock),
00218     wait_for_completion_pending_ (0),
00219     waiting_destruction_ (false),
00220     servant_deactivation_condition_ (thread_lock),
00221 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
00222     filter_factory_ (0),
00223 #endif
00224     caller_key_to_object_ (0),
00225     servant_for_key_to_object_ (0)
00226 {
00227   // Since we are keeping a reference to a POAManager, we need to
00228   // increment the reference count but we do this safely.
00229   PortableServer::POAManager_var pm_guard (
00230     PortableServer::POAManager::_duplicate(&this->poa_manager_));
00231 
00232   // Parse the policies that are used in the critical path in
00233   // a cache.
00234   this->cached_policies_.update (this->policies_);
00235 
00236 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
00237   this->filter_factory_
00238     = ACE_Dynamic_Service<TAO_Acceptor_Filter_Factory>::instance (
00239         "TAO_Acceptor_Filter_Factory");
00240 #endif
00241 
00242   this->network_priority_hook_
00243     = ACE_Dynamic_Service<TAO_Network_Priority_Hook>::instance (
00244         "TAO_Network_Priority_Hook");
00245 
00246   if (this->network_priority_hook_ != 0)
00247     {
00248       this->network_priority_hook_->update_network_priority (
00249         *this, this->policies_);
00250     }
00251 
00252 #if (TAO_HAS_MINIMUM_POA == 1)
00253   // If this is the RootPOA, set the value of the ImplicitActivationPolicy
00254   // to IMPLICIT_ACTIVATION since it is impossible to pass the policy
00255   // as it is not compiled into the library.
00256   //
00257   // If the ImplicitActivationPolicy policy is ever compiled in the
00258   // minimum POA builds, remove this code and remove the guards
00259   // in Object_Adapter.cpp when changing the default policy for the
00260   // RootPOA.
00261   if (ACE_OS::strcmp (this->name_.c_str (),
00262                       TAO_DEFAULT_ROOTPOA_NAME) == 0)
00263     {
00264       this->cached_policies_.implicit_activation
00265         (PortableServer::IMPLICIT_ACTIVATION);
00266     }
00267 #endif /* TAO_HAS_MINIMUM_POA == 1 */
00268 
00269   // Set the active strategies to be used by this POA
00270   this->active_policy_strategies_.update (this->cached_policies_,
00271                                           this);
00272   TAO::Portable_Server::Active_Policy_Strategies_Cleanup_Guard aps_cleanup_guard (
00273     &this->active_policy_strategies_);
00274 
00275   // Set the folded name of this POA.
00276   this->set_folded_name (parent);
00277 
00278   // Register self with manager.
00279   int result = this->poa_manager_.register_poa (this);
00280   if (result != 0)
00281     {
00282       throw ::CORBA::OBJ_ADAPTER ();
00283     }
00284 
00285   // Add self to Object Adapter class.
00286   result =
00287     this->object_adapter ().bind_poa (this->folded_name_,
00288                                       this,
00289                                       this->system_name_.out ());
00290   if (result != 0)
00291     {
00292       // Remove from POA Manager in case of errors. No checks of
00293       // further errors...
00294       this->poa_manager_.remove_poa (this);
00295 
00296       throw ::CORBA::OBJ_ADAPTER ();
00297     }
00298 
00299   // Set the id for this POA.
00300   this->set_id (parent);
00301 
00302   // Notify the Lifespan strategy of our startup
00303   try
00304     {
00305       this->active_policy_strategies_.lifespan_strategy()->notify_startup ();
00306     }
00307   catch (const ::CORBA::Exception&)
00308     {
00309       this->poa_manager_.remove_poa (this);
00310       this->object_adapter ().unbind_poa (this,
00311                                           this->folded_name_,
00312                                           this->system_name_.in ());
00313       throw;
00314     }
00315 
00316   // Now when everything is fine we can release the quards.
00317   pm_guard._retn ();
00318   aps_cleanup_guard._retn ();
00319 }
00320 
00321 TAO_Root_POA::~TAO_Root_POA (void)
00322 {
00323   this->poa_manager_._remove_ref();
00324 }
00325 
00326 void
00327 TAO_Root_POA::complete_destruction_i (void)
00328 {
00329   bool doing_complete_destruction =
00330     this->waiting_destruction_ != false;
00331 
00332   // No longer awaiting destruction.
00333   this->waiting_destruction_ = false;
00334 
00335   PortableServer::POA_var poa;
00336   TAO::ORT_Array my_array_obj_ref_template;
00337   TAO::ORT_Adapter *ort_adapter = 0;
00338   if (doing_complete_destruction)
00339     {
00340       ort_adapter =
00341         this->ORT_adapter_i ();
00342 
00343       // In case no ORT library is linked we get zero.
00344       if (ort_adapter != 0)
00345         {
00346           // Get the ObjectReferenceTemplate.
00347           PortableInterceptor::ObjectReferenceTemplate * const ort =
00348             ort_adapter->get_adapter_template ();
00349 
00350           // Add it to the sequence of object reference templates, we
00351           // just notify for ourselves that we are now non_existent,
00352           // our childs will do it for themselves.
00353           my_array_obj_ref_template.size (1);
00354           my_array_obj_ref_template[0] = ort;
00355         }
00356 
00357       poa = PortableServer::POA::_duplicate (this);
00358     }
00359 
00360   // Remove POA from the POAManager.
00361   if (this->poa_manager_.remove_poa (this) != 0)
00362     throw ::CORBA::OBJ_ADAPTER ();
00363 
00364   // Remove POA from the Object Adapter.
00365   int result = this->object_adapter ().unbind_poa (this,
00366                                                    this->folded_name_,
00367                                                    this->system_name_.in ());
00368   if (result != 0)
00369     throw ::CORBA::OBJ_ADAPTER ();
00370 
00371   // Cleanup all strategies
00372   this->active_policy_strategies_.cleanup ();
00373 
00374   // Forced cleanup.  The new memory management scheme is evil and can
00375   // lead to reference deadlock, i.e., POA holds object A, but POA
00376   // cannot die because object A hold POA.
00377   {
00378     //
00379     // If new things are added to this cleanup code, make sure to move
00380     // the minimum CORBA #define after the declaration of
00381     // <non_servant_upcall>.
00382     //
00383 
00384 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
00385 
00386     // ATTENTION: Trick locking here, see class header for details
00387     TAO::Portable_Server::Non_Servant_Upcall non_servant_upcall (*this);
00388     ACE_UNUSED_ARG (non_servant_upcall);
00389 
00390     this->adapter_activator_ = PortableServer::AdapterActivator::_nil ();
00391 
00392 #endif /* TAO_HAS_MINIMUM_POA == 0 */
00393 
00394   }
00395 
00396   ::CORBA::release (this);
00397 
00398   if (doing_complete_destruction)
00399     {
00400       this->adapter_state_ = PortableInterceptor::NON_EXISTENT;
00401 
00402       this->adapter_state_changed (my_array_obj_ref_template,
00403                                    this->adapter_state_);
00404 
00405       if (ort_adapter != 0)
00406         {
00407           ort_adapter->release (my_array_obj_ref_template[0]);
00408 
00409           TAO::ORT_Adapter_Factory *ort_factory =
00410             this->ORT_adapter_factory ();
00411 
00412           ort_factory->destroy (ort_adapter);
00413 
00414           this->ort_adapter_ = 0;
00415         }
00416     }
00417 }
00418 
00419 #if ! defined (CORBA_E_MICRO)
00420 PortableServer::POA_ptr
00421 TAO_Root_POA::create_POA_i (const char *adapter_name,
00422                             PortableServer::POAManager_ptr poa_manager,
00423                             const CORBA::PolicyList &policies)
00424 {
00425   // Initialize a TAO_POA_Policy_Set instance so that it contains the
00426   // default POA policies.
00427   TAO_POA_Policy_Set tao_policies (this->object_adapter ().default_poa_policies ());
00428 
00429   // Merge policies from the ORB level.
00430   this->object_adapter ().validator ().merge_policies (tao_policies.policies ());
00431 
00432   // Merge in any policies that the user may have specified.
00433   tao_policies.merge_policies (policies);
00434 
00435   // If any of the policy objects specified are not valid for the ORB
00436   // implementation, if conflicting policy objects are specified, or
00437   // if any of the specified policy objects require prior
00438   // administrative action that has not been performed, an
00439   // InvalidPolicy exception is raised containing the index in the
00440   // policies parameter value of the first offending policy object.
00441   tao_policies.validate_policies (this->object_adapter ().validator (),
00442                                   this->orb_core_);
00443 
00444   // If the poa_manager parameter is null, a new POAManager object is
00445   // created and associated with the new POA. Otherwise, the specified
00446   // POAManager object is associated with the new POA. The POAManager
00447   // object can be obtained using the attribute name the_POAManager.
00448 
00449   PortableServer::POAManager_var the_poa_manager;
00450 
00451   if (CORBA::is_nil (poa_manager))
00452     {
00453 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT)
00454 
00455       PortableServer::POA_var poa = PortableServer::POA::_duplicate (this);
00456       PortableServer::POA_var root_poa;
00457 
00458       // Find the RootPOA by traversing the POA hierarchy until the
00459       // RootPOA is reached.  The RootPOA has no parent.
00460       while (!CORBA::is_nil (poa.in ()))
00461       {
00462         root_poa = poa;
00463         poa = poa->the_parent ();
00464       }
00465 
00466       // Get the POAManagerFactory instance owned by RootPOA.
00467       PortableServer::POAManagerFactory_var tao_poa_manager_factory
00468         = root_poa->the_POAManagerFactory ();
00469 
00470       CORBA::PolicyList empty_policies;
00471 
00472       // The POAManager name will be generated when the POAManager instance
00473       // is created.
00474       the_poa_manager
00475         = tao_poa_manager_factory->create_POAManager (0, empty_policies);
00476 #else
00477 
00478       PortableServer::POAManager_ptr the_poa_manager_ptr;
00479       ACE_NEW_THROW_EX (the_poa_manager_ptr,
00480                         TAO_POA_Manager (this->object_adapter (), 0),
00481                         CORBA::NO_MEMORY ());
00482       the_poa_manager = the_poa_manager_ptr;
00483 #endif /* TAO_HAS_MINIMUM_POA == 0 && ! CORBA_E_COMPACT) */
00484 
00485     }
00486   else
00487     {
00488       the_poa_manager = PortableServer::POAManager::_duplicate (poa_manager);
00489     }
00490 
00491   PortableServer::POA_var poa = this->create_POA_i (adapter_name,
00492                                                     the_poa_manager.in (),
00493                                                     tao_policies);
00494 
00495   return poa._retn ();
00496 }
00497 #endif /* !CORBA_E_MICRO */
00498 
00499 #if ! defined (CORBA_E_MICRO)
00500 TAO_Root_POA *
00501 TAO_Root_POA::new_POA (const String &name,
00502                        PortableServer::POAManager_ptr poa_manager,
00503                        const TAO_POA_Policy_Set &policies,
00504                        TAO_Root_POA *parent,
00505                        ACE_Lock &lock,
00506                        TAO_SYNCH_MUTEX &thread_lock,
00507                        TAO_ORB_Core &orb_core,
00508                        TAO_Object_Adapter *object_adapter)
00509 {
00510   TAO_Regular_POA *poa = 0;
00511 
00512   ACE_NEW_THROW_EX (poa,
00513                     TAO_Regular_POA (name,
00514                              poa_manager,
00515                              policies,
00516                              parent,
00517                              lock,
00518                              thread_lock,
00519                              orb_core,
00520                              object_adapter),
00521                     CORBA::NO_MEMORY ());
00522 
00523   return poa;
00524 }
00525 
00526 PortableServer::POA_ptr
00527 TAO_Root_POA::create_POA_i (const TAO_Root_POA::String &adapter_name,
00528                             PortableServer::POAManager_ptr poa_manager,
00529                             const TAO_POA_Policy_Set &policies)
00530 {
00531   // This operaton creates a new POA as a child of the target POA. The
00532   // specified name identifies the new POA with respect to other POAs
00533   // with the same parent POA. If the target POA already has a child
00534   // POA with the specified name, the AdapterAlreadyExists exception
00535   // is raised.
00536   // Child was found
00537   if (this->children_.find (adapter_name) != -1)
00538     {
00539       throw PortableServer::POA::AdapterAlreadyExists ();
00540     }
00541 
00542   //
00543   // Child was not found.  Create one.
00544   //
00545 
00546   // The specified policy objects are associated with the POA and used
00547   // to control its behavior. The policy objects are effectively
00548   // copied before this operation returns, so the application is free
00549   // to destroy them while the POA is in use. Policies are not
00550   // inherited from the parent POA.
00551   TAO_Root_POA * poa = this->new_POA (adapter_name,
00552                                       poa_manager,
00553                                       policies,
00554                                       this,
00555                                       this->object_adapter ().lock (),
00556                                       this->object_adapter ().thread_lock (),
00557                                       this->orb_core_,
00558                                       this->object_adapter_);
00559 
00560   // Give ownership of the new map to the POA_var.  Note, that it
00561   // is important for the POA_var to take ownership before
00562   // checking for exception since we may need to delete the new map.
00563   PortableServer::POA_var new_poa = poa;
00564 
00565   // Check for exception in construction of the POA.
00566 
00567   // Add to children map
00568   if (this->children_.bind (adapter_name, poa) != 0)
00569     {
00570       throw ::CORBA::OBJ_ADAPTER ();
00571     }
00572 
00573   // Increment the reference count on the child POA since the children
00574   // map must retain ownership.  Do so immediately before any other
00575   // operations to prevent memory cleanup problems induced from
00576   // errors below.
00577   poa->_add_ref ();
00578 
00579   // Iterate over the registered IOR interceptors so that they may be
00580   // given the opportunity to add tagged components to the profiles
00581   // for this servant.
00582   poa->establish_components ();
00583 
00584   // Note: Creating a POA using a POA manager that is in the active
00585   // state can lead to race conditions if the POA supports preexisting
00586   // objects, because the new POA may receive a request before its
00587   // adapter activator, servant manager, or default servant have been
00588   // initialized. These problems do not occur if the POA is created by
00589   // an adapter activator registered with a parent of the new POA,
00590   // because requests are queued until the adapter activator
00591   // returns. To avoid these problems when a POA must be explicitly
00592   // initialized, the application can initialize the POA by invoking
00593   // find_POA with a TRUE activate parameter.
00594 
00595   // Everything is fine. Don't let the POA_var release the
00596   // implementation.
00597   return new_poa._retn ();
00598 }
00599 #endif
00600 
00601 #if ! defined (CORBA_E_MICRO)
00602 PortableServer::POA_ptr
00603 TAO_Root_POA::find_POA (const char *adapter_name,
00604                         CORBA::Boolean activate_it)
00605 {
00606   // Lock access for the duration of this transaction.
00607   TAO_POA_GUARD_RETURN (0);
00608 
00609   TAO_Root_POA *poa = this->find_POA_i (adapter_name, activate_it);
00610 
00611   return PortableServer::POA::_duplicate (poa);
00612 }
00613 #endif
00614 
00615 #if ! defined (CORBA_E_MICRO)
00616 TAO_Root_POA *
00617 TAO_Root_POA::find_POA_i (const ACE_CString &child_name,
00618                           CORBA::Boolean activate_it)
00619 {
00620   TAO_Root_POA *child = 0;
00621   int result = this->children_.find (child_name, child);
00622 
00623 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT)
00624 
00625   if (result != 0)
00626     {
00627       if (activate_it)
00628         {
00629           if (!CORBA::is_nil (this->adapter_activator_.in ()))
00630             {
00631               // Check our state
00632               this->check_state ();
00633 
00634               CORBA::Boolean success = false;
00635               try
00636                 {
00637                   // ATTENTION: Trick locking here, see class header for details
00638                   TAO::Portable_Server::Non_Servant_Upcall non_servant_upcall (
00639                     *this);
00640                   ACE_UNUSED_ARG (non_servant_upcall);
00641 
00642                   // When unknown_adapter gives a system exception, the POA
00643                   // should raise OBJ_ADAPTER with standard minor code 1.
00644                   // See 11.3.9.2 of the Corba spec
00645                   success =
00646                     this->adapter_activator_->unknown_adapter (
00647                       this,
00648                       child_name.c_str ());
00649                 }
00650               catch (const ::CORBA::SystemException&)
00651                 {
00652                   throw ::CORBA::OBJ_ADAPTER (CORBA::OMGVMCID | 1,
00653                                               CORBA::COMPLETED_NO);
00654                 }
00655 
00656               if (success)
00657                 {
00658                   result = this->children_.find (child_name,
00659                                                  child);
00660                 }
00661               else
00662                 {
00663                   result = -1;
00664                 }
00665             }
00666           else
00667             {
00668               result = -1;
00669             }
00670         }
00671       else
00672         {
00673           result = -1;
00674         }
00675     }
00676 #else
00677   ACE_UNUSED_ARG (activate_it);
00678 #endif /* TAO_HAS_MINIMUM_POA == 0 */
00679 
00680   if (result == 0)
00681     {
00682       return child;
00683     }
00684   else
00685     {
00686       // Otherwise, the AdapterNonExistent exception is raised.
00687       throw PortableServer::POA::AdapterNonExistent ();
00688     }
00689 }
00690 #endif
00691 
00692 TAO_POA_Manager &
00693 TAO_Root_POA::tao_poa_manager ()
00694 {
00695   return poa_manager_;
00696 }
00697 
00698 #if ! defined (CORBA_E_MICRO)
00699 PortableServer::POA_ptr
00700 TAO_Root_POA::create_POA (const char *adapter_name,
00701                           PortableServer::POAManager_ptr poa_manager,
00702                           const CORBA::PolicyList &policies)
00703 {
00704   // Lock access for the duration of this transaction.
00705   TAO_POA_GUARD_RETURN (0);
00706 
00707   return this->create_POA_i (adapter_name, poa_manager, policies);
00708 }
00709 #endif
00710 
00711 PortableServer::ObjectId *
00712 TAO_Root_POA::servant_to_id (PortableServer::Servant servant)
00713 {
00714   // If we had upgradeable locks, this would initially be a read lock
00715   //
00716   // Lock access for the duration of this transaction.
00717   TAO_POA_GUARD_RETURN (0);
00718 
00719   return this->servant_to_id_i (servant);
00720 }
00721 
00722 PortableServer::ObjectId *
00723 TAO_Root_POA::servant_to_user_id (PortableServer::Servant servant)
00724 {
00725   return this->active_policy_strategies_.servant_retention_strategy()->
00726     servant_to_user_id (servant);
00727 }
00728 
00729 PortableServer::Servant
00730 TAO_Root_POA::reference_to_servant (CORBA::Object_ptr reference)
00731 {
00732   // Lock access for the duration of this transaction.
00733   TAO_POA_GUARD_RETURN (0);
00734 
00735   return this->reference_to_servant_i (reference);
00736 }
00737 
00738 CORBA::Object_ptr
00739 TAO_Root_POA::servant_to_reference (PortableServer::Servant servant)
00740 {
00741   TAO_POA_GUARD_RETURN (CORBA::Object::_nil ());
00742 
00743   return this->servant_to_reference_i (servant);
00744 }
00745 
00746 PortableServer::POAList *
00747 TAO_Root_POA::the_children (void)
00748 {
00749   // Lock access for the duration of this transaction.
00750   TAO_POA_GUARD_RETURN (0);
00751 
00752   return this->the_children_i ();
00753 }
00754 
00755 
00756 PortableServer::Servant
00757 TAO_Root_POA::id_to_servant (const PortableServer::ObjectId &oid)
00758 {
00759   // Lock access for the duration of this transaction.
00760   TAO_POA_GUARD_RETURN (0);
00761 
00762   return this->id_to_servant_i (oid);
00763 }
00764 
00765 CORBA::Object_ptr
00766 TAO_Root_POA::id_to_reference (const PortableServer::ObjectId &oid)
00767 {
00768   // Lock access for the duration of this transaction.
00769   TAO_POA_GUARD_RETURN (0);
00770 
00771   return this->id_to_reference_i (oid, true);
00772 }
00773 
00774 
00775 #if ! defined (CORBA_E_MICRO)
00776 CORBA::Object_ptr
00777 TAO_Root_POA::create_reference_with_id (const PortableServer::ObjectId &id,
00778                                         const char *intf)
00779 {
00780   // Lock access for the duration of this transaction.
00781   TAO_POA_GUARD_RETURN (CORBA::Object::_nil ());
00782 
00783   return this->create_reference_with_id_i (id,
00784                                            intf,
00785                                            this->server_priority ());
00786 }
00787 #endif
00788 
00789 void
00790 TAO_Root_POA::destroy (CORBA::Boolean etherealize_objects,
00791                        CORBA::Boolean wait_for_completion)
00792 {
00793   // Lock access for the duration of this transaction.
00794   TAO::Portable_Server::POA_Guard poa_guard (*this , 0);
00795   ACE_UNUSED_ARG (poa_guard);
00796 
00797   this->destroy_i (etherealize_objects, wait_for_completion);
00798 }
00799 
00800 void
00801 TAO_Root_POA::remove_from_parent_i (void)
00802 {
00803   // The root poa has no parent, so this is a noop
00804 }
00805 
00806 void
00807 TAO_Root_POA::destroy_i (CORBA::Boolean etherealize_objects,
00808                          CORBA::Boolean wait_for_completion)
00809 {
00810   if (this->cleanup_in_progress_)
00811     return;
00812 
00813   // Is the <wait_for_completion> semantics for this thread correct?
00814   TAO_Root_POA::check_for_valid_wait_for_completions (this->orb_core (),
00815                                                       wait_for_completion);
00816 
00817   this->cleanup_in_progress_ = true;
00818 
00819   // Inform the custom servant dispatching strategy to stop the working
00820   // threads when the poa is destroyed.
00821   this->poa_deactivated_hook ();
00822 
00823   // This operation destroys the POA and all descendant POAs. The POA
00824   // so destroyed (that is, the POA with its name) may be re-created
00825   // later in the same process. (This differs from the
00826   // POAManager::deactivate operation that does not allow a
00827   // re-creation of its associated POA in the same process.)
00828 
00829   // Remove POA from the parent
00830   this->remove_from_parent_i ();
00831 
00832   TAO::ORT_Array array_obj_ref_template (1);
00833 
00834   CORBA::ULong i = 0;
00835 
00836   // Gather all ObjectReferenceTemplates and change all adapter states
00837   // to INACTIVE.
00838   for (CHILDREN::iterator iterator = this->children_.begin ();
00839        iterator != this->children_.end ();
00840        ++iterator)
00841     {
00842       TAO_Root_POA * const child_poa = (*iterator).int_id_;
00843 
00844       TAO::ORT_Adapter * const adapter = child_poa->ORT_adapter_i ();
00845 
00846       // In case no ORT library is linked we get zero.
00847       if (adapter != 0)
00848         {
00849           // Get the ObjectReferenceTemplate for the child POA.
00850           PortableInterceptor::ObjectReferenceTemplate * const ort =
00851             adapter->get_adapter_template ();
00852 
00853           // Add it to the sequence of object reference templates that
00854           // will be destroyed.
00855           array_obj_ref_template.size (1);
00856 
00857           array_obj_ref_template[0] = ort;
00858         }
00859 
00860       child_poa->adapter_state_ =
00861         PortableInterceptor::INACTIVE;
00862 
00863       // Notify the state changes to the IORInterceptors
00864       this->adapter_state_changed (array_obj_ref_template,
00865                                    PortableInterceptor::INACTIVE);
00866 
00867       if (adapter != 0)
00868         adapter->release (array_obj_ref_template[0]);
00869 
00870       ++i;
00871     }
00872 
00873   // Destroy all child POA's now.
00874   for (CHILDREN::iterator destroy_iterator = this->children_.begin ();
00875        destroy_iterator != this->children_.end ();
00876        ++destroy_iterator)
00877     {
00878       TAO_Root_POA *destroy_child_poa = (*destroy_iterator).int_id_;
00879 
00880       destroy_child_poa->destroy_i (etherealize_objects,
00881                                     wait_for_completion);
00882     }
00883 
00884   // Notify the lifespan strategy of our shutdown
00885   this->active_policy_strategies_.lifespan_strategy()->notify_shutdown ();
00886 
00887 // @todo, is the exception handling above correct, should we just fail when
00888 // the notify above fails
00889 
00890   // When a POA is destroyed, any requests that have started execution
00891   // continue to completion. Any requests that have not started
00892   // execution are processed as if they were newly arrived, that is,
00893   // the POA will attempt to cause recreation of the POA by invoking
00894   // one or more adapter activators as described in Section 3.3.3.
00895   // If the wait_for_completion parameter is TRUE, the destroy
00896   // operation will return only after all requests in process have
00897   // completed and all invocations of etherealize have
00898   // completed. Otherwise, the destroy operation returns after
00899   // destroying the POAs.
00900 
00901   this->deactivate_all_objects_i (etherealize_objects,
00902                                   wait_for_completion);
00903 
00904   // If there are no outstanding requests and that we are not in a
00905   // non-servant upcall or if we are in a non-servant upcall, make
00906   // sure we are the POA related to the non-servant upcall.
00907   TAO::Portable_Server::Non_Servant_Upcall *non_servant_upcall_in_progress =
00908     this->object_adapter ().non_servant_upcall_in_progress ();
00909   if (this->outstanding_requests_ == 0 &&
00910       (non_servant_upcall_in_progress == 0 ||
00911        &non_servant_upcall_in_progress->poa () != this))
00912     {
00913       TAO::ORT_Array my_array_obj_ref_template;
00914 
00915       TAO::ORT_Adapter * const ort_adapter =
00916         this->ORT_adapter_i ();
00917 
00918       // In case no ORT library is linked we get zero.
00919       if (ort_adapter != 0)
00920         {
00921           // Get the ObjectReferenceTemplate.
00922           PortableInterceptor::ObjectReferenceTemplate * const ort =
00923             ort_adapter->get_adapter_template ();
00924 
00925           // Add it to the sequence of object reference templates, we
00926           // just notify for ourselves that we are now non_existent,
00927           // our childs will do it for themselves.
00928           my_array_obj_ref_template.size (1);
00929           my_array_obj_ref_template[0] = ort;
00930         }
00931 
00932       // According to the ORT spec, after a POA is destroyed, its state
00933       // has to be changed to NON_EXISTENT and all the registered
00934       // interceptors are to be informed. Since, the POA is destroyed
00935       // and is released in the complete_destruction_i method, we are
00936       // trying to keep the poa still around by doing a duplicate of
00937       // it. (a hack).
00938       PortableServer::POA_var poa = PortableServer::POA::_duplicate (this);
00939 
00940       this->complete_destruction_i ();
00941 
00942       this->adapter_state_ = PortableInterceptor::NON_EXISTENT;
00943 
00944       this->adapter_state_changed (my_array_obj_ref_template,
00945                                    this->adapter_state_);
00946 
00947       if (ort_adapter != 0)
00948         {
00949           ort_adapter->release (my_array_obj_ref_template[0]);
00950 
00951           TAO::ORT_Adapter_Factory *ort_factory =
00952             this->ORT_adapter_factory ();
00953 
00954           ort_factory->destroy (ort_adapter);
00955 
00956           this->ort_adapter_ = 0;
00957         }
00958     }
00959   else
00960     {
00961       // Mark that we are ready for destruction.
00962       this->waiting_destruction_ = true;
00963     }
00964 }
00965 
00966 int
00967 TAO_Root_POA::delete_child (const TAO_Root_POA::String &child)
00968 {
00969   int result = 0;
00970 
00971   // If we are not closing down, we must remove this child from our
00972   // collection.
00973   if (!this->cleanup_in_progress_)
00974     result = this->children_.unbind (child);
00975 
00976   // Otherwise, if we are closing down, we are currently iterating
00977   // over our children and there is not need to remove this child from
00978   // our collection.
00979 
00980   return result;
00981 }
00982 
00983 PortableServer::POAList *
00984 TAO_Root_POA::the_children_i (void)
00985 {
00986   PortableServer::POAList_var children;
00987   CORBA::ULong child_current = static_cast <CORBA::ULong>
00988                                            (this->children_.current_size ());
00989   ACE_NEW_THROW_EX (children,
00990                     PortableServer::POAList (child_current),
00991                     CORBA::NO_MEMORY ());
00992 
00993   children->length (child_current);
00994 
00995   CORBA::ULong index = 0;
00996   for (CHILDREN::iterator iterator = this->children_.begin ();
00997        iterator != this->children_.end ();
00998        ++iterator, ++index)
00999     {
01000       TAO_Root_POA *child_poa = (*iterator).int_id_;
01001       children[index] = PortableServer::POA::_duplicate (child_poa);
01002     }
01003 
01004   return children._retn ();
01005 }
01006 
01007 PortableInterceptor::AdapterName *
01008 TAO_Root_POA::adapter_name_i (void)
01009 {
01010   // The adapter name is the sequence of names starting from the
01011   // RootPOA to the one whose name is requested.  The name of the
01012   // RootPOA is "RootPOA".
01013 
01014   PortableServer::POA_var poa = PortableServer::POA::_duplicate (this);
01015 
01016   CORBA::ULong len = 0;
01017 
01018   // Find the length of the adapter name sequence by traversing the
01019   // POA hierarchy until the RootPOA is reached.  The RootPOA has no
01020   // parent.
01021   while (!CORBA::is_nil (poa.in ()))
01022     {
01023       poa = poa->the_parent ();
01024       ++len;
01025     }
01026 
01027   // Empty adapter name sequence.
01028   PortableInterceptor::AdapterName *names = 0;
01029   ACE_NEW_THROW_EX (names,
01030                     PortableInterceptor::AdapterName (len),
01031                     CORBA::NO_MEMORY (
01032                       CORBA::SystemException::_tao_minor_code (
01033                         TAO::VMCID,
01034                         ENOMEM),
01035                       CORBA::COMPLETED_NO));
01036 
01037   PortableInterceptor::AdapterName_var safe_names (names);
01038 
01039   names->length (len);
01040 
01041   poa = PortableServer::POA::_duplicate (this);
01042 
01043   (*names)[0] = CORBA::string_dup ("RootPOA");
01044 
01045   // Fill in the AdapterName sequence as the POA hierarchy is
01046   // traversed.
01047   CORBA::ULong ilen = len;
01048   for (CORBA::ULong i = 1; i < len; ++i)
01049     {
01050       (*names)[--ilen] = poa->the_name ();
01051 
01052       poa = poa->the_parent ();
01053 
01054       // If this condition asserts, the POA hierarchy was modified
01055       // (i.e. reduced in size) by another thread!
01056       ACE_ASSERT ((ilen > 0 ? !CORBA::is_nil (poa.in ()) : 1));
01057     }
01058 
01059   return safe_names._retn ();
01060 }
01061 
01062 void
01063 TAO_Root_POA::add_ior_component (TAO_MProfile & mprofile,
01064                                  const IOP::TaggedComponent &component)
01065 {
01066   // Add the given tagged component to all profiles.
01067   const CORBA::ULong profile_count = mprofile.profile_count ();
01068 
01069   for (CORBA::ULong i = 0; i < profile_count; ++i)
01070     {
01071       TAO_Profile *profile = mprofile.get_profile (i);
01072 
01073       profile->add_tagged_component (component);
01074     }
01075 }
01076 
01077 void
01078 TAO_Root_POA::add_ior_component_to_profile (
01079     TAO_MProfile & mprofile,
01080     const IOP::TaggedComponent &component,
01081     IOP::ProfileId profile_id)
01082 {
01083   // Add the given tagged component to all profiles matching the given
01084   // ProfileId.
01085   bool found_profile = false;
01086 
01087   CORBA::ULong const profile_count = mprofile.profile_count ();
01088 
01089   for (CORBA::ULong i = 0; i < profile_count; ++i)
01090     {
01091       TAO_Profile *profile = mprofile.get_profile (i);
01092 
01093       if (profile->tag () == profile_id)
01094         {
01095           profile->add_tagged_component (component);
01096 
01097           found_profile = true;
01098         }
01099     }
01100 
01101   // According to the Portable Interceptor specification, we're
01102   // supposed to throw a CORBA::BAD_PARAM exception if no profile
01103   // matched the given ProfileId.
01104   if (found_profile == false)
01105     throw ::CORBA::BAD_PARAM (CORBA::OMGVMCID | 29, CORBA::COMPLETED_NO);
01106 }
01107 
01108 void
01109 TAO_Root_POA::adapter_state_changed (
01110    const TAO::ORT_Array &array_obj_ref_template,
01111    PortableInterceptor::AdapterState state)
01112 {
01113   TAO_IORInterceptor_Adapter *ior_adapter =
01114     this->orb_core_.ior_interceptor_adapter ();
01115 
01116   if (ior_adapter)
01117     {
01118       ior_adapter->adapter_state_changed (array_obj_ref_template, state);
01119     }
01120 }
01121 
01122 PortableServer::ObjectId *
01123 TAO_Root_POA::activate_object_i (PortableServer::Servant servant,
01124                                  CORBA::Short priority,
01125                                  bool &wait_occurred_restart_call)
01126 {
01127   return this->active_policy_strategies_.servant_retention_strategy()->
01128     activate_object (servant,
01129                      priority,
01130                      wait_occurred_restart_call);
01131 }
01132 
01133 PortableServer::ObjectId *
01134 TAO_Root_POA::activate_object (PortableServer::Servant servant)
01135 {
01136   while (1)
01137     {
01138       bool wait_occurred_restart_call = false;
01139 
01140       // Lock access for the duration of this transaction.
01141       TAO_POA_GUARD_RETURN (0);
01142 
01143       PortableServer::ObjectId *result =
01144         this->activate_object_i (servant,
01145                                  this->server_priority (),
01146                                  wait_occurred_restart_call);
01147 
01148       // If we ended up waiting on a condition variable, the POA state
01149       // may have changed while we are waiting.  Therefore, we need to
01150       // restart this call.
01151       if (wait_occurred_restart_call)
01152         continue;
01153       else
01154         return result;
01155     }
01156 }
01157 
01158 #if !defined (CORBA_E_MICRO)
01159 void
01160 TAO_Root_POA::activate_object_with_id (const PortableServer::ObjectId &id,
01161                                        PortableServer::Servant servant)
01162 {
01163   while (1)
01164     {
01165       bool wait_occurred_restart_call = false;
01166 
01167       // Lock access for the duration of this transaction.
01168       TAO_POA_GUARD;
01169 
01170       this->activate_object_with_id_i (id,
01171                                        servant,
01172                                        this->server_priority (),
01173                                        wait_occurred_restart_call);
01174 
01175       // If we ended up waiting on a condition variable, the POA state
01176       // may have changed while we are waiting.  Therefore, we need to
01177       // restart this call.
01178       if (wait_occurred_restart_call)
01179         continue;
01180       else
01181         return;
01182     }
01183 }
01184 #endif
01185 
01186 #if !defined (CORBA_E_MICRO)
01187 void
01188 TAO_Root_POA::activate_object_with_id_i (const PortableServer::ObjectId &id,
01189                                          PortableServer::Servant servant,
01190                                          CORBA::Short priority,
01191                                          bool &wait_occurred_restart_call)
01192 {
01193   this->active_policy_strategies_.servant_retention_strategy()->
01194     activate_object_with_id (id,
01195                              servant,
01196                              priority,
01197                              wait_occurred_restart_call);
01198 }
01199 #endif
01200 
01201 void
01202 TAO_Root_POA::deactivate_all_objects_i (CORBA::Boolean etherealize_objects,
01203                                         CORBA::Boolean wait_for_completion)
01204 {
01205   this->deactivate_all_objects_i (etherealize_objects);
01206 
01207   this->wait_for_completions (wait_for_completion);
01208 }
01209 
01210 void
01211 TAO_Root_POA::wait_for_completions (CORBA::Boolean wait_for_completion)
01212 {
01213   while (this->object_adapter ().enable_locking_ &&
01214          wait_for_completion &&
01215          this->outstanding_requests_ > 0)
01216     {
01217       this->wait_for_completion_pending_ = 1;
01218 
01219       int result = this->outstanding_requests_condition_.wait ();
01220       if (result == -1)
01221         {
01222           throw ::CORBA::OBJ_ADAPTER ();
01223         }
01224     }
01225 }
01226 
01227 /* static */
01228 void
01229 TAO_Root_POA::check_for_valid_wait_for_completions (const TAO_ORB_Core &orb_core,
01230                                                     CORBA::Boolean wait_for_completion)
01231 {
01232   if (wait_for_completion)
01233     {
01234       TAO::Portable_Server::POA_Current_Impl *poa_current_impl =
01235         static_cast <TAO::Portable_Server::POA_Current_Impl *>
01236                     (TAO_TSS_Resources::instance ()->poa_current_impl_);
01237 
01238       while (1)
01239         {
01240           // If wait_for_completion is TRUE and the current thread is
01241           // in an invocation context dispatched from some POA
01242           // belonging to the same ORB as this POA, the BAD_INV_ORDER
01243           // system exception with standard minor code 3 is raised and
01244           // POA destruction does not occur.
01245           if (poa_current_impl != 0)
01246             {
01247               if (&orb_core == &poa_current_impl->orb_core ())
01248                 {
01249                   // CORBA 2.3 specifies which minor code corresponds
01250                   // to this particular problem.
01251                   throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 3,
01252                                                 CORBA::COMPLETED_NO);
01253                 }
01254             }
01255           else
01256             break;
01257 
01258           poa_current_impl =
01259             poa_current_impl->previous_current_impl_;
01260         }
01261     }
01262 }
01263 
01264 void
01265 TAO_Root_POA::deactivate_all_objects_i (CORBA::Boolean etherealize_objects)
01266 {
01267   this->active_policy_strategies_.request_processing_strategy ()->
01268     etherealize_objects (etherealize_objects);
01269 
01270   this->active_policy_strategies_.servant_retention_strategy ()->
01271     deactivate_all_objects ();
01272 }
01273 
01274 void
01275 TAO_Root_POA::deactivate_object (const PortableServer::ObjectId &oid)
01276 {
01277   // Lock access for the duration of this transaction.
01278   TAO_POA_GUARD;
01279 
01280   this->deactivate_object_i (oid);
01281 }
01282 
01283 
01284 void
01285 TAO_Root_POA::deactivate_object_i (const PortableServer::ObjectId &id)
01286 {
01287   this->active_policy_strategies_.servant_retention_strategy()->
01288     deactivate_object (id);
01289 }
01290 
01291 CORBA::Boolean
01292 TAO_Root_POA::is_persistent (void) const
01293 {
01294   return active_policy_strategies_.lifespan_strategy()->is_persistent ();
01295 }
01296 
01297 CORBA::Object_ptr
01298 TAO_Root_POA::create_reference (const char *intf)
01299 {
01300   // Lock access for the duration of this transaction.
01301   TAO_POA_GUARD_RETURN (CORBA::Object::_nil ());
01302 
01303   return this->create_reference_i (intf,
01304                                    this->server_priority ());
01305 }
01306 
01307 CORBA::Object_ptr
01308 TAO_Root_POA::create_reference_i (const char *intf,
01309                                   CORBA::Short priority)
01310 {
01311   if (!this->has_system_id ())
01312     {
01313       throw PortableServer::POA::WrongPolicy ();
01314     }
01315 
01316   return this->active_policy_strategies_.servant_retention_strategy()->
01317     create_reference (intf, priority);
01318 }
01319 
01320 CORBA::Object_ptr
01321 TAO_Root_POA::invoke_key_to_object_helper_i (const char * repository_id,
01322                                              const PortableServer::ObjectId & id)
01323 {
01324   const PortableInterceptor::ObjectId &user_oid =
01325     reinterpret_cast <const PortableInterceptor::ObjectId &>(id);
01326 
01327   // Ask the ORT to create the object.
01328   if (this->ORT_adapter_i ())
01329     {
01330       // Ask the ORT to create the object.
01331       return this->ort_adapter_->make_object (repository_id,
01332                                               user_oid);
01333     }
01334   else
01335     {
01336       return this->invoke_key_to_object ();
01337     }
01338 }
01339 
01340 #if ! defined (CORBA_E_MICRO)
01341 CORBA::Object_ptr
01342 TAO_Root_POA::create_reference_with_id_i (const PortableServer::ObjectId &user_id,
01343                                           const char *intf,
01344                                           CORBA::Short priority)
01345 {
01346   // If the POA has the SYSTEM_ID policy and it detects that the
01347   // Object Id value was not generated by the system or for this POA,
01348   // the create_reference_with_id operation may raise the BAD_PARAM
01349   // system exception. An ORB is not required to detect all such
01350   // invalid Object Id values, but a portable application must not
01351   // invoke this operation on a POA that has the SYSTEM_ID policy with
01352   // an Object Id value that was not previously generated by the
01353   // system for that POA, or, if the POA also has the PERSISTENT
01354   // policy, for a previous instantiation of the same POA.
01355   if (this->has_system_id () &&
01356       !this->is_poa_generated_id (user_id))
01357     {
01358       throw ::CORBA::BAD_PARAM (CORBA::OMGVMCID | 14, CORBA::COMPLETED_NO);
01359     }
01360 
01361   return this->active_policy_strategies_.servant_retention_strategy()->
01362     create_reference_with_id (user_id, intf, priority);
01363 }
01364 #endif
01365 
01366 PortableServer::ObjectId *
01367 TAO_Root_POA::servant_to_id_i (PortableServer::Servant servant)
01368 {
01369   return this->active_policy_strategies_.request_processing_strategy()->
01370     servant_to_id (servant);
01371 }
01372 
01373 CORBA::Object_ptr
01374 TAO_Root_POA::servant_to_reference_i (PortableServer::Servant servant)
01375 {
01376   return this->active_policy_strategies_.servant_retention_strategy()->
01377     servant_to_reference (servant);
01378 }
01379 
01380 PortableServer::Servant
01381 TAO_Root_POA::reference_to_servant_i (CORBA::Object_ptr reference)
01382 {
01383   // Make sure that the reference is valid.
01384   if (CORBA::is_nil (reference))
01385     {
01386       throw ::CORBA::BAD_PARAM ();
01387     }
01388 
01389   PortableServer::ObjectId system_id;
01390   bool const is_generated =
01391     this->is_poa_generated (reference, system_id);
01392 
01393   if (!is_generated)
01394     {
01395       // In case this object reference is not generated by this POA throw
01396       // an exception
01397       throw PortableServer::POA::WrongAdapter ();
01398     }
01399 
01400   PortableServer::Servant servant =
01401     this->active_policy_strategies_.request_processing_strategy()->
01402       system_id_to_servant (system_id);
01403 
01404   if (servant != 0)
01405     {
01406       // ATTENTION: Trick locking here, see class header for details
01407       TAO::Portable_Server::Non_Servant_Upcall non_servant_upcall (*this);
01408       ACE_UNUSED_ARG (non_servant_upcall);
01409 
01410       // The POA invokes _add_ref once on the Servant before returning
01411       // it. If the application uses reference counting, the caller of
01412       // id_to_servant is responsible for invoking _remove_ref once on
01413       // the returned Servant when it is finished with it. A
01414       // conforming caller need not invoke _remove_ref on the returned
01415       // Servant if the type of the Servant uses the default reference
01416       // counting inherited from ServantBase.
01417       servant->_add_ref ();
01418     }
01419 
01420   return servant;
01421 }
01422 
01423 bool
01424 TAO_Root_POA::is_poa_generated (CORBA::Object_ptr reference,
01425                                 PortableServer::ObjectId &system_id)
01426 {
01427   TAO::ObjectKey_var key = reference->_key ();
01428 
01429   TAO_Object_Adapter::poa_name poa_system_name;
01430   CORBA::Boolean is_root = false;
01431   CORBA::Boolean is_persistent = false;
01432   CORBA::Boolean is_system_id = false;
01433   TAO::Portable_Server::Temporary_Creation_Time poa_creation_time;
01434 
01435   int const result = this->parse_key (key.in (),
01436                                       poa_system_name,
01437                                       system_id,
01438                                       is_root,
01439                                       is_persistent,
01440                                       is_system_id,
01441                                       poa_creation_time);
01442   if (result != 0 ||
01443       !this->root () &&
01444       poa_system_name != this->system_name () ||
01445       is_root != this->root () ||
01446       is_system_id != this->system_id () ||
01447       !this->validate_lifespan (is_persistent, poa_creation_time))
01448     {
01449       // The passed reference is NOT generated by this POA
01450       return false;
01451     }
01452   else
01453     {
01454       // The passed reference is generated by this POA
01455       return true;
01456     }
01457 }
01458 
01459 PortableServer::ObjectId *
01460 TAO_Root_POA::reference_to_id (CORBA::Object_ptr reference)
01461 {
01462   // Make sure that the reference is valid.
01463   if (CORBA::is_nil (reference))
01464     {
01465       throw ::CORBA::BAD_PARAM ();
01466     }
01467 
01468   // The WrongPolicy exception is declared to allow future extensions.
01469 
01470   // This operation is valid only if the reference was created by the
01471   // POA on which the operation is being performed.  If the object
01472   // reference was not created by this POA, the WrongAdapter exception
01473   // is raised.
01474   PortableServer::ObjectId system_id;
01475   bool const is_generated = this->is_poa_generated (reference, system_id);
01476 
01477   if (!is_generated)
01478     {
01479       throw PortableServer::POA::WrongAdapter ();
01480     }
01481 
01482   // Lock access for the duration of this transaction.
01483   TAO_POA_GUARD_RETURN (0);
01484 
01485   return this->active_policy_strategies_.servant_retention_strategy()->
01486     system_id_to_object_id (system_id);
01487 }
01488 
01489 PortableServer::Servant
01490 TAO_Root_POA::find_servant (const PortableServer::ObjectId &system_id)
01491 {
01492   return this->active_policy_strategies_.servant_retention_strategy()->
01493     find_servant (system_id);
01494 }
01495 
01496 int
01497 TAO_Root_POA::unbind_using_user_id (const PortableServer::ObjectId &user_id)
01498 {
01499   return this->active_policy_strategies_.servant_retention_strategy()->
01500     unbind_using_user_id  (user_id);
01501 }
01502 
01503 void
01504 TAO_Root_POA::cleanup_servant (
01505   PortableServer::Servant servant,
01506   const PortableServer::ObjectId &user_id)
01507 {
01508   this->active_policy_strategies_.request_processing_strategy()->
01509     cleanup_servant (servant, user_id);
01510 }
01511 
01512 PortableServer::Servant
01513 TAO_Root_POA::id_to_servant_i (const PortableServer::ObjectId &id)
01514 {
01515 
01516   PortableServer::Servant servant =
01517     this->active_policy_strategies_.request_processing_strategy()->
01518       id_to_servant (id);
01519 
01520   if (servant != 0)
01521     {
01522       // ATTENTION: Trick locking here, see class header for details
01523       TAO::Portable_Server::Non_Servant_Upcall non_servant_upcall (*this);
01524       ACE_UNUSED_ARG (non_servant_upcall);
01525 
01526       // The POA invokes _add_ref once on the Servant before returning
01527       // it. If the application uses reference counting, the caller of
01528       // id_to_servant is responsible for invoking _remove_ref once on
01529       // the returned Servant when it is finished with it. A
01530       // conforming caller need not invoke _remove_ref on the returned
01531       // Servant if the type of the Servant uses the default reference
01532       // counting inherited from ServantBase.
01533       servant->_add_ref ();
01534     }
01535 
01536   return servant;
01537 }
01538 
01539 PortableServer::Servant
01540 TAO_Root_POA::user_id_to_servant_i (const PortableServer::ObjectId &id)
01541 {
01542   return this->active_policy_strategies_.servant_retention_strategy()->
01543     user_id_to_servant (id);
01544 }
01545 
01546 CORBA::Object_ptr
01547 TAO_Root_POA::id_to_reference_i (const PortableServer::ObjectId &id,
01548                                  bool indirect)
01549 {
01550   return this->active_policy_strategies_.servant_retention_strategy()->
01551     id_to_reference (id, indirect);
01552 }
01553 
01554 CORBA::OctetSeq *
01555 TAO_Root_POA::id (void)
01556 {
01557   CORBA::OctetSeq *id = 0;
01558   ACE_NEW_THROW_EX (id,
01559                     CORBA::OctetSeq (this->id_),
01560                     CORBA::NO_MEMORY ());
01561 
01562   return id;
01563 }
01564 
01565 PortableServer::Servant
01566 TAO_Root_POA::locate_servant_i (const char *operation,
01567                                 const PortableServer::ObjectId &system_id,
01568                                 TAO::Portable_Server::Servant_Upcall &servant_upcall,
01569                                 TAO::Portable_Server::POA_Current_Impl &poa_current_impl,
01570                                 bool &wait_occurred_restart_call)
01571 {
01572   return this->active_policy_strategies_.request_processing_strategy()->
01573     locate_servant (operation,
01574                     system_id,
01575                     servant_upcall,
01576                     poa_current_impl,
01577                     wait_occurred_restart_call);
01578 }
01579 
01580 /* static */
01581 int
01582 TAO_Root_POA::parse_key (const TAO::ObjectKey &key,
01583                          TAO_Object_Adapter::poa_name &poa_system_name,
01584                          PortableServer::ObjectId &system_id,
01585                          CORBA::Boolean &is_root,
01586                          CORBA::Boolean &is_persistent,
01587                          CORBA::Boolean &is_system_id,
01588                          TAO::Portable_Server::Temporary_Creation_Time &poa_creation_time)
01589 {
01590   // Get the object key octets.
01591   const CORBA::Octet *key_data = key.get_buffer ();
01592 
01593   // Skip the object key prefix since we have already checked for this.
01594   CORBA::ULong starting_at = TAO_OBJECTKEY_PREFIX_SIZE;
01595 
01596   // Check the root indicator.
01597   char root_key_type = key_data[starting_at];
01598   if (root_key_type == TAO_Root_POA::root_key_char ())
01599     {
01600       is_root = true;
01601     }
01602   else if (root_key_type == TAO_Root_POA::non_root_key_char ())
01603     {
01604       is_root = false;
01605     }
01606   else
01607     {
01608       // Incorrect key
01609       return -1;
01610     }
01611 
01612   // Skip past the system id indicator
01613   starting_at += TAO_Root_POA::root_key_type_length ();
01614 
01615   // Check the system id indicator.
01616   char system_id_key_type = key_data[starting_at];
01617   if (system_id_key_type == TAO_Root_POA::system_id_key_char ())
01618     {
01619       is_system_id = true;
01620     }
01621   else if (system_id_key_type == TAO_Root_POA::user_id_key_char ())
01622     {
01623       is_system_id = false;
01624     }
01625   else
01626     {
01627       // Incorrect key
01628       return -1;
01629     }
01630 
01631   // Skip past the system id indicator
01632   starting_at += TAO_Root_POA::system_id_key_type_length ();
01633 
01634   // Check the persistence indicator
01635   char persistent_key_type = key_data[starting_at];
01636   if (persistent_key_type == TAO_Root_POA::persistent_key_char ())
01637     {
01638       is_persistent = true;
01639     }
01640   else if (persistent_key_type == TAO_Root_POA::transient_key_char ())
01641     {
01642       is_persistent = false;
01643     }
01644   else
01645     {
01646       // Incorrect key
01647       return -1;
01648     }
01649 
01650   // Skip past the persistent indicator
01651   starting_at += TAO_Root_POA::persistent_key_type_length ();
01652 
01653 #if (POA_NO_TIMESTAMP == 0)
01654   // Grab the timestamp for transient POAs.
01655   if (!is_persistent)
01656     {
01657       // Take the creation time for the timestamp
01658       poa_creation_time.creation_time (key_data + starting_at);
01659 
01660       // Skip past the timestamp
01661       starting_at += TAO::Portable_Server::Creation_Time::creation_time_length ();
01662     }
01663 #else
01664   ACE_UNUSED_ARG (poa_creation_time);
01665 #endif /* POA_NO_TIMESTAMP */
01666 
01667   // Calculate the size of the POA name.
01668   CORBA::ULong poa_name_size = 0;
01669   if (!is_persistent)
01670     {
01671       // Transient POAs have fixed size.
01672       poa_name_size = TAO_Object_Adapter::transient_poa_name_size ();
01673     }
01674   else if (is_system_id)
01675     {
01676       // System ids have fixed size.
01677       poa_name_size = static_cast <CORBA::ULong>
01678                                   (key.length () - starting_at -
01679                                    TAO_Active_Object_Map::system_id_size ());
01680     }
01681   else
01682     {
01683       // Get the size from the object key.
01684       ACE_OS::memcpy (&poa_name_size,
01685                       key_data + starting_at,
01686                       sizeof (poa_name_size));
01687       poa_name_size = ACE_NTOHL (poa_name_size);
01688 
01689       starting_at += sizeof (poa_name_size);
01690     }
01691 
01692   // Grep the name if there is a name
01693   if (!is_root)
01694     {
01695       poa_system_name.replace (poa_name_size,
01696                                poa_name_size,
01697                                (CORBA::Octet *) key_data + starting_at,
01698                                0);
01699 
01700       starting_at += poa_name_size;
01701     }
01702 
01703   // The rest is the system id.
01704   CORBA::ULong system_id_size = key.length () - starting_at;
01705 
01706   // Reset <system_id>.
01707   system_id.length (system_id_size);
01708   CORBA::Octet * buf = system_id.get_buffer ();
01709   ACE_OS::memcpy (buf, key_data + starting_at, system_id_size);
01710 
01711   // Success
01712   return 0;
01713 }
01714 
01715 TAO::ObjectKey *
01716 TAO_Root_POA::create_object_key (const PortableServer::ObjectId &id)
01717 {
01718   // Calculate the space required for the key.
01719   CORBA::ULong buffer_size =
01720     this->id_.length () +
01721     id.length ();
01722 
01723   // Create the buffer for the key.
01724   CORBA::Octet *buffer = TAO::ObjectKey::allocbuf (buffer_size);
01725 
01726   // First copy the POA id into the key.
01727   ACE_OS::memcpy (&buffer[0],
01728                   this->id_.get_buffer (),
01729                   this->id_.length ());
01730 
01731   // Then copy the object id into the key.
01732   ACE_OS::memcpy (&buffer[this->id_.length ()],
01733                   id.get_buffer (),
01734                   id.length ());
01735 
01736   // Create the key, giving the ownership of the buffer to the
01737   // sequence.
01738   TAO::ObjectKey *key = 0;
01739   ACE_NEW_RETURN (key,
01740                   TAO::ObjectKey (buffer_size,
01741                                   buffer_size,
01742                                   buffer,
01743                                   1),
01744                   0);
01745 
01746   return key;
01747 }
01748 
01749 void
01750 TAO_Root_POA::set_id (TAO_Root_POA *parent)
01751 {
01752   // Calculate the prefix size.
01753   CORBA::ULong prefix_size = 0;
01754   prefix_size += TAO_OBJECTKEY_PREFIX_SIZE;
01755 
01756   // If we are dealing with a persistent POA and user ids are being
01757   // used, then we need to add the POA name length field to the object
01758   // key. Otherwise, the POA name length can be calculated by looking
01759   // at the remainder after extracting other parts of the key.
01760   bool const add_poa_name_length =
01761     this->is_persistent () &&
01762     !this->system_id ();
01763 
01764   // Size required by the POA name.
01765   CORBA::ULong poa_name = 0;
01766 
01767   // Calculate the space required for the POA name.
01768   CORBA::ULong poa_name_length = this->system_name_->length ();
01769   if (parent != 0)
01770     {
01771       poa_name += poa_name_length;
01772     }
01773 
01774   // Check if we need to added the length of the POA name.
01775   if (add_poa_name_length)
01776     {
01777       poa_name += sizeof (poa_name_length);
01778     }
01779 
01780   // Get the space needed for the lifespan length
01781   // byte.
01782   CORBA::ULong const lifespan_key_length =
01783     this->active_policy_strategies_.lifespan_strategy()->key_length ();
01784 
01785   CORBA::ULong const id_assignment_key_length =
01786     this->active_policy_strategies_.id_assignment_strategy()->key_type_length ();
01787 
01788   // Calculate the space required for the POA id.
01789   CORBA::ULong const buffer_size =
01790     prefix_size +
01791     this->root_key_type_length () +
01792     id_assignment_key_length +
01793     lifespan_key_length +
01794     poa_name;
01795 
01796   // Create the buffer for the POA id.
01797   this->id_.length (buffer_size);
01798   CORBA::Octet *buffer = &this->id_[0];
01799 
01800   // Keeps track of where the next infomation goes; start at 0 byte.
01801   CORBA::ULong starting_at = 0;
01802 
01803   // Add the object key prefix.
01804   ACE_OS::memcpy (&buffer[starting_at],
01805                   &objectkey_prefix[0],
01806                   TAO_OBJECTKEY_PREFIX_SIZE);
01807 
01808   starting_at += TAO_OBJECTKEY_PREFIX_SIZE;
01809 
01810   // Copy the root byte.
01811   if (parent != 0)
01812     {
01813       buffer[starting_at] = (CORBA::Octet) TAO_Root_POA::non_root_key_char ();
01814     }
01815   else
01816     {
01817       buffer[starting_at] = (CORBA::Octet) TAO_Root_POA::root_key_char ();
01818     }
01819   starting_at += this->root_key_type_length ();
01820 
01821   // Add the id_assignment part
01822   this->active_policy_strategies_.id_assignment_strategy()->create_key (buffer, starting_at);
01823 
01824   // Add the lifespan part
01825   this->active_policy_strategies_.lifespan_strategy()->create_key (buffer, starting_at);
01826 
01827   // Check if we need to added the length of the POA name.
01828   if (add_poa_name_length)
01829     {
01830       poa_name_length = ACE_HTONL (poa_name_length);
01831       ACE_OS::memcpy (&buffer[starting_at],
01832                       &poa_name_length,
01833                       sizeof (poa_name_length));
01834       starting_at += sizeof (poa_name_length);
01835     }
01836 
01837   // Put the POA name into the key (for non-root POAs).
01838   if (parent != 0)
01839     {
01840       ACE_OS::memcpy (&buffer[starting_at],
01841                       this->system_name_->get_buffer (),
01842                       this->system_name_->length ());
01843       starting_at += this->system_name_->length ();
01844     }
01845 }
01846 
01847 int
01848 TAO_Root_POA::is_poa_generated_id (const PortableServer::ObjectId &id)
01849 {
01850 #if defined (POA_NAME_IN_POA_GENERATED_ID)
01851 
01852   // Grab the buffer
01853   const char *id_buffer = (const char *) id.get_buffer ();
01854 
01855   // Check to see if the POA name is the first part of the id
01856   return
01857     this->name_.length () < id.length () &&
01858     ACE_OS::strncmp (id_buffer,
01859                      this->name_.c_str (),
01860                      this->name_.length ()) == 0;
01861 #else /* POA_NAME_IN_POA_GENERATED_ID */
01862 
01863   ACE_UNUSED_ARG (id);
01864   return 1;
01865 
01866 #endif /* POA_NAME_IN_POA_GENERATED_ID */
01867 }
01868 
01869 void
01870 TAO_Root_POA::set_folded_name (TAO_Root_POA *parent)
01871 {
01872   size_t length = 0;
01873   size_t parent_length = 0;
01874 
01875   if (parent != 0)
01876     {
01877       parent_length = parent->folded_name ().length ();
01878       length += parent_length;
01879     }
01880 
01881   length += this->name_.length ();
01882   length += TAO_Root_POA::name_separator_length ();
01883 
01884   this->folded_name_.length (static_cast <CORBA::ULong> (length));
01885   CORBA::Octet *folded_name_buffer = this->folded_name_.get_buffer ();
01886 
01887   if (parent != 0)
01888     {
01889       ACE_OS::memcpy (folded_name_buffer,
01890                       parent->folded_name ().get_buffer (),
01891                       parent_length);
01892     }
01893 
01894   ACE_OS::memcpy (&folded_name_buffer[parent_length],
01895                   this->name_.c_str (),
01896                   this->name_.length ());
01897 
01898   folded_name_buffer[length - TAO_Root_POA::name_separator_length ()] = TAO_Root_POA::name_separator ();
01899 }
01900 
01901 int
01902 TAO_Root_POA::parse_ir_object_key (const TAO::ObjectKey &object_key,
01903                                    PortableServer::ObjectId &user_id)
01904 {
01905   TAO_Object_Adapter::poa_name poa_system_name;
01906   CORBA::Boolean is_root = false;
01907   CORBA::Boolean is_persistent = false;
01908   CORBA::Boolean is_system_id = false;
01909   TAO::Portable_Server::Temporary_Creation_Time poa_creation_time;
01910 
01911   return TAO_Root_POA::parse_key (object_key,
01912                                   poa_system_name,
01913                                   user_id,
01914                                   is_root,
01915                                   is_persistent,
01916                                   is_system_id,
01917                                   poa_creation_time);
01918 }
01919 
01920 TAO_Object_Adapter &
01921 TAO_Root_POA::object_adapter (void)
01922 {
01923   return *this->object_adapter_;
01924 }
01925 
01926 CORBA::Object_ptr
01927 TAO_Root_POA::invoke_key_to_object (void)
01928 {
01929   PortableServer::ObjectId_var &system_id =
01930     *this->key_to_object_params_.system_id_;
01931 
01932   // Create object key.
01933   TAO::ObjectKey_var key =
01934     this->create_object_key (system_id.in ());
01935 
01936   return this->key_to_object (key.in (),
01937                               this->key_to_object_params_.type_id_,
01938                               this->key_to_object_params_.servant_,
01939                               this->key_to_object_params_.collocated_,
01940                               this->key_to_object_params_.priority_,
01941                               this->key_to_object_params_.indirect_);
01942 }
01943 
01944 CORBA::Object_ptr
01945 TAO_Root_POA::key_to_object (const TAO::ObjectKey &key,
01946                              const char *type_id,
01947                              TAO_ServantBase *servant,
01948                              CORBA::Boolean collocated,
01949                              CORBA::Short priority,
01950                              bool indirect)
01951 {
01952   // Check if the ORB is still running, otherwise throw an exception.
01953   // @@ What if the ORB was destroyed?  In that case we shouldn't even
01954   //    get here!
01955   this->orb_core_.check_shutdown ();
01956 
01957   //
01958   // ImplRepo related.
01959   //
01960 #if (TAO_HAS_MINIMUM_CORBA == 0)
01961 
01962   CORBA::Object_ptr obj = CORBA::Object::_nil ();
01963 
01964   if (indirect && this->active_policy_strategies_.lifespan_strategy()->use_imr ()
01965          && this->orb_core ().imr_endpoints_in_ior ())
01966     {
01967       // Check to see if we alter the IOR.
01968       CORBA::Object_var imr = this->orb_core ().implrepo_service ();
01969 
01970       if (CORBA::is_nil (imr.in ())
01971           || !imr->_stubobj ()
01972           || !imr->_stubobj ()->profile_in_use ())
01973         {
01974           if (TAO_debug_level > 1)
01975             {
01976               ACE_DEBUG ((LM_DEBUG,
01977                           "Missing ImR IOR, will not use the ImR\n"));
01978             }
01979           goto orbkey;
01980         }
01981 
01982       CORBA::String_var imr_str =
01983         imr->_stubobj ()->profile_in_use ()->to_string ();
01984 
01985       if (TAO_debug_level > 0)
01986         ACE_DEBUG ((LM_DEBUG,
01987                     "IMR IOR = \n%s\n",
01988                     ACE_TEXT_CHAR_TO_TCHAR (imr_str.in ())));
01989 
01990       // Search for "corbaloc:" alone, without the protocol.  This code
01991       // should be protocol neutral.
01992       const char corbaloc[] = "corbaloc:";
01993       char *pos = ACE_OS::strstr (imr_str.inout (), corbaloc);
01994       pos = ACE_OS::strchr (pos + sizeof (corbaloc), ':');
01995 
01996       pos = ACE_OS::strchr (pos + 1,
01997                             imr->_stubobj ()->profile_in_use ()->object_key_delimiter ());
01998 
01999       if (pos)
02000         pos[1] = 0;  // Crop the string.
02001       else
02002         {
02003           if (TAO_debug_level > 0)
02004             ACE_ERROR ((LM_ERROR,
02005                         "Could not parse ImR IOR, skipping ImRification\n"));
02006           goto orbkey;
02007         }
02008 
02009       ACE_CString ior (imr_str.in ());
02010 
02011       // Add the key.
02012 
02013       CORBA::String_var key_str;
02014       TAO::ObjectKey::encode_sequence_to_string (key_str.inout (), key);
02015 
02016       ior += key_str.in ();
02017 
02018       if (TAO_debug_level > 0)
02019         ACE_DEBUG ((LM_DEBUG,
02020                     "ImR-ified IOR = \n%s\n",
02021                     ACE_TEXT_CHAR_TO_TCHAR (ior.c_str ())));
02022 
02023       obj = this->orb_core_.orb ()->string_to_object (ior.c_str ());
02024 
02025       return obj;
02026     }
02027 
02028 orbkey:
02029 
02030 #else
02031   ACE_UNUSED_ARG (indirect);
02032 #endif /* TAO_HAS_MINIMUM_CORBA */
02033 
02034   TAO_Stub *data = this->key_to_stub_i (key, type_id, priority);
02035 
02036   TAO_Stub_Auto_Ptr safe_data (data);
02037 
02038   CORBA::Object_ptr tmp;
02039 
02040   if (this->orb_core_.optimize_collocation_objects ())
02041     {
02042       ACE_NEW_THROW_EX (tmp, CORBA::Object (data,
02043                                             collocated,
02044                                             servant),
02045                         CORBA::INTERNAL ());
02046 
02047     }
02048   else
02049     {
02050       ACE_NEW_THROW_EX (tmp,
02051                         CORBA::Object (data,
02052                                        collocated),
02053                         CORBA::INTERNAL ());
02054     }
02055 
02056   data->servant_orb (this->orb_core_.orb ());
02057 
02058   // Transfer ownership to the Object.
02059   (void) safe_data.release ();
02060 
02061   return tmp;
02062 }
02063 
02064 TAO_Stub *
02065 TAO_Root_POA::key_to_stub (const TAO::ObjectKey &key,
02066                            const char *type_id,
02067                            CORBA::Short priority)
02068 {
02069   // Check if the ORB is still running, otherwise throw an exception.
02070   // @@ What if the ORB was destroyed?  In that case we shouldn't even
02071   //    get here!
02072   this->orb_core_.check_shutdown ();
02073 
02074   return this->key_to_stub_i (key, type_id, priority);
02075 }
02076 
02077 TAO_Stub *
02078 TAO_Root_POA::key_to_stub_i (const TAO::ObjectKey &key,
02079                              const char *type_id,
02080                              CORBA::Short priority)
02081 {
02082   CORBA::PolicyList_var client_exposed_policies =
02083     this->client_exposed_policies (priority);
02084 
02085   TAO_Acceptor_Filter* filter = 0;
02086 
02087 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
02088   if (this->filter_factory_)
02089     {
02090       filter = this->filter_factory_->create_object (this->poa_manager_);
02091     }
02092   else
02093 #endif
02094     {
02095       ACE_NEW_RETURN (filter,
02096                       TAO_Default_Acceptor_Filter (),
02097                       0);
02098     }
02099 
02100   // Give ownership to the auto pointer.
02101   auto_ptr<TAO_Acceptor_Filter> new_filter (filter);
02102 
02103   TAO_Stub *data =
02104     this->create_stub_object (
02105       key,
02106       type_id,
02107       client_exposed_policies._retn (),
02108       filter,
02109       this->orb_core_.lane_resources ().acceptor_registry ());
02110 
02111   return data;
02112 }
02113 
02114 void
02115 TAO_Root_POA::establish_components (void)
02116 {
02117   TAO_IORInterceptor_Adapter *ior_adapter =
02118     this->orb_core_.ior_interceptor_adapter ();
02119 
02120   if (ior_adapter)
02121     {
02122       ior_adapter->establish_components (this);
02123     }
02124 }
02125 
02126 void
02127 TAO_Root_POA::components_established (PortableInterceptor::IORInfo_ptr info)
02128 {
02129   TAO_IORInterceptor_Adapter *ior_adapter =
02130     this->orb_core_.ior_interceptor_adapter ();
02131 
02132   if (ior_adapter)
02133     {
02134       ior_adapter->components_established (info);
02135     }
02136 }
02137 
02138 void
02139 TAO_Root_POA::save_ior_component (const IOP::TaggedComponent &component)
02140 {
02141   CORBA::ULong const old_len = this->tagged_component_.length ();
02142 
02143   this->tagged_component_.length (old_len + 1);
02144   this->tagged_component_[old_len] = component;
02145 }
02146 
02147 void
02148 TAO_Root_POA::
02149 save_ior_component_and_profile_id (const IOP::TaggedComponent &component,
02150                                    IOP::ProfileId profile_id)
02151 {
02152   // The length of this->tagged_component_id_ is the same as the
02153   // length of the profile_id_array_ since we are trying to make a
02154   // one-to-one link between these two arrays. So, whenever
02155   // this->tagged_component_id_ is increased, we need to increase the
02156   // size of this->profile_id_array_ also.
02157 
02158   CORBA::ULong const old_len = this->tagged_component_id_.length ();
02159 
02160   CORBA::ULong const new_len = old_len + 1;
02161 
02162   this->tagged_component_id_.length (new_len);
02163   this->tagged_component_id_[old_len] = component;
02164 
02165   this->profile_id_array_.size (new_len);
02166   this->profile_id_array_[old_len] = profile_id;
02167 }
02168 
02169 TAO_Stub *
02170 TAO_Root_POA::create_stub_object (const TAO::ObjectKey &object_key,
02171                                   const char *type_id,
02172                                   CORBA::PolicyList *policy_list,
02173                                   TAO_Acceptor_Filter *filter,
02174                                   TAO_Acceptor_Registry &acceptor_registry)
02175 {
02176   bool error = false;
02177 
02178   // Count the number of endpoints.
02179   size_t const profile_count = acceptor_registry.endpoint_count ();
02180 
02181   // Create a profile container and have acceptor registries populate
02182   // it with profiles as appropriate.
02183   TAO_MProfile mprofile (0);
02184 
02185   // Allocate space for storing the profiles.  There can never be more
02186   // profiles than there are endpoints.  In some cases, there can be
02187   // less profiles than endpoints.
02188   int result = mprofile.set (static_cast <CORBA::ULong> (profile_count));
02189   if (result == -1)
02190     error = true;
02191 
02192   if (!error)
02193     {
02194       result =
02195         filter->fill_profile (object_key,
02196                               mprofile,
02197                               acceptor_registry.begin (),
02198                               acceptor_registry.end ());
02199       if (result == -1)
02200         error = true;
02201     }
02202 
02203   if (!error)
02204     result = filter->encode_endpoints (mprofile);
02205 
02206   if (result == -1)
02207     error = true;
02208 
02209   if (error)
02210     throw ::CORBA::INTERNAL (
02211       CORBA::SystemException::_tao_minor_code (
02212         TAO_MPROFILE_CREATION_ERROR,
02213         0),
02214       CORBA::COMPLETED_NO);
02215 
02216   // Make sure we have at least one profile.  <mp> may end up being
02217   // empty if none of the acceptor endpoints have the right priority
02218   // for this object, for example.
02219   if (mprofile.profile_count () == 0)
02220     throw ::CORBA::BAD_PARAM (
02221       CORBA::SystemException::_tao_minor_code (
02222         TAO_MPROFILE_CREATION_ERROR,
02223         0),
02224       CORBA::COMPLETED_NO);
02225 
02226   TAO_Stub *stub =
02227     this->orb_core_.create_stub_object (mprofile, type_id, policy_list);
02228 
02229   // Add the saved tagged components methods to the profiles.
02230   CORBA::ULong len = this->tagged_component_.length ();
02231   for (CORBA::ULong i = 0; i != len; ++i)
02232     {
02233       this->add_ior_component (mprofile, this->tagged_component_[i]);
02234       }
02235 
02236   len = this->tagged_component_id_.length ();
02237 
02238   for (CORBA::ULong k = 0; k != len; ++k)
02239     {
02240       this->add_ior_component_to_profile (mprofile,
02241                                           this->tagged_component_id_[k],
02242                                           this->profile_id_array_[k]);
02243     }
02244 
02245   return stub;
02246 }
02247 
02248 CORBA::PolicyList *
02249 TAO_Root_POA::client_exposed_policies (CORBA::Short /* object_priority */)
02250 {
02251   CORBA::PolicyList *client_exposed_policies = 0;
02252   ACE_NEW_THROW_EX (client_exposed_policies,
02253                     CORBA::PolicyList (),
02254                     CORBA::NO_MEMORY (TAO::VMCID,
02255                                       CORBA::COMPLETED_NO));
02256 
02257   CORBA::PolicyList_var policies = client_exposed_policies;
02258 
02259   // Add in all of the client exposed policies.
02260   this->policies_.add_client_exposed_fixed_policies (client_exposed_policies);
02261 
02262   return policies._retn ();
02263 }
02264 
02265 TAO_SERVANT_LOCATION
02266 TAO_Root_POA::locate_servant_i (const PortableServer::ObjectId &system_id,
02267                                 PortableServer::Servant &servant)
02268 {
02269   return this->active_policy_strategies_.request_processing_strategy()->
02270           locate_servant (system_id, servant);
02271 }
02272 
02273 TAO_SERVANT_LOCATION
02274 TAO_Root_POA::servant_present (const PortableServer::ObjectId &system_id,
02275                                PortableServer::Servant &servant)
02276 {
02277   return this->active_policy_strategies_.servant_retention_strategy()->
02278           servant_present (system_id, servant);
02279 }
02280 
02281 PortableServer::Servant
02282 TAO_Root_POA::find_servant (
02283         const PortableServer::ObjectId &system_id,
02284         TAO::Portable_Server::Servant_Upcall &servant_upcall,
02285         TAO::Portable_Server::POA_Current_Impl &poa_current_impl)
02286 {
02287   return this->active_policy_strategies_.servant_retention_strategy()->
02288           find_servant (system_id,
02289                         servant_upcall,
02290                         poa_current_impl);
02291 }
02292 
02293 int
02294 TAO_Root_POA::find_servant_priority (
02295          const PortableServer::ObjectId &system_id,
02296          CORBA::Short &priority)
02297 {
02298   return this->active_policy_strategies_.servant_retention_strategy()->
02299           find_servant_priority (system_id, priority);
02300 }
02301 
02302 TAO::ORT_Adapter_Factory *
02303 TAO_Root_POA::ORT_adapter_factory (void)
02304 {
02305   return ACE_Dynamic_Service<TAO::ORT_Adapter_Factory>::instance
02306     (orb_core_.configuration (),
02307            TAO_Root_POA::ort_adapter_factory_name ());
02308 }
02309 
02310 TAO::ORT_Adapter *
02311 TAO_Root_POA::ORT_adapter_i (void)
02312 {
02313   if (this->ort_adapter_ != 0)
02314     return this->ort_adapter_;
02315 
02316   try
02317     {
02318       TAO::ORT_Adapter_Factory * ort_ap_factory = this->ORT_adapter_factory ();
02319 
02320       if (!ort_ap_factory)
02321         return 0;
02322 
02323       // Get the full adapter name of this POA, do this before we
02324       // create the adapter so that in case this fails, we just
02325       // return 0 and not a not activated adapter
02326       PortableInterceptor::AdapterName *adapter_name = this->adapter_name_i ();
02327 
02328       this->ort_adapter_ = ort_ap_factory->create ();
02329 
02330       if (!this->ort_adapter_)
02331         return 0;
02332 
02333       // @todo We have to look at this, we activate it but hold the POA lock,
02334       // in case we are called by ORT_adapter, we shouldn't keep the lock
02335       // here, but then the ort_adapter should be guarded against multiple
02336       // activations.
02337       this->ort_adapter_->activate (this->orb_core_.server_id (),
02338                                     this->orb_core_.orbid (),
02339                                     adapter_name,
02340                                     this);
02341     }
02342   catch (const ::CORBA::Exception& ex)
02343     {
02344       ex._tao_print_exception (
02345         "(%P|%t) Cannot initialize the "
02346         "object_reference_template_adapter\n");
02347     }
02348 
02349   return this->ort_adapter_;
02350 }
02351 
02352 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
02353 
02354 PortableServer::AdapterActivator_ptr
02355 TAO_Root_POA::the_activator (void)
02356 {
02357   // Lock access for the duration of this transaction.
02358   TAO_POA_GUARD_RETURN (PortableServer::AdapterActivator::_nil ());
02359 
02360   return PortableServer::AdapterActivator::_duplicate (this->adapter_activator_.in ());
02361 }
02362 
02363 void
02364 TAO_Root_POA::the_activator (PortableServer::AdapterActivator_ptr adapter_activator)
02365 {
02366   // Lock access for the duration of this transaction.
02367   TAO_POA_GUARD;
02368 
02369   this->adapter_activator_ = PortableServer::AdapterActivator::_duplicate (adapter_activator);
02370 }
02371 
02372 #endif /* TAO_HAS_MINIMUM_POA == 0 && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)*/
02373 
02374 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
02375 
02376 PortableServer::ServantManager_ptr
02377 TAO_Root_POA::get_servant_manager (void)
02378 {
02379   // Lock access for the duration of this transaction.
02380   TAO_POA_GUARD_RETURN (PortableServer::ServantManager::_nil ());
02381 
02382   return this->active_policy_strategies_.request_processing_strategy()->
02383     get_servant_manager ();
02384 }
02385 
02386 void
02387 TAO_Root_POA::set_servant_manager (PortableServer::ServantManager_ptr imgr)
02388 {
02389   // Lock access for the duration of this transaction.
02390   TAO_POA_GUARD;
02391 
02392   this->active_policy_strategies_.request_processing_strategy()->
02393     set_servant_manager (imgr);
02394 }
02395 
02396 PortableServer::Servant
02397 TAO_Root_POA::get_servant_i (void)
02398 {
02399   return this->active_policy_strategies_.request_processing_strategy()->
02400     get_servant ();
02401 }
02402 
02403 PortableServer::Servant
02404 TAO_Root_POA::get_servant (void)
02405 {
02406   // Lock access for the duration of this transaction.
02407   TAO_POA_GUARD_RETURN (0);
02408 
02409   PortableServer::Servant servant = this->get_servant_i ();
02410 
02411   if (servant != 0)
02412     {
02413       // ATTENTION: Trick locking here, see class header for details
02414       TAO::Portable_Server::Non_Servant_Upcall non_servant_upcall (*this);
02415       ACE_UNUSED_ARG (non_servant_upcall);
02416 
02417       // The POA invokes _add_ref once on the Servant before returning
02418       // it. If the application uses reference counting, the caller of
02419       // get_servant is responsible for invoking _remove_ref once on
02420       // the returned Servant when it is finished with it. A
02421       // conforming caller need not invoke _remove_ref on the returned
02422       // Servant if the type of the Servant uses the default reference
02423       // counting inherited from ServantBase.
02424       servant->_add_ref ();
02425 
02426       return servant;
02427     }
02428   else
02429     {
02430       // If no servant has been associated with the POA, the NoServant
02431       // exception is raised.
02432       throw PortableServer::POA::NoServant ();
02433     }
02434 }
02435 
02436 void
02437 TAO_Root_POA::set_servant (PortableServer::Servant servant)
02438 {
02439   // Lock access for the duration of this transaction.
02440   TAO_POA_GUARD;
02441 
02442   this->active_policy_strategies_.request_processing_strategy()->
02443     set_servant (servant);
02444 }
02445 
02446 #endif /* TAO_HAS_MINIMUM_POA == 0 && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO) */
02447 
02448 bool
02449 TAO_Root_POA::is_servant_activation_allowed (PortableServer::Servant servant,
02450                                              bool &wait_occurred_restart_call)
02451 {
02452   return this->active_policy_strategies_.id_uniqueness_strategy ()->
02453     is_servant_activation_allowed (servant, wait_occurred_restart_call);
02454 }
02455 
02456 bool
02457 TAO_Root_POA::has_system_id (void) const
02458 {
02459   return this->active_policy_strategies_.id_assignment_strategy ()->
02460     has_system_id ();
02461 }
02462 
02463 int
02464 TAO_Root_POA::rebind_using_user_id_and_system_id (
02465   PortableServer::Servant servant,
02466   const PortableServer::ObjectId &user_id,
02467   const PortableServer::ObjectId &system_id,
02468   TAO::Portable_Server::Servant_Upcall &servant_upcall)
02469 {
02470   return this->active_policy_strategies_.servant_retention_strategy ()->
02471     rebind_using_user_id_and_system_id (servant,
02472                                         user_id,
02473                                         system_id,
02474                                         servant_upcall);
02475 }
02476 
02477 CORBA::Boolean
02478 TAO_Root_POA::servant_has_remaining_activations (PortableServer::Servant servant)
02479 {
02480   return this->active_policy_strategies_.servant_retention_strategy ()->
02481     servant_has_remaining_activations (servant);
02482 }
02483 
02484 bool
02485 TAO_Root_POA::allow_implicit_activation (void) const
02486 {
02487   return this->active_policy_strategies_.implicit_activation_strategy ()->
02488     allow_implicit_activation ();
02489 }
02490 
02491 bool
02492 TAO_Root_POA::allow_multiple_activations (void) const
02493 {
02494   return this->active_policy_strategies_.id_uniqueness_strategy ()->
02495     allow_multiple_activations ();
02496 }
02497 
02498 void
02499 TAO_Root_POA::post_invoke_servant_cleanup(
02500   const PortableServer::ObjectId &system_id,
02501   const TAO::Portable_Server::Servant_Upcall &servant_upcall)
02502 {
02503   this->active_policy_strategies_.request_processing_strategy ()->
02504     post_invoke_servant_cleanup (system_id, servant_upcall);
02505 }
02506 
02507 CORBA::Short
02508 TAO_Root_POA::server_priority (void) const
02509 {
02510   return this->cached_policies_.server_priority ();
02511 }
02512 
02513 int
02514 TAO_Root_POA::is_servant_active (
02515   PortableServer::Servant servant,
02516   bool &wait_occurred_restart_call)
02517 {
02518   return this->active_policy_strategies_.servant_retention_strategy ()->
02519     is_servant_in_map (servant, wait_occurred_restart_call);
02520 }
02521 
02522 TAO::Portable_Server::Cached_Policies&
02523 TAO_Root_POA::cached_policies (void)
02524 {
02525   return this->cached_policies_;
02526 }
02527 
02528 TAO_Network_Priority_Hook*
02529 TAO_Root_POA::network_priority_hook (void)
02530 {
02531   return this->network_priority_hook_;
02532 }
02533 
02534 TAO::Portable_Server::Cached_Policies::PriorityModel
02535 TAO_Root_POA::priority_model (void) const
02536 {
02537   return cached_policies_.priority_model ();
02538 }
02539 
02540 #if (TAO_HAS_MINIMUM_POA == 0)
02541 int
02542 TAO_Root_POA::enter ()
02543 {
02544   return this->active_policy_strategies_.thread_strategy ()->enter();
02545 }
02546 #endif /* TAO_HAS_MINIMUM_POA == 0 */
02547 
02548 #if (TAO_HAS_MINIMUM_POA == 0)
02549 int
02550 TAO_Root_POA::exit ()
02551 {
02552   return this->active_policy_strategies_.thread_strategy ()->exit();
02553 }
02554 #endif /* TAO_HAS_MINIMUM_POA == 0 */
02555 
02556 bool
02557 TAO_Root_POA::validate_lifespan (
02558   CORBA::Boolean is_persistent,
02559   const TAO::Portable_Server::Temporary_Creation_Time& creation_time) const
02560 {
02561   return this->active_policy_strategies_.lifespan_strategy()->
02562     validate (is_persistent, creation_time);
02563 }
02564 
02565 CORBA::Boolean
02566 TAO_Root_POA::root (void) const
02567 {
02568   return true;
02569 }
02570 
02571 TAO::ORT_Adapter *
02572 TAO_Root_POA::ORT_adapter (void)
02573 {
02574   if (this->ort_adapter_ != 0)
02575     return this->ort_adapter_;
02576 
02577   // Lock access for the duration of this transaction.
02578   TAO_POA_GUARD_RETURN (0);
02579 
02580   // DCL ..
02581   if (this->ort_adapter_ != 0)
02582     {
02583       return this->ort_adapter_;
02584     }
02585 
02586   return this->ORT_adapter_i ();
02587 }
02588 
02589 CORBA::Policy *
02590 TAO_Root_POA::server_protocol (void)
02591 {
02592   return 0;
02593 }
02594 
02595 void
02596 TAO_Root_POA::Key_To_Object_Params::set (PortableServer::ObjectId_var &system_id,
02597                                          const char *type_id,
02598                                          TAO_ServantBase *servant,
02599                                          CORBA::Boolean collocated,
02600                                          CORBA::Short priority,
02601                                          bool indirect)
02602 {
02603   this->system_id_ = &system_id;
02604   this->type_id_ = type_id;
02605   this->servant_ = servant;
02606   this->collocated_ = collocated;
02607   this->priority_ = priority;
02608   this->indirect_ = indirect;
02609 }
02610 
02611 CORBA::ULong
02612 TAO_Root_POA::waiting_servant_deactivation (void) const
02613 {
02614   return this->active_policy_strategies_.servant_retention_strategy ()->
02615           waiting_servant_deactivation ();
02616 }
02617 
02618 void
02619 TAO_Root_POA::ort_adapter_factory_name (const char *name)
02620 {
02621   TAO_POA_Static_Resources::instance ()->ort_adapter_factory_name_ =
02622     name;
02623 }
02624 
02625 CORBA::Policy_ptr
02626 TAO_Root_POA::get_policy (CORBA::PolicyType policy)
02627 {
02628   return this->policies_.get_policy (policy);
02629 }
02630 
02631 void
02632 TAO_Root_POA::check_state (void)
02633 {
02634   this->active_policy_strategies_.lifespan_strategy ()->check_state ();
02635 }
02636 
02637 const char *
02638 TAO_Root_POA::ort_adapter_factory_name (void)
02639 {
02640   return TAO_POA_Static_Resources::instance ()->ort_adapter_factory_name_.c_str();
02641 }
02642 
02643 void
02644 TAO_Root_POA::imr_client_adapter_name (const char *name)
02645 {
02646   TAO_POA_Static_Resources::instance ()->imr_client_adapter_name_ = name;
02647 }
02648 
02649 const char *
02650 TAO_Root_POA::imr_client_adapter_name (void)
02651 {
02652   return TAO_POA_Static_Resources::instance ()->imr_client_adapter_name_.c_str();
02653 }
02654 
02655 PortableServer::POAManager_ptr
02656 TAO_Root_POA::the_POAManager (void)
02657 {
02658   return PortableServer::POAManager::_duplicate (&this->poa_manager_);
02659 }
02660 
02661 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
02662 PortableServer::POAManagerFactory_ptr
02663 TAO_Root_POA::the_POAManagerFactory (void)
02664 {
02665   return PortableServer::POAManagerFactory::_duplicate (&this->poa_manager_factory_);
02666 }
02667 #endif
02668 
02669 CORBA::ORB_ptr
02670 TAO_Root_POA::_get_orb (void)
02671 {
02672   return CORBA::ORB::_duplicate (this->orb_core_.orb ());
02673 }
02674 
02675 // Initialize instance_ to 0, since this is what we test for in the call
02676 // to instance ().  Note that this does not require a constructor call, so
02677 // it is always initialized by the time that instance () can be called.
02678 TAO_POA_Static_Resources* TAO_POA_Static_Resources::instance_ = 0;
02679 
02680 // Force an instance to be created at module initialization time,
02681 // since we do not want to worry about double checked locking and
02682 // the race condition to initialize the lock.
02683 TAO_POA_Static_Resources* TAO_POA_Static_Resources::initialization_reference_ =
02684   TAO_POA_Static_Resources::instance ();
02685 
02686 TAO_POA_Static_Resources*
02687 TAO_POA_Static_Resources::instance (void)
02688 {
02689   if (TAO_POA_Static_Resources::instance_ == 0)
02690     {
02691       // This new is never freed on purpose.  The data specified by
02692       // it needs to be around for the last shared library that references
02693       // this class.  This could occur in a destructor in a shared library
02694       // that is unloaded after this one.  One solution to avoid this
02695       // harmless memory leak would be to use reference counting.
02696       ACE_NEW_RETURN (TAO_POA_Static_Resources::instance_,
02697                       TAO_POA_Static_Resources (),
02698                       0);
02699     }
02700 
02701   return TAO_POA_Static_Resources::instance_;
02702 }
02703 
02704 TAO_POA_Static_Resources::TAO_POA_Static_Resources (void)
02705   : ort_adapter_factory_name_ ("ORT_Adapter_Factory"),
02706     imr_client_adapter_name_ ("ImR_Client_Adapter")
02707 {
02708 }
02709 
02710 void
02711 TAO_Root_POA::poa_activated_hook ()
02712 {
02713 }
02714 
02715 void
02716 TAO_Root_POA::poa_deactivated_hook ()
02717 {
02718 }
02719 
02720 void
02721 TAO_Root_POA::servant_activated_hook (PortableServer::Servant,
02722                                       const PortableServer::ObjectId&)
02723 {
02724 }
02725 
02726 void
02727 TAO_Root_POA::servant_deactivated_hook (PortableServer::Servant,
02728                                         const PortableServer::ObjectId&)
02729 {
02730 }
02731 
02732 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:40:54 2010 for TAO_PortableServer by  doxygen 1.4.7