1 #include "tao/PortableServer/Default_Policy_Validator.h"
2 #include "tao/ORB_Core.h"
3 #include "tao/Policy_Set.h"
4 #include "tao/PolicyFactory_Registry_Adapter.h"
5 #include "tao/PortableServer/PortableServer.h"
7 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
9 TAO_POA_Default_Policy_Validator::TAO_POA_Default_Policy_Validator (
10 TAO_ORB_Core
&orb_core
)
11 : TAO_Policy_Validator (orb_core
)
16 TAO_POA_Default_Policy_Validator::validate_impl (TAO_Policy_Set
&policies
)
18 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
19 CORBA::Policy_var policy
=
20 policies
.get_cached_policy (TAO_CACHED_POLICY_SERVANT_RETENTION
);
22 PortableServer::ServantRetentionPolicy_var srp
=
23 PortableServer::ServantRetentionPolicy::_narrow (policy
.in ());
24 PortableServer::ServantRetentionPolicyValue servant_retention
=
27 policy
= policies
.get_cached_policy (TAO_CACHED_POLICY_REQUEST_PROCESSING
);
29 PortableServer::RequestProcessingPolicy_var rpp
=
30 PortableServer::RequestProcessingPolicy::_narrow (policy
.in ());
31 PortableServer::RequestProcessingPolicyValue request_processing
=
34 // The NON_RETAIN policy requires either the USE_DEFAULT_SERVANT or
35 // USE_SERVANT_MANAGER policies.
36 if (servant_retention
== PortableServer::NON_RETAIN
)
37 if (request_processing
!= PortableServer::USE_SERVANT_MANAGER
&&
38 request_processing
!= PortableServer::USE_DEFAULT_SERVANT
)
39 throw PortableServer::POA::InvalidPolicy ();
41 // USE_ACTIVE_OBJECT_MAP_ONLY requires the RETAIN policy.
42 if (request_processing
== PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY
)
43 if (servant_retention
!= PortableServer::RETAIN
)
44 throw PortableServer::POA::InvalidPolicy ();
46 policy
= policies
.get_cached_policy (TAO_CACHED_POLICY_ID_UNIQUENESS
);
48 PortableServer::IdUniquenessPolicy_var iup
=
49 PortableServer::IdUniquenessPolicy::_narrow (policy
.in ());
50 PortableServer::IdUniquenessPolicyValue id_uniqueness
=
54 policies
.get_cached_policy (TAO_CACHED_POLICY_IMPLICIT_ACTIVATION
);
56 PortableServer::ImplicitActivationPolicy_var iap
=
57 PortableServer::ImplicitActivationPolicy::_narrow (policy
.in ());
58 PortableServer::ImplicitActivationPolicyValue implicit_activation
=
61 policy
= policies
.get_cached_policy (TAO_CACHED_POLICY_ID_ASSIGNMENT
);
63 PortableServer::IdAssignmentPolicy_var idap
=
64 PortableServer::IdAssignmentPolicy::_narrow (policy
.in ());
65 PortableServer::IdAssignmentPolicyValue id_assignment
=
68 // USE_DEFAULT_SERVANT requires the MULTIPLE_ID policy.
69 if (request_processing
== PortableServer::USE_DEFAULT_SERVANT
)
70 if (id_uniqueness
!= PortableServer::MULTIPLE_ID
)
71 throw PortableServer::POA::InvalidPolicy ();
73 // IMPLICIT_ACTIVATION requires the SYSTEM_ID and RETAIN policies.
74 if (implicit_activation
== PortableServer::IMPLICIT_ACTIVATION
)
75 if (servant_retention
!= PortableServer::RETAIN
||
76 id_assignment
!= PortableServer::SYSTEM_ID
)
77 throw PortableServer::POA::InvalidPolicy ();
78 #else /* TAO_HAS_MINIMUM_POA == 0 */
79 ACE_UNUSED_ARG (policies
);
80 #endif /* TAO_HAS_MINIMUM_POA == 0 */
84 TAO_POA_Default_Policy_Validator::legal_policy_impl (CORBA::PolicyType type
)
86 // Check known POA policies, or if given PolicyType has a
87 // corresponding PolicyFactory. The PolicyFactory check is mandated
88 // by the CORBA specification.
91 # if ! defined (CORBA_E_COMPACT) && ! defined (CORBA_E_MICRO)
92 type
== PortableServer::THREAD_POLICY_ID
||
94 # if ! defined (CORBA_E_MICRO)
95 type
== PortableServer::LIFESPAN_POLICY_ID
||
96 type
== PortableServer::ID_UNIQUENESS_POLICY_ID
||
97 type
== PortableServer::ID_ASSIGNMENT_POLICY_ID
||
99 # if ! defined (CORBA_E_COMPACT) && ! defined (CORBA_E_MICRO)
100 type
== PortableServer::IMPLICIT_ACTIVATION_POLICY_ID
||
101 type
== PortableServer::SERVANT_RETENTION_POLICY_ID
||
102 type
== PortableServer::REQUEST_PROCESSING_POLICY_ID
||
104 (this->orb_core_
.policy_factory_registry () != 0 &&
105 this->orb_core_
.policy_factory_registry ()->factory_exists (type
)));
109 TAO_POA_Default_Policy_Validator::merge_policies_impl (TAO_Policy_Set
&)
113 TAO_END_VERSIONED_NAMESPACE_DECL