00001 // Default_Policy_Validator.cpp,v 1.13 2006/06/19 19:49:48 jwillemsen Exp 00002 00003 #include "tao/PortableServer/Default_Policy_Validator.h" 00004 #include "tao/ORB_Core.h" 00005 #include "tao/Policy_Set.h" 00006 #include "tao/PolicyFactory_Registry_Adapter.h" 00007 #include "tao/PortableServer/PortableServer.h" 00008 00009 ACE_RCSID (PortableServer, 00010 Default_Policy_Validator, 00011 "Default_Policy_Validator.cpp,v 1.13 2006/06/19 19:49:48 jwillemsen Exp") 00012 00013 00014 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00015 00016 TAO_POA_Default_Policy_Validator::TAO_POA_Default_Policy_Validator ( 00017 TAO_ORB_Core &orb_core) 00018 : TAO_Policy_Validator (orb_core) 00019 { 00020 } 00021 00022 TAO_POA_Default_Policy_Validator::~TAO_POA_Default_Policy_Validator (void) 00023 { 00024 } 00025 00026 void 00027 TAO_POA_Default_Policy_Validator::validate_impl (TAO_Policy_Set &policies 00028 ACE_ENV_ARG_DECL) 00029 { 00030 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO) 00031 CORBA::Policy_var policy = 00032 policies.get_cached_policy (TAO_CACHED_POLICY_SERVANT_RETENTION 00033 ACE_ENV_ARG_PARAMETER); 00034 ACE_CHECK; 00035 00036 PortableServer::ServantRetentionPolicy_var srp = 00037 PortableServer::ServantRetentionPolicy::_narrow (policy.in () 00038 ACE_ENV_ARG_PARAMETER); 00039 ACE_CHECK; 00040 PortableServer::ServantRetentionPolicyValue servant_retention = 00041 srp->value (ACE_ENV_SINGLE_ARG_PARAMETER); 00042 ACE_CHECK; 00043 00044 policy = 00045 policies.get_cached_policy (TAO_CACHED_POLICY_REQUEST_PROCESSING 00046 ACE_ENV_ARG_PARAMETER); 00047 ACE_CHECK; 00048 00049 PortableServer::RequestProcessingPolicy_var rpp = 00050 PortableServer::RequestProcessingPolicy::_narrow (policy.in () 00051 ACE_ENV_ARG_PARAMETER); 00052 ACE_CHECK; 00053 PortableServer::RequestProcessingPolicyValue request_processing = 00054 rpp->value (ACE_ENV_SINGLE_ARG_PARAMETER); 00055 ACE_CHECK; 00056 00057 // The NON_RETAIN policy requires either the USE_DEFAULT_SERVANT or 00058 // USE_SERVANT_MANAGER policies. 00059 if (servant_retention == PortableServer::NON_RETAIN) 00060 if (request_processing != PortableServer::USE_SERVANT_MANAGER && 00061 request_processing != PortableServer::USE_DEFAULT_SERVANT) 00062 ACE_THROW (PortableServer::POA::InvalidPolicy ()); 00063 00064 // USE_ACTIVE_OBJECT_MAP_ONLY requires the RETAIN policy. 00065 if (request_processing == PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY) 00066 if (servant_retention != PortableServer::RETAIN) 00067 ACE_THROW (PortableServer::POA::InvalidPolicy ()); 00068 00069 policy = 00070 policies.get_cached_policy (TAO_CACHED_POLICY_ID_UNIQUENESS 00071 ACE_ENV_ARG_PARAMETER); 00072 00073 ACE_CHECK; 00074 00075 PortableServer::IdUniquenessPolicy_var iup = 00076 PortableServer::IdUniquenessPolicy::_narrow (policy.in () 00077 ACE_ENV_ARG_PARAMETER); 00078 ACE_CHECK; 00079 PortableServer::IdUniquenessPolicyValue id_uniqueness = 00080 iup->value (ACE_ENV_SINGLE_ARG_PARAMETER); 00081 ACE_CHECK; 00082 00083 policy = 00084 policies.get_cached_policy (TAO_CACHED_POLICY_IMPLICIT_ACTIVATION 00085 ACE_ENV_ARG_PARAMETER); 00086 ACE_CHECK; 00087 00088 PortableServer::ImplicitActivationPolicy_var iap = 00089 PortableServer::ImplicitActivationPolicy::_narrow (policy.in () 00090 ACE_ENV_ARG_PARAMETER); 00091 ACE_CHECK; 00092 PortableServer::ImplicitActivationPolicyValue implicit_activation = 00093 iap->value (ACE_ENV_SINGLE_ARG_PARAMETER); 00094 ACE_CHECK; 00095 00096 policy = 00097 policies.get_cached_policy (TAO_CACHED_POLICY_ID_ASSIGNMENT 00098 ACE_ENV_ARG_PARAMETER); 00099 ACE_CHECK; 00100 00101 PortableServer::IdAssignmentPolicy_var idap = 00102 PortableServer::IdAssignmentPolicy::_narrow (policy.in () 00103 ACE_ENV_ARG_PARAMETER); 00104 ACE_CHECK; 00105 PortableServer::IdAssignmentPolicyValue id_assignment = 00106 idap->value (ACE_ENV_SINGLE_ARG_PARAMETER); 00107 ACE_CHECK; 00108 00109 // USE_DEFAULT_SERVANT requires the MULTIPLE_ID policy. 00110 if (request_processing == PortableServer::USE_DEFAULT_SERVANT) 00111 if (id_uniqueness != PortableServer::MULTIPLE_ID) 00112 ACE_THROW (PortableServer::POA::InvalidPolicy ()); 00113 00114 // IMPLICIT_ACTIVATION requires the SYSTEM_ID and RETAIN policies. 00115 if (implicit_activation == PortableServer::IMPLICIT_ACTIVATION) 00116 if (servant_retention != PortableServer::RETAIN || 00117 id_assignment != PortableServer::SYSTEM_ID) 00118 ACE_THROW (PortableServer::POA::InvalidPolicy ()); 00119 #else /* TAO_HAS_MINIMUM_POA == 0 */ 00120 ACE_UNUSED_ARG (policies); 00121 ACE_ENV_ARG_NOT_USED; // FUZZ: ignore check_for_ace_check 00122 #endif /* TAO_HAS_MINIMUM_POA == 0 */ 00123 } 00124 00125 CORBA::Boolean 00126 TAO_POA_Default_Policy_Validator::legal_policy_impl (CORBA::PolicyType type) 00127 { 00128 // Check known POA policies, or if given PolicyType has a 00129 // corresponding PolicyFactory. The PolicyFactory check is mandated 00130 // by the CORBA specification. 00131 return 00132 ( 00133 # if ! defined (CORBA_E_COMPACT) && ! defined (CORBA_E_MICRO) 00134 type == PortableServer::THREAD_POLICY_ID || 00135 # endif 00136 # if ! defined (CORBA_E_MICRO) 00137 type == PortableServer::LIFESPAN_POLICY_ID || 00138 type == PortableServer::ID_UNIQUENESS_POLICY_ID || 00139 type == PortableServer::ID_ASSIGNMENT_POLICY_ID || 00140 # endif 00141 # if ! defined (CORBA_E_COMPACT) && ! defined (CORBA_E_MICRO) 00142 type == PortableServer::IMPLICIT_ACTIVATION_POLICY_ID || 00143 type == PortableServer::SERVANT_RETENTION_POLICY_ID || 00144 type == PortableServer::REQUEST_PROCESSING_POLICY_ID || 00145 # endif 00146 (this->orb_core_.policy_factory_registry () != 0 && 00147 this->orb_core_.policy_factory_registry ()->factory_exists (type))); 00148 } 00149 00150 void 00151 TAO_POA_Default_Policy_Validator::merge_policies_impl ( 00152 TAO_Policy_Set & 00153 ACE_ENV_ARG_DECL_NOT_USED) 00154 { 00155 } 00156 00157 TAO_END_VERSIONED_NAMESPACE_DECL