00001 // $Id: Default_Policy_Validator.cpp 79118 2007-07-31 11:38:01Z johnnyw $ 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 "$Id: Default_Policy_Validator.cpp 79118 2007-07-31 11:38:01Z johnnyw $") 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 { 00029 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO) 00030 CORBA::Policy_var policy = 00031 policies.get_cached_policy (TAO_CACHED_POLICY_SERVANT_RETENTION); 00032 00033 PortableServer::ServantRetentionPolicy_var srp = 00034 PortableServer::ServantRetentionPolicy::_narrow (policy.in ()); 00035 PortableServer::ServantRetentionPolicyValue servant_retention = 00036 srp->value (); 00037 00038 policy = policies.get_cached_policy (TAO_CACHED_POLICY_REQUEST_PROCESSING); 00039 00040 PortableServer::RequestProcessingPolicy_var rpp = 00041 PortableServer::RequestProcessingPolicy::_narrow (policy.in ()); 00042 PortableServer::RequestProcessingPolicyValue request_processing = 00043 rpp->value (); 00044 00045 // The NON_RETAIN policy requires either the USE_DEFAULT_SERVANT or 00046 // USE_SERVANT_MANAGER policies. 00047 if (servant_retention == PortableServer::NON_RETAIN) 00048 if (request_processing != PortableServer::USE_SERVANT_MANAGER && 00049 request_processing != PortableServer::USE_DEFAULT_SERVANT) 00050 throw PortableServer::POA::InvalidPolicy (); 00051 00052 // USE_ACTIVE_OBJECT_MAP_ONLY requires the RETAIN policy. 00053 if (request_processing == PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY) 00054 if (servant_retention != PortableServer::RETAIN) 00055 throw PortableServer::POA::InvalidPolicy (); 00056 00057 policy = policies.get_cached_policy (TAO_CACHED_POLICY_ID_UNIQUENESS); 00058 00059 PortableServer::IdUniquenessPolicy_var iup = 00060 PortableServer::IdUniquenessPolicy::_narrow (policy.in ()); 00061 PortableServer::IdUniquenessPolicyValue id_uniqueness = 00062 iup->value (); 00063 00064 policy = 00065 policies.get_cached_policy (TAO_CACHED_POLICY_IMPLICIT_ACTIVATION); 00066 00067 PortableServer::ImplicitActivationPolicy_var iap = 00068 PortableServer::ImplicitActivationPolicy::_narrow (policy.in ()); 00069 PortableServer::ImplicitActivationPolicyValue implicit_activation = 00070 iap->value (); 00071 00072 policy = policies.get_cached_policy (TAO_CACHED_POLICY_ID_ASSIGNMENT); 00073 00074 PortableServer::IdAssignmentPolicy_var idap = 00075 PortableServer::IdAssignmentPolicy::_narrow (policy.in ()); 00076 PortableServer::IdAssignmentPolicyValue id_assignment = 00077 idap->value (); 00078 00079 // USE_DEFAULT_SERVANT requires the MULTIPLE_ID policy. 00080 if (request_processing == PortableServer::USE_DEFAULT_SERVANT) 00081 if (id_uniqueness != PortableServer::MULTIPLE_ID) 00082 throw PortableServer::POA::InvalidPolicy (); 00083 00084 // IMPLICIT_ACTIVATION requires the SYSTEM_ID and RETAIN policies. 00085 if (implicit_activation == PortableServer::IMPLICIT_ACTIVATION) 00086 if (servant_retention != PortableServer::RETAIN || 00087 id_assignment != PortableServer::SYSTEM_ID) 00088 throw PortableServer::POA::InvalidPolicy (); 00089 #else /* TAO_HAS_MINIMUM_POA == 0 */ 00090 ACE_UNUSED_ARG (policies); 00091 #endif /* TAO_HAS_MINIMUM_POA == 0 */ 00092 } 00093 00094 CORBA::Boolean 00095 TAO_POA_Default_Policy_Validator::legal_policy_impl (CORBA::PolicyType type) 00096 { 00097 // Check known POA policies, or if given PolicyType has a 00098 // corresponding PolicyFactory. The PolicyFactory check is mandated 00099 // by the CORBA specification. 00100 return 00101 ( 00102 # if ! defined (CORBA_E_COMPACT) && ! defined (CORBA_E_MICRO) 00103 type == PortableServer::THREAD_POLICY_ID || 00104 # endif 00105 # if ! defined (CORBA_E_MICRO) 00106 type == PortableServer::LIFESPAN_POLICY_ID || 00107 type == PortableServer::ID_UNIQUENESS_POLICY_ID || 00108 type == PortableServer::ID_ASSIGNMENT_POLICY_ID || 00109 # endif 00110 # if ! defined (CORBA_E_COMPACT) && ! defined (CORBA_E_MICRO) 00111 type == PortableServer::IMPLICIT_ACTIVATION_POLICY_ID || 00112 type == PortableServer::SERVANT_RETENTION_POLICY_ID || 00113 type == PortableServer::REQUEST_PROCESSING_POLICY_ID || 00114 # endif 00115 (this->orb_core_.policy_factory_registry () != 0 && 00116 this->orb_core_.policy_factory_registry ()->factory_exists (type))); 00117 } 00118 00119 void 00120 TAO_POA_Default_Policy_Validator::merge_policies_impl (TAO_Policy_Set &) 00121 { 00122 } 00123 00124 TAO_END_VERSIONED_NAMESPACE_DECL