1 #include "tao/PortableServer/Root_POA.h"
2 #include "tao/PortableServer/Regular_POA.h"
4 #include "tao/PortableServer/ThreadPolicy.h"
5 #include "tao/PortableServer/LifespanPolicy.h"
6 #include "tao/PortableServer/IdAssignmentPolicy.h"
7 #include "tao/PortableServer/IdUniquenessPolicy.h"
8 #include "tao/PortableServer/ImplicitActivationPolicy.h"
9 #include "tao/PortableServer/RequestProcessingPolicy.h"
10 #include "tao/PortableServer/ServantRetentionPolicy.h"
11 #include "tao/PortableServer/Active_Object_Map.h"
12 #include "tao/PortableServer/Default_Acceptor_Filter.h"
13 #include "tao/PortableServer/ORT_Adapter.h"
14 #include "tao/PortableServer/ORT_Adapter_Factory.h"
15 #include "tao/PortableServer/POA_Current_Impl.h"
16 #include "tao/PortableServer/Servant_Upcall.h"
17 #include "tao/PortableServer/AdapterActivatorC.h"
18 #include "tao/PortableServer/Non_Servant_Upcall.h"
19 #include "tao/PortableServer/POAManager.h"
20 #include "tao/PortableServer/POAManagerFactory.h"
21 #include "tao/PortableServer/ServantManagerC.h"
22 #include "tao/PortableServer/poa_macros.h"
23 #include "tao/PortableServer/POA_Guard.h"
24 #include "tao/PortableServer/Creation_Time.h"
25 #include "tao/PortableServer/RequestProcessingStrategy.h"
26 #include "tao/PortableServer/LifespanStrategy.h"
27 #include "tao/PortableServer/IdUniquenessStrategy.h"
28 #include "tao/PortableServer/IdAssignmentStrategy.h"
29 #include "tao/PortableServer/ServantRetentionStrategy.h"
30 #include "tao/PortableServer/ImplicitActivationStrategy.h"
31 #include "tao/PortableServer/ThreadStrategy.h"
32 #include "tao/PortableServer/Acceptor_Filter_Factory.h"
33 #include "tao/PortableServer/Network_Priority_Hook.h"
35 #include "tao/StringSeqC.h"
36 #include "tao/PortableInterceptorC.h"
37 #include "tao/PolicyC.h"
38 #include "tao/ORB_Core.h"
40 #include "tao/Server_Strategy_Factory.h"
41 #include "tao/Acceptor_Registry.h"
42 #include "tao/Thread_Lane_Resources.h"
43 #include "tao/Exception.h"
45 #include "tao/Profile.h"
46 #include "tao/TSS_Resources.h"
47 #include "tao/IORInterceptor_Adapter.h"
48 #include "tao/debug.h"
51 #include "ace/Auto_Ptr.h"
52 #include "ace/Dynamic_Service.h"
53 #include "ace/OS_NS_netdb.h"
54 #include "ace/OS_NS_string.h"
55 #include "ace/OS_NS_unistd.h"
56 #include "ace/Log_Msg.h"
58 #if !defined (__ACE_INLINE__)
59 # include "tao/PortableServer/Root_POA.inl"
60 #endif /* ! __ACE_INLINE__ */
62 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
64 // This is the TAO_Object_key-prefix that is appended to all TAO Object keys.
65 // It's an array of octets representing ^t^a^o/0 in octal.
67 TAO_Root_POA::objectkey_prefix
[TAO_Root_POA::TAO_OBJECTKEY_PREFIX_SIZE
] = {
74 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
76 PortableServer::ThreadPolicy_ptr
77 TAO_Root_POA::create_thread_policy (PortableServer::ThreadPolicyValue value
)
79 TAO::Portable_Server::ThreadPolicy
*policy
= 0;
80 ACE_NEW_THROW_EX (policy
,
81 TAO::Portable_Server::ThreadPolicy (value
),
87 #endif /* TAO_HAS_MINIMUM_POA == 0 && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO) */
89 #if !defined (CORBA_E_MICRO)
91 PortableServer::LifespanPolicy_ptr
92 TAO_Root_POA::create_lifespan_policy (PortableServer::LifespanPolicyValue value
)
94 TAO::Portable_Server::LifespanPolicy
*policy
= 0;
95 ACE_NEW_THROW_EX (policy
,
96 TAO::Portable_Server::LifespanPolicy (value
),
104 #if !defined (CORBA_E_MICRO)
105 PortableServer::IdUniquenessPolicy_ptr
106 TAO_Root_POA::create_id_uniqueness_policy (PortableServer::IdUniquenessPolicyValue value
)
108 TAO::Portable_Server::IdUniquenessPolicy
*policy
= 0;
109 ACE_NEW_THROW_EX (policy
,
110 TAO::Portable_Server::IdUniquenessPolicy (value
),
111 CORBA::NO_MEMORY ());
117 #if !defined (CORBA_E_MICRO)
118 PortableServer::IdAssignmentPolicy_ptr
119 TAO_Root_POA::create_id_assignment_policy (PortableServer::IdAssignmentPolicyValue value
)
121 TAO::Portable_Server::IdAssignmentPolicy
*policy
= 0;
122 ACE_NEW_THROW_EX (policy
,
123 TAO::Portable_Server::IdAssignmentPolicy (value
),
124 CORBA::NO_MEMORY ());
130 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
132 PortableServer::ImplicitActivationPolicy_ptr
133 TAO_Root_POA::create_implicit_activation_policy (PortableServer::ImplicitActivationPolicyValue value
)
135 TAO::Portable_Server::ImplicitActivationPolicy
*policy
= 0;
136 ACE_NEW_THROW_EX (policy
,
137 TAO::Portable_Server::ImplicitActivationPolicy (value
),
138 CORBA::NO_MEMORY ());
143 PortableServer::ServantRetentionPolicy_ptr
144 TAO_Root_POA::create_servant_retention_policy (PortableServer::ServantRetentionPolicyValue value
)
146 TAO::Portable_Server::ServantRetentionPolicy
*policy
= 0;
147 ACE_NEW_THROW_EX (policy
,
148 TAO::Portable_Server::ServantRetentionPolicy (value
),
149 CORBA::NO_MEMORY ());
154 PortableServer::RequestProcessingPolicy_ptr
155 TAO_Root_POA::create_request_processing_policy (PortableServer::RequestProcessingPolicyValue value
)
157 TAO::Portable_Server::RequestProcessingPolicy
*policy
= 0;
158 ACE_NEW_THROW_EX (policy
,
159 TAO::Portable_Server::RequestProcessingPolicy (value
),
160 CORBA::NO_MEMORY ());
165 #endif /* TAO_HAS_MINIMUM_POA == 0 */
168 TAO_Root_POA::set_obj_ref_factory (
169 PortableInterceptor::ObjectReferenceFactory
*current_factory
)
171 TAO::ORT_Adapter
*adapter
= this->ORT_adapter ();
175 // Activate a different factory
176 this->ort_adapter_
->set_obj_ref_factory (current_factory
);
180 TAO_Root_POA::TAO_Root_POA (const TAO_Root_POA::String
&name
,
181 PortableServer::POAManager_ptr poa_manager
,
182 const TAO_POA_Policy_Set
&policies
,
183 TAO_Root_POA
*parent
,
185 TAO_SYNCH_MUTEX
&thread_lock
,
186 TAO_ORB_Core
&orb_core
,
187 TAO_Object_Adapter
*object_adapter
)
189 poa_manager_ (* (dynamic_cast <TAO_POA_Manager
*> (poa_manager
))),
191 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
192 poa_manager_factory_ (* (object_adapter
->poa_manager_factory_
)),
195 tagged_component_ (),
196 tagged_component_id_ (),
197 profile_id_array_ (0),
198 policies_ (policies
),
200 ort_adapter_factory_ (0),
201 adapter_state_ (PortableInterceptor::HOLDING
),
202 network_priority_hook_ (0),
203 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
204 adapter_activator_ (),
205 #endif /* TAO_HAS_MINIMUM_POA == 0 */
208 orb_core_ (orb_core
),
209 object_adapter_ (object_adapter
),
210 cleanup_in_progress_ (false),
211 outstanding_requests_ (0),
212 outstanding_requests_condition_ (thread_lock
),
213 wait_for_completion_pending_ (0),
214 waiting_destruction_ (false),
215 servant_deactivation_condition_ (thread_lock
),
216 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
219 caller_key_to_object_ (0),
220 servant_for_key_to_object_ (0)
222 // Since we are keeping a reference to a POAManager, we need to
223 // increment the reference count but we do this safely.
224 PortableServer::POAManager_var
pm_guard (
225 PortableServer::POAManager::_duplicate(&this->poa_manager_
));
227 // Parse the policies that are used in the critical path in
229 this->cached_policies_
.update (this->policies_
);
231 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
232 this->filter_factory_
233 = ACE_Dynamic_Service
<TAO_Acceptor_Filter_Factory
>::instance (
234 "TAO_Acceptor_Filter_Factory");
237 this->network_priority_hook_
238 = ACE_Dynamic_Service
<TAO_Network_Priority_Hook
>::instance (
239 "TAO_Network_Priority_Hook");
241 if (this->network_priority_hook_
!= 0)
243 this->network_priority_hook_
->update_network_priority (
244 *this, this->policies_
);
247 // Cache ort adapter factory
248 this->ort_adapter_factory_
249 = ACE_Dynamic_Service
<TAO::ORT_Adapter_Factory
>::instance
250 (orb_core_
.configuration (), TAO_Root_POA::ort_adapter_factory_name ());
252 #if (TAO_HAS_MINIMUM_POA == 1)
253 // If this is the RootPOA, set the value of the ImplicitActivationPolicy
254 // to IMPLICIT_ACTIVATION since it is impossible to pass the policy
255 // as it is not compiled into the library.
257 // If the ImplicitActivationPolicy policy is ever compiled in the
258 // minimum POA builds, remove this code and remove the guards
259 // in Object_Adapter.cpp when changing the default policy for the
261 if (ACE_OS::strcmp (this->name_
.c_str (),
262 TAO_DEFAULT_ROOTPOA_NAME
) == 0)
264 this->cached_policies_
.implicit_activation
265 (PortableServer::IMPLICIT_ACTIVATION
);
267 #endif /* TAO_HAS_MINIMUM_POA == 1 */
269 // Set the active strategies to be used by this POA
270 this->active_policy_strategies_
.update (this->cached_policies_
,
272 TAO::Portable_Server::Active_Policy_Strategies_Cleanup_Guard
aps_cleanup_guard (
273 &this->active_policy_strategies_
);
275 // Set the folded name of this POA.
276 this->set_folded_name (parent
);
278 // Register self with manager.
279 int result
= this->poa_manager_
.register_poa (this);
282 throw ::CORBA::OBJ_ADAPTER ();
285 // Add self to Object Adapter class.
287 this->object_adapter ().bind_poa (this->folded_name_
,
289 this->system_name_
.out ());
292 // Remove from POA Manager in case of errors. No checks of
294 this->poa_manager_
.remove_poa (this);
296 throw ::CORBA::OBJ_ADAPTER ();
299 // Set the id for this POA.
300 this->set_id (parent
);
302 // Notify the Lifespan strategy of our startup
305 this->active_policy_strategies_
.lifespan_strategy()->notify_startup ();
307 catch (const ::CORBA::Exception
&)
309 this->poa_manager_
.remove_poa (this);
310 this->object_adapter ().unbind_poa (this,
312 this->system_name_
.in ());
316 // Now when everything is fine we can release the quards.
318 aps_cleanup_guard
._retn ();
321 TAO_Root_POA::~TAO_Root_POA ()
323 this->poa_manager_
._remove_ref();
327 TAO_Root_POA::complete_destruction_i ()
329 bool doing_complete_destruction
=
330 this->waiting_destruction_
!= false;
332 // No longer awaiting destruction.
333 this->waiting_destruction_
= false;
335 PortableServer::POA_var poa
;
336 TAO::ORT_Array my_array_obj_ref_template
;
337 TAO::ORT_Adapter
*ort_adapter
= 0;
338 if (doing_complete_destruction
)
341 this->ORT_adapter_i ();
343 // In case no ORT library is linked we get zero.
344 if (ort_adapter
!= 0)
346 // Get the ObjectReferenceTemplate.
347 PortableInterceptor::ObjectReferenceTemplate
* const ort
=
348 ort_adapter
->get_adapter_template ();
350 // Add it to the sequence of object reference templates, we
351 // just notify for ourselves that we are now non_existent,
352 // our childs will do it for themselves.
353 my_array_obj_ref_template
.size (1);
354 my_array_obj_ref_template
[0] = ort
;
357 poa
= PortableServer::POA::_duplicate (this);
360 // Remove POA from the POAManager.
361 if (this->poa_manager_
.remove_poa (this) != 0)
362 throw ::CORBA::OBJ_ADAPTER ();
364 // Remove POA from the Object Adapter.
365 int result
= this->object_adapter ().unbind_poa (this,
367 this->system_name_
.in ());
369 throw ::CORBA::OBJ_ADAPTER ();
371 // Cleanup all strategies
372 this->active_policy_strategies_
.cleanup ();
374 // Forced cleanup. The new memory management scheme is evil and can
375 // lead to reference deadlock, i.e., POA holds object A, but POA
376 // cannot die because object A hold POA.
379 // If new things are added to this cleanup code, make sure to move
380 // the minimum CORBA #define after the declaration of
381 // <non_servant_upcall>.
384 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
386 // ATTENTION: Trick locking here, see class header for details
387 TAO::Portable_Server::Non_Servant_Upcall
non_servant_upcall (*this);
388 ACE_UNUSED_ARG (non_servant_upcall
);
390 this->adapter_activator_
= PortableServer::AdapterActivator::_nil ();
392 #endif /* TAO_HAS_MINIMUM_POA == 0 */
396 ::CORBA::release (this);
398 if (doing_complete_destruction
)
400 this->adapter_state_
= PortableInterceptor::NON_EXISTENT
;
402 this->adapter_state_changed (my_array_obj_ref_template
,
403 this->adapter_state_
);
405 if (ort_adapter
!= 0)
407 ort_adapter
->release (my_array_obj_ref_template
[0]);
409 if (this->ort_adapter_factory_
)
411 this->ort_adapter_factory_
->destroy (ort_adapter
);
414 this->ort_adapter_
= 0;
419 #if ! defined (CORBA_E_MICRO)
420 PortableServer::POA_ptr
421 TAO_Root_POA::create_POA_i (const char *adapter_name
,
422 PortableServer::POAManager_ptr poa_manager
,
423 const CORBA::PolicyList
&policies
)
425 // Initialize a TAO_POA_Policy_Set instance so that it contains the
426 // default POA policies.
427 TAO_POA_Policy_Set
tao_policies (this->object_adapter ().default_poa_policies ());
429 // Merge policies from the ORB level.
430 this->object_adapter ().validator ().merge_policies (tao_policies
.policies ());
432 // Merge in any policies that the user may have specified.
433 tao_policies
.merge_policies (policies
);
435 // If any of the policy objects specified are not valid for the ORB
436 // implementation, if conflicting policy objects are specified, or
437 // if any of the specified policy objects require prior
438 // administrative action that has not been performed, an
439 // InvalidPolicy exception is raised containing the index in the
440 // policies parameter value of the first offending policy object.
441 tao_policies
.validate_policies (this->object_adapter ().validator (),
444 // If the poa_manager parameter is null, a new POAManager object is
445 // created and associated with the new POA. Otherwise, the specified
446 // POAManager object is associated with the new POA. The POAManager
447 // object can be obtained using the attribute name the_POAManager.
449 PortableServer::POAManager_var the_poa_manager
;
451 if (CORBA::is_nil (poa_manager
))
453 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT)
455 PortableServer::POA_var poa
= PortableServer::POA::_duplicate (this);
456 PortableServer::POA_var root_poa
;
458 // Find the RootPOA by traversing the POA hierarchy until the
459 // RootPOA is reached. The RootPOA has no parent.
460 while (!CORBA::is_nil (poa
.in ()))
463 poa
= poa
->the_parent ();
466 // Get the POAManagerFactory instance owned by RootPOA.
467 PortableServer::POAManagerFactory_var tao_poa_manager_factory
468 = root_poa
->the_POAManagerFactory ();
470 CORBA::PolicyList empty_policies
;
472 // The POAManager name will be generated when the POAManager instance
475 = tao_poa_manager_factory
->create_POAManager (0, empty_policies
);
478 PortableServer::POAManager_ptr the_poa_manager_ptr
;
479 ACE_NEW_THROW_EX (the_poa_manager_ptr
,
480 TAO_POA_Manager (this->object_adapter (), 0),
481 CORBA::NO_MEMORY ());
482 the_poa_manager
= the_poa_manager_ptr
;
483 #endif /* TAO_HAS_MINIMUM_POA == 0 && ! CORBA_E_COMPACT) */
488 the_poa_manager
= PortableServer::POAManager::_duplicate (poa_manager
);
491 PortableServer::POA_var poa
= this->create_POA_i (adapter_name
,
492 the_poa_manager
.in (),
497 #endif /* !CORBA_E_MICRO */
499 #if ! defined (CORBA_E_MICRO)
501 TAO_Root_POA::new_POA (const String
&name
,
502 PortableServer::POAManager_ptr poa_manager
,
503 const TAO_POA_Policy_Set
&policies
,
504 TAO_Root_POA
*parent
,
506 TAO_SYNCH_MUTEX
&thread_lock
,
507 TAO_ORB_Core
&orb_core
,
508 TAO_Object_Adapter
*object_adapter
)
510 TAO_Regular_POA
*poa
= 0;
512 ACE_NEW_THROW_EX (poa
,
513 TAO_Regular_POA (name
,
521 CORBA::NO_MEMORY ());
526 PortableServer::POA_ptr
527 TAO_Root_POA::create_POA_i (const TAO_Root_POA::String
&adapter_name
,
528 PortableServer::POAManager_ptr poa_manager
,
529 const TAO_POA_Policy_Set
&policies
)
531 // This operation creates a new POA as a child of the target POA. The
532 // specified name identifies the new POA with respect to other POAs
533 // with the same parent POA. If the target POA already has a child
534 // POA with the specified name, the AdapterAlreadyExists exception
537 if (this->children_
.find (adapter_name
) != -1)
539 throw PortableServer::POA::AdapterAlreadyExists ();
543 // Child was not found. Create one.
546 // The specified policy objects are associated with the POA and used
547 // to control its behavior. The policy objects are effectively
548 // copied before this operation returns, so the application is free
549 // to destroy them while the POA is in use. Policies are not
550 // inherited from the parent POA.
551 TAO_Root_POA
* poa
= this->new_POA (adapter_name
,
555 this->object_adapter ().lock (),
556 this->object_adapter ().thread_lock (),
558 this->object_adapter_
);
560 // Give ownership of the new map to the POA_var. Note, that it
561 // is important for the POA_var to take ownership before
562 // checking for exception since we may need to delete the new map.
563 PortableServer::POA_var new_poa
= poa
;
565 // Check for exception in construction of the POA.
567 // Add to children map
568 if (this->children_
.bind (adapter_name
, poa
) != 0)
570 throw ::CORBA::OBJ_ADAPTER ();
573 // Increment the reference count on the child POA since the children
574 // map must retain ownership. Do so immediately before any other
575 // operations to prevent memory cleanup problems induced from
579 // Iterate over the registered IOR interceptors so that they may be
580 // given the opportunity to add tagged components to the profiles
582 poa
->establish_components ();
584 // Note: Creating a POA using a POA manager that is in the active
585 // state can lead to race conditions if the POA supports preexisting
586 // objects, because the new POA may receive a request before its
587 // adapter activator, servant manager, or default servant have been
588 // initialized. These problems do not occur if the POA is created by
589 // an adapter activator registered with a parent of the new POA,
590 // because requests are queued until the adapter activator
591 // returns. To avoid these problems when a POA must be explicitly
592 // initialized, the application can initialize the POA by invoking
593 // find_POA with a TRUE activate parameter.
595 // Everything is fine. Don't let the POA_var release the
597 return new_poa
._retn ();
601 #if ! defined (CORBA_E_MICRO)
602 PortableServer::POA_ptr
603 TAO_Root_POA::find_POA (const char *adapter_name
,
604 CORBA::Boolean activate_it
)
606 // Lock access for the duration of this transaction.
607 TAO_POA_GUARD_RETURN (0);
609 TAO_Root_POA
*poa
= this->find_POA_i (adapter_name
, activate_it
);
611 return PortableServer::POA::_duplicate (poa
);
615 #if ! defined (CORBA_E_MICRO)
617 TAO_Root_POA::find_POA_i (const ACE_CString
&child_name
,
618 CORBA::Boolean activate_it
)
620 TAO_Root_POA
*child
= 0;
621 int result
= this->children_
.find (child_name
, child
);
623 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT)
629 if (!CORBA::is_nil (this->adapter_activator_
.in ()))
632 this->check_state ();
634 CORBA::Boolean success
= false;
637 // ATTENTION: Trick locking here, see class header for details
638 TAO::Portable_Server::Non_Servant_Upcall
non_servant_upcall (
640 ACE_UNUSED_ARG (non_servant_upcall
);
642 // When unknown_adapter gives a system exception, the POA
643 // should just pass the system exception through
644 // See 15.3.9.2 of the 3.1 CORBA spec
646 this->adapter_activator_
->unknown_adapter (
648 child_name
.c_str ());
653 result
= this->children_
.find (child_name
,
672 ACE_UNUSED_ARG (activate_it
);
673 #endif /* TAO_HAS_MINIMUM_POA == 0 */
681 // Otherwise, the AdapterNonExistent exception is raised.
682 throw PortableServer::POA::AdapterNonExistent ();
688 TAO_Root_POA::tao_poa_manager ()
693 #if ! defined (CORBA_E_MICRO)
694 PortableServer::POA_ptr
695 TAO_Root_POA::create_POA (const char *adapter_name
,
696 PortableServer::POAManager_ptr poa_manager
,
697 const CORBA::PolicyList
&policies
)
699 // Lock access for the duration of this transaction.
700 TAO_POA_GUARD_RETURN (0);
702 return this->create_POA_i (adapter_name
, poa_manager
, policies
);
706 PortableServer::ObjectId
*
707 TAO_Root_POA::servant_to_id (PortableServer::Servant servant
)
709 // If we had upgradeable locks, this would initially be a read lock
711 // Lock access for the duration of this transaction.
712 TAO_POA_GUARD_RETURN (0);
714 return this->servant_to_id_i (servant
);
717 PortableServer::ObjectId
*
718 TAO_Root_POA::servant_to_user_id (PortableServer::Servant servant
)
720 return this->active_policy_strategies_
.servant_retention_strategy()->
721 servant_to_user_id (servant
);
724 PortableServer::Servant
725 TAO_Root_POA::reference_to_servant (CORBA::Object_ptr reference
)
727 // Lock access for the duration of this transaction.
728 TAO_POA_GUARD_RETURN (0);
730 return this->reference_to_servant_i (reference
);
734 TAO_Root_POA::servant_to_reference (PortableServer::Servant servant
)
736 TAO_POA_GUARD_RETURN (CORBA::Object::_nil ());
738 return this->servant_to_reference_i (servant
);
741 PortableServer::POAList
*
742 TAO_Root_POA::the_children ()
744 // Lock access for the duration of this transaction.
745 TAO_POA_GUARD_RETURN (0);
747 return this->the_children_i ();
751 PortableServer::Servant
752 TAO_Root_POA::id_to_servant (const PortableServer::ObjectId
&oid
)
754 // Lock access for the duration of this transaction.
755 TAO_POA_GUARD_RETURN (0);
757 return this->id_to_servant_i (oid
);
761 TAO_Root_POA::id_to_reference (const PortableServer::ObjectId
&oid
)
763 // Lock access for the duration of this transaction.
764 TAO_POA_GUARD_RETURN (0);
766 return this->id_to_reference_i (oid
, true);
770 #if ! defined (CORBA_E_MICRO)
772 TAO_Root_POA::create_reference_with_id (const PortableServer::ObjectId
&id
,
775 // Lock access for the duration of this transaction.
776 TAO_POA_GUARD_RETURN (CORBA::Object::_nil ());
778 return this->create_reference_with_id_i (id
,
780 this->server_priority ());
785 TAO_Root_POA::destroy (CORBA::Boolean etherealize_objects
,
786 CORBA::Boolean wait_for_completion
)
788 // Lock access for the duration of this transaction.
789 TAO::Portable_Server::POA_Guard
poa_guard (*this , 0);
790 ACE_UNUSED_ARG (poa_guard
);
792 this->destroy_i (etherealize_objects
, wait_for_completion
);
796 TAO_Root_POA::remove_from_parent_i ()
798 // The root poa has no parent, so this is a noop
802 TAO_Root_POA::destroy_i (CORBA::Boolean etherealize_objects
,
803 CORBA::Boolean wait_for_completion
)
805 if (this->cleanup_in_progress_
)
808 // Is the <wait_for_completion> semantics for this thread correct?
809 TAO_Root_POA::check_for_valid_wait_for_completions (this->orb_core (),
810 wait_for_completion
);
812 this->cleanup_in_progress_
= true;
814 // Inform the custom servant dispatching strategy to stop the working
815 // threads when the poa is destroyed.
816 this->poa_deactivated_hook ();
818 // This operation destroys the POA and all descendant POAs. The POA
819 // so destroyed (that is, the POA with its name) may be re-created
820 // later in the same process. (This differs from the
821 // POAManager::deactivate operation that does not allow a
822 // re-creation of its associated POA in the same process.)
824 // Remove POA from the parent
825 this->remove_from_parent_i ();
827 TAO::ORT_Array
array_obj_ref_template (1);
831 // Gather all ObjectReferenceTemplates and change all adapter states
833 for (CHILDREN::iterator iterator
= this->children_
.begin ();
834 iterator
!= this->children_
.end ();
837 TAO_Root_POA
* const child_poa
= (*iterator
).int_id_
;
839 TAO::ORT_Adapter
* const adapter
= child_poa
->ORT_adapter_i ();
841 // In case no ORT library is linked we get zero.
844 // Get the ObjectReferenceTemplate for the child POA.
845 PortableInterceptor::ObjectReferenceTemplate
* const ort
=
846 adapter
->get_adapter_template ();
848 // Add it to the sequence of object reference templates that
849 // will be destroyed.
850 array_obj_ref_template
.size (1);
852 array_obj_ref_template
[0] = ort
;
855 child_poa
->adapter_state_
=
856 PortableInterceptor::INACTIVE
;
858 // Notify the state changes to the IORInterceptors
859 this->adapter_state_changed (array_obj_ref_template
,
860 PortableInterceptor::INACTIVE
);
863 adapter
->release (array_obj_ref_template
[0]);
868 // Destroy all child POA's now.
869 for (CHILDREN::iterator destroy_iterator
= this->children_
.begin ();
870 destroy_iterator
!= this->children_
.end ();
873 TAO_Root_POA
*destroy_child_poa
= (*destroy_iterator
).int_id_
;
875 destroy_child_poa
->destroy_i (etherealize_objects
,
876 wait_for_completion
);
879 // Notify the lifespan strategy of our shutdown
880 this->active_policy_strategies_
.lifespan_strategy()->notify_shutdown ();
882 // @todo, is the exception handling above correct, should we just fail when
883 // the notify above fails
885 // When a POA is destroyed, any requests that have started execution
886 // continue to completion. Any requests that have not started
887 // execution are processed as if they were newly arrived, that is,
888 // the POA will attempt to cause recreation of the POA by invoking
889 // one or more adapter activators as described in Section 3.3.3.
890 // If the wait_for_completion parameter is TRUE, the destroy
891 // operation will return only after all requests in process have
892 // completed and all invocations of etherealize have
893 // completed. Otherwise, the destroy operation returns after
894 // destroying the POAs.
896 this->deactivate_all_objects_i (etherealize_objects
,
897 wait_for_completion
);
899 // If there are no outstanding requests and that we are not in a
900 // non-servant upcall or if we are in a non-servant upcall, make
901 // sure we are the POA related to the non-servant upcall.
902 TAO::Portable_Server::Non_Servant_Upcall
*non_servant_upcall_in_progress
=
903 this->object_adapter ().non_servant_upcall_in_progress ();
904 if (this->outstanding_requests_
== 0 &&
905 (non_servant_upcall_in_progress
== 0 ||
906 &non_servant_upcall_in_progress
->poa () != this))
908 TAO::ORT_Array my_array_obj_ref_template
;
910 TAO::ORT_Adapter
* const ort_adapter
=
911 this->ORT_adapter_i ();
913 // In case no ORT library is linked we get zero.
914 if (ort_adapter
!= 0)
916 // Get the ObjectReferenceTemplate.
917 PortableInterceptor::ObjectReferenceTemplate
* const ort
=
918 ort_adapter
->get_adapter_template ();
920 // Add it to the sequence of object reference templates, we
921 // just notify for ourselves that we are now non_existent,
922 // our childs will do it for themselves.
923 my_array_obj_ref_template
.size (1);
924 my_array_obj_ref_template
[0] = ort
;
927 // According to the ORT spec, after a POA is destroyed, its state
928 // has to be changed to NON_EXISTENT and all the registered
929 // interceptors are to be informed. Since, the POA is destroyed
930 // and is released in the complete_destruction_i method, we are
931 // trying to keep the poa still around by doing a duplicate of
933 PortableServer::POA_var poa
= PortableServer::POA::_duplicate (this);
935 this->complete_destruction_i ();
937 this->adapter_state_
= PortableInterceptor::NON_EXISTENT
;
939 this->adapter_state_changed (my_array_obj_ref_template
,
940 this->adapter_state_
);
942 if (ort_adapter
!= 0)
944 ort_adapter
->release (my_array_obj_ref_template
[0]);
946 if (this->ort_adapter_factory_
)
948 this->ort_adapter_factory_
->destroy (ort_adapter
);
951 this->ort_adapter_
= 0;
956 // Mark that we are ready for destruction.
957 this->waiting_destruction_
= true;
962 TAO_Root_POA::delete_child (const TAO_Root_POA::String
&child
)
966 // If we are not closing down, we must remove this child from our
968 if (!this->cleanup_in_progress_
)
969 result
= this->children_
.unbind (child
);
971 // Otherwise, if we are closing down, we are currently iterating
972 // over our children and there is not need to remove this child from
978 PortableServer::POAList
*
979 TAO_Root_POA::the_children_i ()
981 PortableServer::POAList_var children
;
982 CORBA::ULong child_current
= static_cast <CORBA::ULong
>
983 (this->children_
.current_size ());
984 ACE_NEW_THROW_EX (children
,
985 PortableServer::POAList (child_current
),
986 CORBA::NO_MEMORY ());
988 children
->length (child_current
);
990 CORBA::ULong index
= 0;
991 for (CHILDREN::iterator iterator
= this->children_
.begin ();
992 iterator
!= this->children_
.end ();
995 TAO_Root_POA
*child_poa
= (*iterator
).int_id_
;
996 children
[index
] = PortableServer::POA::_duplicate (child_poa
);
999 return children
._retn ();
1002 PortableInterceptor::AdapterName
*
1003 TAO_Root_POA::adapter_name_i ()
1005 // The adapter name is the sequence of names starting from the
1006 // RootPOA to the one whose name is requested. The name of the
1007 // RootPOA is "RootPOA".
1009 PortableServer::POA_var poa
= PortableServer::POA::_duplicate (this);
1011 CORBA::ULong len
= 0;
1013 // Find the length of the adapter name sequence by traversing the
1014 // POA hierarchy until the RootPOA is reached. The RootPOA has no
1016 while (!CORBA::is_nil (poa
.in ()))
1018 poa
= poa
->the_parent ();
1022 // Empty adapter name sequence.
1023 PortableInterceptor::AdapterName
*names
= 0;
1024 ACE_NEW_THROW_EX (names
,
1025 PortableInterceptor::AdapterName (len
),
1027 CORBA::SystemException::_tao_minor_code (
1030 CORBA::COMPLETED_NO
));
1032 PortableInterceptor::AdapterName_var
safe_names (names
);
1034 names
->length (len
);
1036 poa
= PortableServer::POA::_duplicate (this);
1038 (*names
)[0] = CORBA::string_dup ("RootPOA");
1040 // Fill in the AdapterName sequence as the POA hierarchy is
1042 CORBA::ULong ilen
= len
;
1043 for (CORBA::ULong i
= 1; i
< len
; ++i
)
1045 (*names
)[--ilen
] = poa
->the_name ();
1047 poa
= poa
->the_parent ();
1049 // If this condition asserts, the POA hierarchy was modified
1050 // (i.e. reduced in size) by another thread!
1051 ACE_ASSERT ((ilen
> 0 ? !CORBA::is_nil (poa
.in ()) : 1));
1054 return safe_names
._retn ();
1058 TAO_Root_POA::add_ior_component (TAO_MProfile
& mprofile
,
1059 const IOP::TaggedComponent
&component
)
1061 // Add the given tagged component to all profiles.
1062 const CORBA::ULong profile_count
= mprofile
.profile_count ();
1064 for (CORBA::ULong i
= 0; i
< profile_count
; ++i
)
1066 TAO_Profile
*profile
= mprofile
.get_profile (i
);
1068 profile
->add_tagged_component (component
);
1073 TAO_Root_POA::add_ior_component_to_profile (
1074 TAO_MProfile
& mprofile
,
1075 const IOP::TaggedComponent
&component
,
1076 IOP::ProfileId profile_id
)
1078 // Add the given tagged component to all profiles matching the given
1080 bool found_profile
= false;
1082 CORBA::ULong
const profile_count
= mprofile
.profile_count ();
1084 for (CORBA::ULong i
= 0; i
< profile_count
; ++i
)
1086 TAO_Profile
*profile
= mprofile
.get_profile (i
);
1088 if (profile
->tag () == profile_id
)
1090 profile
->add_tagged_component (component
);
1092 found_profile
= true;
1096 // According to the Portable Interceptor specification, we're
1097 // supposed to throw a CORBA::BAD_PARAM exception if no profile
1098 // matched the given ProfileId.
1099 if (found_profile
== false)
1100 throw ::CORBA::BAD_PARAM (CORBA::OMGVMCID
| 29, CORBA::COMPLETED_NO
);
1104 TAO_Root_POA::adapter_state_changed (
1105 const TAO::ORT_Array
&array_obj_ref_template
,
1106 PortableInterceptor::AdapterState state
)
1108 TAO_IORInterceptor_Adapter
*ior_adapter
=
1109 this->orb_core_
.ior_interceptor_adapter ();
1113 ior_adapter
->adapter_state_changed (array_obj_ref_template
, state
);
1117 PortableServer::ObjectId
*
1118 TAO_Root_POA::activate_object_i (PortableServer::Servant servant
,
1119 CORBA::Short priority
,
1120 bool &wait_occurred_restart_call
)
1122 return this->active_policy_strategies_
.servant_retention_strategy()->
1123 activate_object (servant
,
1125 wait_occurred_restart_call
);
1128 PortableServer::ObjectId
*
1129 TAO_Root_POA::activate_object (PortableServer::Servant servant
)
1133 bool wait_occurred_restart_call
= false;
1135 // Lock access for the duration of this transaction.
1136 TAO_POA_GUARD_RETURN (0);
1138 PortableServer::ObjectId
*result
=
1139 this->activate_object_i (servant
,
1140 this->server_priority (),
1141 wait_occurred_restart_call
);
1143 // If we ended up waiting on a condition variable, the POA state
1144 // may have changed while we are waiting. Therefore, we need to
1145 // restart this call.
1146 if (wait_occurred_restart_call
)
1154 TAO_Root_POA::activate_object_with_id (const PortableServer::ObjectId
&id
,
1155 PortableServer::Servant servant
)
1159 bool wait_occurred_restart_call
= false;
1161 // Lock access for the duration of this transaction.
1164 this->activate_object_with_id_i (id
,
1166 this->server_priority (),
1167 wait_occurred_restart_call
);
1169 // If we ended up waiting on a condition variable, the POA state
1170 // may have changed while we are waiting. Therefore, we need to
1171 // restart this call.
1172 if (wait_occurred_restart_call
)
1180 TAO_Root_POA::activate_object_with_id_i (const PortableServer::ObjectId
&id
,
1181 PortableServer::Servant servant
,
1182 CORBA::Short priority
,
1183 bool &wait_occurred_restart_call
)
1185 this->active_policy_strategies_
.servant_retention_strategy()->
1186 activate_object_with_id (id
,
1189 wait_occurred_restart_call
);
1193 TAO_Root_POA::deactivate_all_objects_i (CORBA::Boolean etherealize_objects
,
1194 CORBA::Boolean wait_for_completion
)
1196 this->deactivate_all_objects_i (etherealize_objects
);
1198 this->wait_for_completions (wait_for_completion
);
1202 TAO_Root_POA::wait_for_completions (CORBA::Boolean wait_for_completion
)
1204 while (wait_for_completion
&&
1205 this->outstanding_requests_
> 0)
1207 this->wait_for_completion_pending_
= true;
1209 int const result
= this->outstanding_requests_condition_
.wait ();
1212 throw ::CORBA::OBJ_ADAPTER ();
1219 TAO_Root_POA::check_for_valid_wait_for_completions (const TAO_ORB_Core
&orb_core
,
1220 CORBA::Boolean wait_for_completion
)
1222 if (wait_for_completion
)
1224 TAO::Portable_Server::POA_Current_Impl
*poa_current_impl
=
1225 static_cast <TAO::Portable_Server::POA_Current_Impl
*>
1226 (TAO_TSS_Resources::instance ()->poa_current_impl_
);
1230 // If wait_for_completion is TRUE and the current thread is
1231 // in an invocation context dispatched from some POA
1232 // belonging to the same ORB as this POA, the BAD_INV_ORDER
1233 // system exception with standard minor code 3 is raised and
1234 // POA destruction does not occur.
1235 if ((poa_current_impl
!= 0) && (poa_current_impl
->poa () != 0))
1237 if (&orb_core
== &poa_current_impl
->orb_core ())
1239 // CORBA 2.3 specifies which minor code corresponds
1240 // to this particular problem.
1241 throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID
| 3,
1242 CORBA::COMPLETED_NO
);
1249 poa_current_impl
->previous_current_impl_
;
1255 TAO_Root_POA::deactivate_all_objects_i (CORBA::Boolean etherealize_objects
)
1257 this->active_policy_strategies_
.request_processing_strategy ()->
1258 etherealize_objects (etherealize_objects
);
1260 this->active_policy_strategies_
.servant_retention_strategy ()->
1261 deactivate_all_objects ();
1265 TAO_Root_POA::deactivate_object (const PortableServer::ObjectId
&oid
)
1267 // Lock access for the duration of this transaction.
1270 this->deactivate_object_i (oid
);
1274 TAO_Root_POA::deactivate_object_i (const PortableServer::ObjectId
&id
)
1276 this->active_policy_strategies_
.servant_retention_strategy()->
1277 deactivate_object (id
);
1281 TAO_Root_POA::is_persistent () const
1283 return active_policy_strategies_
.lifespan_strategy()->is_persistent ();
1287 TAO_Root_POA::create_reference (const char *intf
)
1289 // Lock access for the duration of this transaction.
1290 TAO_POA_GUARD_RETURN (CORBA::Object::_nil ());
1292 return this->create_reference_i (intf
,
1293 this->server_priority ());
1297 TAO_Root_POA::create_reference_i (const char *intf
,
1298 CORBA::Short priority
)
1300 if (!this->has_system_id ())
1302 throw PortableServer::POA::WrongPolicy ();
1305 return this->active_policy_strategies_
.servant_retention_strategy()->
1306 create_reference (intf
, priority
);
1310 TAO_Root_POA::invoke_key_to_object_helper_i (const char * repository_id
,
1311 const PortableServer::ObjectId
& id
)
1313 const PortableInterceptor::ObjectId
&user_oid
=
1314 reinterpret_cast <const PortableInterceptor::ObjectId
&>(id
);
1316 // Ask the ORT to create the object.
1317 if (this->ORT_adapter_i ())
1319 // Ask the ORT to create the object.
1320 return this->ort_adapter_
->make_object (repository_id
, user_oid
);
1324 return this->invoke_key_to_object ();
1328 #if ! defined (CORBA_E_MICRO)
1330 TAO_Root_POA::create_reference_with_id_i (const PortableServer::ObjectId
&user_id
,
1332 CORBA::Short priority
)
1334 // If the POA has the SYSTEM_ID policy and it detects that the
1335 // Object Id value was not generated by the system or for this POA,
1336 // the create_reference_with_id operation may raise the BAD_PARAM
1337 // system exception. An ORB is not required to detect all such
1338 // invalid Object Id values, but a portable application must not
1339 // invoke this operation on a POA that has the SYSTEM_ID policy with
1340 // an Object Id value that was not previously generated by the
1341 // system for that POA, or, if the POA also has the PERSISTENT
1342 // policy, for a previous instantiation of the same POA.
1343 if (this->has_system_id () &&
1344 !this->is_poa_generated_id (user_id
))
1346 throw ::CORBA::BAD_PARAM (CORBA::OMGVMCID
| 14, CORBA::COMPLETED_NO
);
1349 return this->active_policy_strategies_
.servant_retention_strategy()->
1350 create_reference_with_id (user_id
, intf
, priority
);
1354 PortableServer::ObjectId
*
1355 TAO_Root_POA::servant_to_id_i (PortableServer::Servant servant
)
1357 return this->active_policy_strategies_
.request_processing_strategy()->
1358 servant_to_id (servant
);
1362 TAO_Root_POA::servant_to_reference_i (PortableServer::Servant servant
)
1364 return this->active_policy_strategies_
.servant_retention_strategy()->
1365 servant_to_reference (servant
);
1368 PortableServer::Servant
1369 TAO_Root_POA::reference_to_servant_i (CORBA::Object_ptr reference
)
1371 // Make sure that the reference is valid.
1372 if (CORBA::is_nil (reference
))
1374 throw ::CORBA::BAD_PARAM ();
1377 PortableServer::ObjectId system_id
;
1378 bool const is_generated
=
1379 this->is_poa_generated (reference
, system_id
);
1383 // In case this object reference is not generated by this POA throw
1385 throw PortableServer::POA::WrongAdapter ();
1388 PortableServer::Servant servant
=
1389 this->active_policy_strategies_
.request_processing_strategy()->
1390 system_id_to_servant (system_id
);
1394 // ATTENTION: Trick locking here, see class header for details
1395 TAO::Portable_Server::Non_Servant_Upcall
non_servant_upcall (*this);
1396 ACE_UNUSED_ARG (non_servant_upcall
);
1398 // The POA invokes _add_ref once on the Servant before returning
1399 // it. If the application uses reference counting, the caller of
1400 // id_to_servant is responsible for invoking _remove_ref once on
1401 // the returned Servant when it is finished with it. A
1402 // conforming caller need not invoke _remove_ref on the returned
1403 // Servant if the type of the Servant uses the default reference
1404 // counting inherited from ServantBase.
1405 servant
->_add_ref ();
1412 TAO_Root_POA::is_poa_generated (CORBA::Object_ptr reference
,
1413 PortableServer::ObjectId
&system_id
)
1415 TAO::ObjectKey_var key
= reference
->_key ();
1417 TAO_Object_Adapter::poa_name poa_system_name
;
1418 CORBA::Boolean is_root
= false;
1419 CORBA::Boolean is_persistent
= false;
1420 CORBA::Boolean is_system_id
= false;
1421 TAO::Portable_Server::Temporary_Creation_Time poa_creation_time
;
1423 int const result
= this->parse_key (key
.in (),
1431 || (this->root () == 0 && poa_system_name
!= this->system_name ())
1432 || is_root
!= this->root ()
1433 || is_system_id
!= this->system_id ()
1434 || !this->validate_lifespan (is_persistent
, poa_creation_time
))
1436 // The passed reference is NOT generated by this POA.
1441 // The passed reference is generated by this POA.
1446 PortableServer::ObjectId
*
1447 TAO_Root_POA::reference_to_id (CORBA::Object_ptr reference
)
1449 // Make sure that the reference is valid.
1450 if (CORBA::is_nil (reference
))
1452 throw ::CORBA::BAD_PARAM ();
1455 // The WrongPolicy exception is declared to allow future extensions.
1457 // This operation is valid only if the reference was created by the
1458 // POA on which the operation is being performed. If the object
1459 // reference was not created by this POA, the WrongAdapter exception
1461 PortableServer::ObjectId system_id
;
1462 bool const is_generated
= this->is_poa_generated (reference
, system_id
);
1466 throw PortableServer::POA::WrongAdapter ();
1469 // Lock access for the duration of this transaction.
1470 TAO_POA_GUARD_RETURN (0);
1472 return this->active_policy_strategies_
.servant_retention_strategy()->
1473 system_id_to_object_id (system_id
);
1476 PortableServer::Servant
1477 TAO_Root_POA::find_servant (const PortableServer::ObjectId
&system_id
)
1479 return this->active_policy_strategies_
.servant_retention_strategy()->
1480 find_servant (system_id
);
1484 TAO_Root_POA::unbind_using_user_id (const PortableServer::ObjectId
&user_id
)
1486 return this->active_policy_strategies_
.servant_retention_strategy()->
1487 unbind_using_user_id (user_id
);
1491 TAO_Root_POA::cleanup_servant (
1492 PortableServer::Servant servant
,
1493 const PortableServer::ObjectId
&user_id
)
1495 this->active_policy_strategies_
.request_processing_strategy()->
1496 cleanup_servant (servant
, user_id
);
1499 PortableServer::Servant
1500 TAO_Root_POA::id_to_servant_i (const PortableServer::ObjectId
&id
)
1503 PortableServer::Servant servant
=
1504 this->active_policy_strategies_
.request_processing_strategy()->
1509 // ATTENTION: Trick locking here, see class header for details
1510 TAO::Portable_Server::Non_Servant_Upcall
non_servant_upcall (*this);
1511 ACE_UNUSED_ARG (non_servant_upcall
);
1513 // The POA invokes _add_ref once on the Servant before returning
1514 // it. If the application uses reference counting, the caller of
1515 // id_to_servant is responsible for invoking _remove_ref once on
1516 // the returned Servant when it is finished with it. A
1517 // conforming caller need not invoke _remove_ref on the returned
1518 // Servant if the type of the Servant uses the default reference
1519 // counting inherited from ServantBase.
1520 servant
->_add_ref ();
1526 PortableServer::Servant
1527 TAO_Root_POA::user_id_to_servant_i (const PortableServer::ObjectId
&id
)
1529 return this->active_policy_strategies_
.servant_retention_strategy()->
1530 user_id_to_servant (id
);
1534 TAO_Root_POA::id_to_reference_i (const PortableServer::ObjectId
&id
,
1537 return this->active_policy_strategies_
.servant_retention_strategy()->
1538 id_to_reference (id
, indirect
);
1544 CORBA::OctetSeq
*id
= 0;
1545 ACE_NEW_THROW_EX (id
,
1546 CORBA::OctetSeq (this->id_
),
1547 CORBA::NO_MEMORY ());
1552 PortableServer::Servant
1553 TAO_Root_POA::locate_servant_i (const char *operation
,
1554 const PortableServer::ObjectId
&system_id
,
1555 TAO::Portable_Server::Servant_Upcall
&servant_upcall
,
1556 TAO::Portable_Server::POA_Current_Impl
&poa_current_impl
,
1557 bool &wait_occurred_restart_call
)
1559 return this->active_policy_strategies_
.request_processing_strategy()->
1560 locate_servant (operation
,
1564 wait_occurred_restart_call
);
1569 TAO_Root_POA::parse_key (const TAO::ObjectKey
&key
,
1570 TAO_Object_Adapter::poa_name
&poa_system_name
,
1571 PortableServer::ObjectId
&system_id
,
1572 CORBA::Boolean
&is_root
,
1573 CORBA::Boolean
&is_persistent
,
1574 CORBA::Boolean
&is_system_id
,
1575 TAO::Portable_Server::Temporary_Creation_Time
&poa_creation_time
)
1577 // Get the object key octets.
1578 const CORBA::Octet
*key_data
= key
.get_buffer ();
1580 // Skip the object key prefix since we have already checked for this.
1581 CORBA::ULong starting_at
= TAO_OBJECTKEY_PREFIX_SIZE
;
1583 // Check the root indicator.
1584 char root_key_type
= key_data
[starting_at
];
1585 if (root_key_type
== TAO_Root_POA::root_key_char ())
1589 else if (root_key_type
== TAO_Root_POA::non_root_key_char ())
1599 // Skip past the system id indicator
1600 starting_at
+= TAO_Root_POA::root_key_type_length ();
1602 // Check the system id indicator.
1603 char system_id_key_type
= key_data
[starting_at
];
1604 if (system_id_key_type
== TAO_Root_POA::system_id_key_char ())
1606 is_system_id
= true;
1608 else if (system_id_key_type
== TAO_Root_POA::user_id_key_char ())
1610 is_system_id
= false;
1618 // Skip past the system id indicator
1619 starting_at
+= TAO_Root_POA::system_id_key_type_length ();
1621 // Check the persistence indicator
1622 char persistent_key_type
= key_data
[starting_at
];
1623 if (persistent_key_type
== TAO_Root_POA::persistent_key_char ())
1625 is_persistent
= true;
1627 else if (persistent_key_type
== TAO_Root_POA::transient_key_char ())
1629 is_persistent
= false;
1637 // Skip past the persistent indicator
1638 starting_at
+= TAO_Root_POA::persistent_key_type_length ();
1640 #if (POA_NO_TIMESTAMP == 0)
1641 // Grab the timestamp for transient POAs.
1644 // Take the creation time for the timestamp
1645 poa_creation_time
.creation_time (key_data
+ starting_at
);
1647 // Skip past the timestamp
1648 starting_at
+= TAO::Portable_Server::Creation_Time::creation_time_length ();
1651 ACE_UNUSED_ARG (poa_creation_time
);
1652 #endif /* POA_NO_TIMESTAMP */
1654 // Calculate the size of the POA name.
1655 CORBA::ULong poa_name_size
= 0;
1658 // Transient POAs have fixed size.
1659 poa_name_size
= TAO_Object_Adapter::transient_poa_name_size ();
1661 else if (is_system_id
)
1663 // System ids have fixed size.
1664 poa_name_size
= static_cast <CORBA::ULong
>
1665 (key
.length () - starting_at
-
1666 TAO_Active_Object_Map::system_id_size ());
1670 // Get the size from the object key.
1671 ACE_OS::memcpy (&poa_name_size
,
1672 key_data
+ starting_at
,
1673 sizeof (poa_name_size
));
1674 poa_name_size
= ACE_NTOHL (poa_name_size
);
1676 starting_at
+= sizeof (poa_name_size
);
1679 // Grep the name if there is a name
1682 poa_system_name
.replace (poa_name_size
,
1684 (CORBA::Octet
*) key_data
+ starting_at
,
1687 starting_at
+= poa_name_size
;
1690 // The rest is the system id.
1691 CORBA::ULong system_id_size
= key
.length () - starting_at
;
1693 // Reset <system_id>.
1694 system_id
.length (system_id_size
);
1695 CORBA::Octet
* buf
= system_id
.get_buffer ();
1696 ACE_OS::memcpy (buf
, key_data
+ starting_at
, system_id_size
);
1703 TAO_Root_POA::create_object_key (const PortableServer::ObjectId
&id
)
1705 // Calculate the space required for the key.
1706 CORBA::ULong buffer_size
=
1707 this->id_
.length () +
1710 // Create the buffer for the key.
1711 CORBA::Octet
*buffer
= TAO::ObjectKey::allocbuf (buffer_size
);
1713 // First copy the POA id into the key.
1714 ACE_OS::memcpy (&buffer
[0],
1715 this->id_
.get_buffer (),
1716 this->id_
.length ());
1718 // Then copy the object id into the key.
1719 ACE_OS::memcpy (&buffer
[this->id_
.length ()],
1723 // Create the key, giving the ownership of the buffer to the
1725 TAO::ObjectKey
*key
= 0;
1726 ACE_NEW_RETURN (key
,
1727 TAO::ObjectKey (buffer_size
,
1737 TAO_Root_POA::set_id (TAO_Root_POA
*parent
)
1739 // Calculate the prefix size.
1740 CORBA::ULong prefix_size
= 0;
1741 prefix_size
+= TAO_OBJECTKEY_PREFIX_SIZE
;
1743 // If we are dealing with a persistent POA and user ids are being
1744 // used, then we need to add the POA name length field to the object
1745 // key. Otherwise, the POA name length can be calculated by looking
1746 // at the remainder after extracting other parts of the key.
1747 bool const add_poa_name_length
=
1748 this->is_persistent () &&
1749 !this->system_id ();
1751 // Size required by the POA name.
1752 CORBA::ULong poa_name
= 0;
1754 // Calculate the space required for the POA name.
1755 CORBA::ULong poa_name_length
= this->system_name_
->length ();
1758 poa_name
+= poa_name_length
;
1761 // Check if we need to added the length of the POA name.
1762 if (add_poa_name_length
)
1764 poa_name
+= sizeof (poa_name_length
);
1767 // Get the space needed for the lifespan length
1769 CORBA::ULong
const lifespan_key_length
=
1770 this->active_policy_strategies_
.lifespan_strategy()->key_length ();
1772 CORBA::ULong
const id_assignment_key_length
=
1773 this->active_policy_strategies_
.id_assignment_strategy()->key_type_length ();
1775 // Calculate the space required for the POA id.
1776 CORBA::ULong
const buffer_size
=
1778 this->root_key_type_length () +
1779 id_assignment_key_length
+
1780 lifespan_key_length
+
1783 // Create the buffer for the POA id.
1784 this->id_
.length (buffer_size
);
1785 CORBA::Octet
*buffer
= &this->id_
[0];
1787 // Keeps track of where the next infomation goes; start at 0 byte.
1788 CORBA::ULong starting_at
= 0;
1790 // Add the object key prefix.
1791 ACE_OS::memcpy (&buffer
[starting_at
],
1792 &objectkey_prefix
[0],
1793 TAO_OBJECTKEY_PREFIX_SIZE
);
1795 starting_at
+= TAO_OBJECTKEY_PREFIX_SIZE
;
1797 // Copy the root byte.
1800 buffer
[starting_at
] = (CORBA::Octet
) TAO_Root_POA::non_root_key_char ();
1804 buffer
[starting_at
] = (CORBA::Octet
) TAO_Root_POA::root_key_char ();
1806 starting_at
+= this->root_key_type_length ();
1808 // Add the id_assignment part
1809 this->active_policy_strategies_
.id_assignment_strategy()->create_key (buffer
, starting_at
);
1811 // Add the lifespan part
1812 this->active_policy_strategies_
.lifespan_strategy()->create_key (buffer
, starting_at
);
1814 // Check if we need to added the length of the POA name.
1815 if (add_poa_name_length
)
1817 poa_name_length
= ACE_HTONL (poa_name_length
);
1818 ACE_OS::memcpy (&buffer
[starting_at
],
1820 sizeof (poa_name_length
));
1821 starting_at
+= sizeof (poa_name_length
);
1824 // Put the POA name into the key (for non-root POAs).
1827 ACE_OS::memcpy (&buffer
[starting_at
],
1828 this->system_name_
->get_buffer (),
1829 this->system_name_
->length ());
1830 starting_at
+= this->system_name_
->length ();
1835 TAO_Root_POA::is_poa_generated_id (const PortableServer::ObjectId
&id
)
1837 #if defined (POA_NAME_IN_POA_GENERATED_ID)
1840 const char *id_buffer
= (const char *) id
.get_buffer ();
1842 // Check to see if the POA name is the first part of the id
1844 this->name_
.length () < id
.length () &&
1845 ACE_OS::strncmp (id_buffer
,
1846 this->name_
.c_str (),
1847 this->name_
.length ()) == 0;
1848 #else /* POA_NAME_IN_POA_GENERATED_ID */
1850 ACE_UNUSED_ARG (id
);
1853 #endif /* POA_NAME_IN_POA_GENERATED_ID */
1857 TAO_Root_POA::set_folded_name (TAO_Root_POA
*parent
)
1860 size_t parent_length
= 0;
1864 parent_length
= parent
->folded_name ().length ();
1865 length
+= parent_length
;
1868 length
+= this->name_
.length ();
1869 length
+= TAO_Root_POA::name_separator_length ();
1871 this->folded_name_
.length (static_cast <CORBA::ULong
> (length
));
1872 CORBA::Octet
*folded_name_buffer
= this->folded_name_
.get_buffer ();
1876 ACE_OS::memcpy (folded_name_buffer
,
1877 parent
->folded_name ().get_buffer (),
1881 ACE_OS::memcpy (&folded_name_buffer
[parent_length
],
1882 this->name_
.c_str (),
1883 this->name_
.length ());
1885 folded_name_buffer
[length
- TAO_Root_POA::name_separator_length ()] = TAO_Root_POA::name_separator ();
1889 TAO_Root_POA::parse_ir_object_key (const TAO::ObjectKey
&object_key
,
1890 PortableServer::ObjectId
&user_id
)
1892 TAO_Object_Adapter::poa_name poa_system_name
;
1893 CORBA::Boolean is_root
= false;
1894 CORBA::Boolean is_persistent
= false;
1895 CORBA::Boolean is_system_id
= false;
1896 TAO::Portable_Server::Temporary_Creation_Time poa_creation_time
;
1898 return TAO_Root_POA::parse_key (object_key
,
1907 TAO_Object_Adapter
&
1908 TAO_Root_POA::object_adapter ()
1910 return *this->object_adapter_
;
1914 TAO_Root_POA::invoke_key_to_object ()
1916 PortableServer::ObjectId_var
&system_id
=
1917 *this->key_to_object_params_
.system_id_
;
1919 // Create object key.
1920 TAO::ObjectKey_var key
=
1921 this->create_object_key (system_id
.in ());
1923 return this->key_to_object (key
.in (),
1924 this->key_to_object_params_
.type_id_
,
1925 this->key_to_object_params_
.servant_
,
1926 this->key_to_object_params_
.collocated_
,
1927 this->key_to_object_params_
.priority_
,
1928 this->key_to_object_params_
.indirect_
);
1932 TAO_Root_POA::key_to_object (const TAO::ObjectKey
&key
,
1933 const char *type_id
,
1934 TAO_ServantBase
*servant
,
1935 CORBA::Boolean collocated
,
1936 CORBA::Short priority
,
1939 // Check if the ORB is still running, otherwise throw an exception.
1940 // @@ What if the ORB was destroyed? In that case we shouldn't even
1942 this->orb_core_
.check_shutdown ();
1945 // ImplRepo related.
1947 #if (TAO_HAS_MINIMUM_CORBA == 0)
1949 if (indirect
&& this->orb_core ().imr_endpoints_in_ior ())
1951 CORBA::Object_ptr obj
= this->active_policy_strategies_
.
1952 lifespan_strategy()->imr_key_to_object (key
, type_id
);
1953 if (!CORBA::is_nil (obj
))
1960 ACE_UNUSED_ARG (indirect
);
1961 #endif /* TAO_HAS_MINIMUM_CORBA */
1963 TAO_Stub
*data
= this->key_to_stub_i (key
, type_id
, priority
);
1965 TAO_Stub_Auto_Ptr
safe_data (data
);
1967 CORBA::Object_ptr tmp
;
1969 if (this->orb_core_
.optimize_collocation_objects ())
1971 ACE_NEW_THROW_EX (tmp
, CORBA::Object (data
,
1974 CORBA::INTERNAL ());
1979 ACE_NEW_THROW_EX (tmp
,
1980 CORBA::Object (data
,
1982 CORBA::INTERNAL ());
1985 data
->servant_orb (this->orb_core_
.orb ());
1987 // Transfer ownership to the Object.
1988 (void) safe_data
.release ();
1994 TAO_Root_POA::key_to_stub (const TAO::ObjectKey
&key
,
1995 const char *type_id
,
1996 CORBA::Short priority
)
1998 // Check if the ORB is still running, otherwise throw an exception.
1999 // @@ What if the ORB was destroyed? In that case we shouldn't even
2001 this->orb_core_
.check_shutdown ();
2003 return this->key_to_stub_i (key
, type_id
, priority
);
2007 TAO_Root_POA::key_to_stub_i (const TAO::ObjectKey
&key
,
2008 const char *type_id
,
2009 CORBA::Short priority
)
2011 CORBA::PolicyList_var client_exposed_policies
=
2012 this->client_exposed_policies (priority
);
2014 TAO_Acceptor_Filter
* filter
= 0;
2016 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
2017 if (this->filter_factory_
)
2019 filter
= this->filter_factory_
->create_object (this->poa_manager_
);
2024 ACE_NEW_RETURN (filter
,
2025 TAO_Default_Acceptor_Filter (),
2029 // Give ownership to the auto pointer.
2030 std::unique_ptr
<TAO_Acceptor_Filter
> new_filter (filter
);
2033 this->create_stub_object (
2036 client_exposed_policies
._retn (),
2038 this->orb_core_
.lane_resources ().acceptor_registry ());
2044 TAO_Root_POA::establish_components ()
2046 TAO_IORInterceptor_Adapter
*ior_adapter
=
2047 this->orb_core_
.ior_interceptor_adapter ();
2051 ior_adapter
->establish_components (this);
2056 TAO_Root_POA::components_established (PortableInterceptor::IORInfo_ptr info
)
2058 TAO_IORInterceptor_Adapter
*ior_adapter
=
2059 this->orb_core_
.ior_interceptor_adapter ();
2063 ior_adapter
->components_established (info
);
2068 TAO_Root_POA::save_ior_component (const IOP::TaggedComponent
&component
)
2070 CORBA::ULong
const old_len
= this->tagged_component_
.length ();
2072 this->tagged_component_
.length (old_len
+ 1);
2073 this->tagged_component_
[old_len
] = component
;
2078 save_ior_component_and_profile_id (const IOP::TaggedComponent
&component
,
2079 IOP::ProfileId profile_id
)
2081 // The length of this->tagged_component_id_ is the same as the
2082 // length of the profile_id_array_ since we are trying to make a
2083 // one-to-one link between these two arrays. So, whenever
2084 // this->tagged_component_id_ is increased, we need to increase the
2085 // size of this->profile_id_array_ also.
2087 CORBA::ULong
const old_len
= this->tagged_component_id_
.length ();
2089 CORBA::ULong
const new_len
= old_len
+ 1;
2091 this->tagged_component_id_
.length (new_len
);
2092 this->tagged_component_id_
[old_len
] = component
;
2094 this->profile_id_array_
.size (new_len
);
2095 this->profile_id_array_
[old_len
] = profile_id
;
2099 TAO_Root_POA::create_stub_object (const TAO::ObjectKey
&object_key
,
2100 const char *type_id
,
2101 CORBA::PolicyList
*policy_list
,
2102 TAO_Acceptor_Filter
*filter
,
2103 TAO_Acceptor_Registry
&acceptor_registry
)
2107 // Count the number of endpoints.
2108 size_t const profile_count
= acceptor_registry
.endpoint_count ();
2110 // Create a profile container and have acceptor registries populate
2111 // it with profiles as appropriate.
2112 TAO_MProfile
mprofile (0);
2114 // Allocate space for storing the profiles. There can never be more
2115 // profiles than there are endpoints. In some cases, there can be
2116 // less profiles than endpoints.
2117 int result
= mprofile
.set (static_cast <CORBA::ULong
> (profile_count
));
2124 filter
->fill_profile (object_key
,
2126 acceptor_registry
.begin (),
2127 acceptor_registry
.end ());
2133 result
= filter
->encode_endpoints (mprofile
);
2139 throw ::CORBA::INTERNAL (
2140 CORBA::SystemException::_tao_minor_code (
2141 TAO_MPROFILE_CREATION_ERROR
,
2143 CORBA::COMPLETED_NO
);
2145 // Make sure we have at least one profile. <mp> may end up being
2146 // empty if none of the acceptor endpoints have the right priority
2147 // for this object, for example.
2148 if (mprofile
.profile_count () == 0)
2149 throw ::CORBA::BAD_PARAM (
2150 CORBA::SystemException::_tao_minor_code (
2151 TAO_MPROFILE_CREATION_ERROR
,
2153 CORBA::COMPLETED_NO
);
2156 this->orb_core_
.create_stub_object (mprofile
, type_id
, policy_list
);
2158 // Add the saved tagged components methods to the profiles.
2159 CORBA::ULong len
= this->tagged_component_
.length ();
2160 for (CORBA::ULong i
= 0; i
!= len
; ++i
)
2162 this->add_ior_component (mprofile
, this->tagged_component_
[i
]);
2165 len
= this->tagged_component_id_
.length ();
2167 for (CORBA::ULong k
= 0; k
!= len
; ++k
)
2169 this->add_ior_component_to_profile (mprofile
,
2170 this->tagged_component_id_
[k
],
2171 this->profile_id_array_
[k
]);
2178 TAO_Root_POA::client_exposed_policies (CORBA::Short
/* object_priority */)
2180 CORBA::PolicyList
*client_exposed_policies
= 0;
2181 ACE_NEW_THROW_EX (client_exposed_policies
,
2182 CORBA::PolicyList (),
2183 CORBA::NO_MEMORY (TAO::VMCID
,
2184 CORBA::COMPLETED_NO
));
2186 CORBA::PolicyList_var policies
= client_exposed_policies
;
2188 // Add in all of the client exposed policies.
2189 this->policies_
.add_client_exposed_fixed_policies (client_exposed_policies
);
2191 return policies
._retn ();
2194 TAO_SERVANT_LOCATION
2195 TAO_Root_POA::locate_servant_i (const PortableServer::ObjectId
&system_id
,
2196 PortableServer::Servant
&servant
)
2198 return this->active_policy_strategies_
.request_processing_strategy()->
2199 locate_servant (system_id
, servant
);
2202 TAO_SERVANT_LOCATION
2203 TAO_Root_POA::servant_present (const PortableServer::ObjectId
&system_id
,
2204 PortableServer::Servant
&servant
)
2206 return this->active_policy_strategies_
.servant_retention_strategy()->
2207 servant_present (system_id
, servant
);
2210 PortableServer::Servant
2211 TAO_Root_POA::find_servant (
2212 const PortableServer::ObjectId
&system_id
,
2213 TAO::Portable_Server::Servant_Upcall
&servant_upcall
,
2214 TAO::Portable_Server::POA_Current_Impl
&poa_current_impl
)
2216 return this->active_policy_strategies_
.servant_retention_strategy()->
2217 find_servant (system_id
,
2223 TAO_Root_POA::find_servant_priority (
2224 const PortableServer::ObjectId
&system_id
,
2225 CORBA::Short
&priority
)
2227 return this->active_policy_strategies_
.servant_retention_strategy()->
2228 find_servant_priority (system_id
, priority
);
2232 TAO_Root_POA::ORT_adapter_i ()
2234 if ((this->ort_adapter_factory_
) && (this->ort_adapter_
== 0))
2238 // Get the full adapter name of this POA, do this before we
2239 // create the adapter so that in case this fails, we just
2240 // return 0 and not a not activated adapter
2241 PortableInterceptor::AdapterName
*adapter_name
= this->adapter_name_i ();
2243 this->ort_adapter_
= this->ort_adapter_factory_
->create ();
2245 if (this->ort_adapter_
)
2247 // @todo We have to look at this, we activate it but hold the POA lock,
2248 // in case we are called by ORT_adapter, we shouldn't keep the lock
2249 // here, but then the ort_adapter should be guarded against multiple
2251 this->ort_adapter_
->activate (this->orb_core_
.server_id (),
2252 this->orb_core_
.orbid (),
2257 catch (const ::CORBA::Exception
& ex
)
2259 ex
._tao_print_exception (
2260 "(%P|%t) Cannot initialize the "
2261 "object_reference_template_adapter\n");
2265 return this->ort_adapter_
;
2268 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
2270 PortableServer::AdapterActivator_ptr
2271 TAO_Root_POA::the_activator ()
2273 // Lock access for the duration of this transaction.
2274 TAO_POA_GUARD_RETURN (PortableServer::AdapterActivator::_nil ());
2276 return PortableServer::AdapterActivator::_duplicate (this->adapter_activator_
.in ());
2280 TAO_Root_POA::the_activator (PortableServer::AdapterActivator_ptr adapter_activator
)
2282 // Lock access for the duration of this transaction.
2285 this->adapter_activator_
= PortableServer::AdapterActivator::_duplicate (adapter_activator
);
2288 #endif /* TAO_HAS_MINIMUM_POA == 0 && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)*/
2290 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
2292 PortableServer::ServantManager_ptr
2293 TAO_Root_POA::get_servant_manager ()
2295 // Lock access for the duration of this transaction.
2296 TAO_POA_GUARD_RETURN (PortableServer::ServantManager::_nil ());
2298 return this->active_policy_strategies_
.request_processing_strategy()->
2299 get_servant_manager ();
2303 TAO_Root_POA::set_servant_manager (PortableServer::ServantManager_ptr imgr
)
2305 // Lock access for the duration of this transaction.
2308 this->active_policy_strategies_
.request_processing_strategy()->
2309 set_servant_manager (imgr
);
2312 PortableServer::Servant
2313 TAO_Root_POA::get_servant_i ()
2315 return this->active_policy_strategies_
.request_processing_strategy()->
2319 PortableServer::Servant
2320 TAO_Root_POA::get_servant ()
2322 // Lock access for the duration of this transaction.
2323 TAO_POA_GUARD_RETURN (0);
2325 PortableServer::Servant servant
= this->get_servant_i ();
2329 // ATTENTION: Trick locking here, see class header for details
2330 TAO::Portable_Server::Non_Servant_Upcall
non_servant_upcall (*this);
2331 ACE_UNUSED_ARG (non_servant_upcall
);
2333 // The POA invokes _add_ref once on the Servant before returning
2334 // it. If the application uses reference counting, the caller of
2335 // get_servant is responsible for invoking _remove_ref once on
2336 // the returned Servant when it is finished with it. A
2337 // conforming caller need not invoke _remove_ref on the returned
2338 // Servant if the type of the Servant uses the default reference
2339 // counting inherited from ServantBase.
2340 servant
->_add_ref ();
2346 // If no servant has been associated with the POA, the NoServant
2347 // exception is raised.
2348 throw PortableServer::POA::NoServant ();
2353 TAO_Root_POA::set_servant (PortableServer::Servant servant
)
2355 // Lock access for the duration of this transaction.
2358 this->active_policy_strategies_
.request_processing_strategy()->
2359 set_servant (servant
);
2362 #endif /* TAO_HAS_MINIMUM_POA == 0 && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO) */
2365 TAO_Root_POA::is_servant_activation_allowed (PortableServer::Servant servant
,
2366 bool &wait_occurred_restart_call
)
2368 return this->active_policy_strategies_
.id_uniqueness_strategy ()->
2369 is_servant_activation_allowed (servant
, wait_occurred_restart_call
);
2373 TAO_Root_POA::has_system_id () const
2375 return this->active_policy_strategies_
.id_assignment_strategy ()->
2380 TAO_Root_POA::rebind_using_user_id_and_system_id (
2381 PortableServer::Servant servant
,
2382 const PortableServer::ObjectId
&user_id
,
2383 const PortableServer::ObjectId
&system_id
,
2384 TAO::Portable_Server::Servant_Upcall
&servant_upcall
)
2386 return this->active_policy_strategies_
.servant_retention_strategy ()->
2387 rebind_using_user_id_and_system_id (servant
,
2394 TAO_Root_POA::servant_has_remaining_activations (PortableServer::Servant servant
)
2396 return this->active_policy_strategies_
.servant_retention_strategy ()->
2397 servant_has_remaining_activations (servant
);
2401 TAO_Root_POA::allow_implicit_activation () const
2403 return this->active_policy_strategies_
.implicit_activation_strategy ()->
2404 allow_implicit_activation ();
2408 TAO_Root_POA::allow_multiple_activations () const
2410 return this->active_policy_strategies_
.id_uniqueness_strategy ()->
2411 allow_multiple_activations ();
2415 TAO_Root_POA::post_invoke_servant_cleanup(
2416 const PortableServer::ObjectId
&system_id
,
2417 const TAO::Portable_Server::Servant_Upcall
&servant_upcall
)
2419 this->active_policy_strategies_
.request_processing_strategy ()->
2420 post_invoke_servant_cleanup (system_id
, servant_upcall
);
2424 TAO_Root_POA::server_priority () const
2426 return this->cached_policies_
.server_priority ();
2430 TAO_Root_POA::is_servant_active (
2431 PortableServer::Servant servant
,
2432 bool &wait_occurred_restart_call
)
2434 return this->active_policy_strategies_
.servant_retention_strategy ()->
2435 is_servant_in_map (servant
, wait_occurred_restart_call
);
2438 TAO::Portable_Server::Cached_Policies
&
2439 TAO_Root_POA::cached_policies ()
2441 return this->cached_policies_
;
2444 TAO_Network_Priority_Hook
*
2445 TAO_Root_POA::network_priority_hook ()
2447 return this->network_priority_hook_
;
2450 TAO::Portable_Server::Cached_Policies::PriorityModel
2451 TAO_Root_POA::priority_model () const
2453 return cached_policies_
.priority_model ();
2456 #if (TAO_HAS_MINIMUM_POA == 0)
2458 TAO_Root_POA::enter ()
2460 return this->active_policy_strategies_
.thread_strategy ()->enter();
2462 #endif /* TAO_HAS_MINIMUM_POA == 0 */
2464 #if (TAO_HAS_MINIMUM_POA == 0)
2466 TAO_Root_POA::exit ()
2468 return this->active_policy_strategies_
.thread_strategy ()->exit();
2470 #endif /* TAO_HAS_MINIMUM_POA == 0 */
2473 TAO_Root_POA::validate_lifespan (
2474 CORBA::Boolean is_persistent
,
2475 const TAO::Portable_Server::Temporary_Creation_Time
& creation_time
) const
2477 return this->active_policy_strategies_
.lifespan_strategy()->
2478 validate (is_persistent
, creation_time
);
2482 TAO_Root_POA::root () const
2488 TAO_Root_POA::ORT_adapter ()
2490 if (this->ort_adapter_
!= 0)
2491 return this->ort_adapter_
;
2493 // Lock access for the duration of this transaction.
2494 TAO_POA_GUARD_RETURN (0);
2497 if (this->ort_adapter_
!= 0)
2499 return this->ort_adapter_
;
2502 return this->ORT_adapter_i ();
2506 TAO_Root_POA::server_protocol ()
2512 TAO_Root_POA::Key_To_Object_Params::set (PortableServer::ObjectId_var
&system_id
,
2513 const char *type_id
,
2514 TAO_ServantBase
*servant
,
2515 CORBA::Boolean collocated
,
2516 CORBA::Short priority
,
2519 this->system_id_
= &system_id
;
2520 this->type_id_
= type_id
;
2521 this->servant_
= servant
;
2522 this->collocated_
= collocated
;
2523 this->priority_
= priority
;
2524 this->indirect_
= indirect
;
2528 TAO_Root_POA::waiting_servant_deactivation () const
2530 return this->active_policy_strategies_
.servant_retention_strategy ()->
2531 waiting_servant_deactivation ();
2535 TAO_Root_POA::ort_adapter_factory_name (const char *name
)
2537 TAO_POA_Static_Resources::instance ()->ort_adapter_factory_name_
=
2542 TAO_Root_POA::get_policy (CORBA::PolicyType policy
)
2544 return this->policies_
.get_policy (policy
);
2548 TAO_Root_POA::check_state ()
2550 this->active_policy_strategies_
.lifespan_strategy ()->check_state ();
2554 TAO_Root_POA::ort_adapter_factory_name ()
2556 return TAO_POA_Static_Resources::instance ()->ort_adapter_factory_name_
.c_str();
2560 TAO_Root_POA::imr_client_adapter_name (const char *name
)
2562 TAO_POA_Static_Resources::instance ()->imr_client_adapter_name_
= name
;
2566 TAO_Root_POA::imr_client_adapter_name ()
2568 return TAO_POA_Static_Resources::instance ()->imr_client_adapter_name_
.c_str();
2571 PortableServer::POAManager_ptr
2572 TAO_Root_POA::the_POAManager ()
2574 return PortableServer::POAManager::_duplicate (&this->poa_manager_
);
2577 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
2578 PortableServer::POAManagerFactory_ptr
2579 TAO_Root_POA::the_POAManagerFactory ()
2581 return PortableServer::POAManagerFactory::_duplicate (&this->poa_manager_factory_
);
2586 TAO_Root_POA::_get_orb ()
2588 return CORBA::ORB::_duplicate (this->orb_core_
.orb ());
2591 // Initialize instance_ to 0, since this is what we test for in the call
2592 // to instance (). Note that this does not require a constructor call, so
2593 // it is always initialized by the time that instance () can be called.
2594 TAO_POA_Static_Resources
* TAO_POA_Static_Resources::instance_
= 0;
2596 // Force an instance to be created at module initialization time,
2597 // since we do not want to worry about double checked locking and
2598 // the race condition to initialize the lock.
2599 TAO_POA_Static_Resources
* TAO_POA_Static_Resources::initialization_reference_
=
2600 TAO_POA_Static_Resources::instance ();
2603 TAO_POA_Static_Resources::fini ()
2605 delete TAO_POA_Static_Resources::instance_
;
2606 TAO_POA_Static_Resources::instance_
= 0;
2609 TAO_POA_Static_Resources
*
2610 TAO_POA_Static_Resources::instance ()
2612 if (TAO_POA_Static_Resources::instance_
== 0)
2614 // This new is never freed on purpose. The data specified by
2615 // it needs to be around for the last shared library that references
2616 // this class. This could occur in a destructor in a shared library
2617 // that is unloaded after this one. One solution to avoid this
2618 // harmless memory leak would be to use reference counting.
2619 ACE_NEW_RETURN (TAO_POA_Static_Resources::instance_
,
2620 TAO_POA_Static_Resources (),
2624 return TAO_POA_Static_Resources::instance_
;
2627 TAO_POA_Static_Resources::TAO_POA_Static_Resources ()
2628 : ort_adapter_factory_name_ ("ORT_Adapter_Factory"),
2629 imr_client_adapter_name_ ("ImR_Client_Adapter")
2634 TAO_Root_POA::poa_activated_hook ()
2639 TAO_Root_POA::poa_deactivated_hook ()
2644 TAO_Root_POA::servant_activated_hook (PortableServer::Servant
,
2645 const PortableServer::ObjectId
&)
2650 TAO_Root_POA::servant_deactivated_hook (PortableServer::Servant
,
2651 const PortableServer::ObjectId
&)
2655 TAO_Active_Object_Map
*
2656 TAO_Root_POA::get_active_object_map() const
2658 return this->active_policy_strategies_
.servant_retention_strategy()->
2659 get_active_object_map();
2663 TAO_END_VERSIONED_NAMESPACE_DECL