00001 // @(#) $Id: POA_Policy_Set.cpp 76898 2007-02-04 18:58:07Z johnnyw $ 00002 00003 #include "tao/PortableServer/POA_Policy_Set.h" 00004 #include "tao/PortableServer/POA_Cached_Policies.h" 00005 #include "tao/PortableServer/PortableServer.h" 00006 00007 #include "tao/Policy_Validator.h" 00008 #include "tao/ORB_Core.h" 00009 00010 #if !defined (__ACE_INLINE__) 00011 # include "tao/PortableServer/POA_Policy_Set.inl" 00012 #endif /* ! __ACE_INLINE__ */ 00013 00014 ACE_RCSID (PortableServer, 00015 POA_Policy_Set, 00016 "$Id: POA_Policy_Set.cpp 76898 2007-02-04 18:58:07Z johnnyw $") 00017 00018 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00019 00020 TAO_POA_Policy_Set::TAO_POA_Policy_Set (void) 00021 : impl_ (TAO_POLICY_POA_SCOPE) 00022 { 00023 } 00024 00025 TAO_POA_Policy_Set::TAO_POA_Policy_Set (const TAO_POA_Policy_Set &rhs) 00026 : 00027 impl_ (rhs.impl_) 00028 { 00029 } 00030 00031 TAO_POA_Policy_Set::~TAO_POA_Policy_Set (void) 00032 { 00033 } 00034 00035 void 00036 TAO_POA_Policy_Set::add_client_exposed_fixed_policies ( 00037 CORBA::PolicyList *client_exposed_policies) 00038 { 00039 CORBA::ULong cep_index = client_exposed_policies->length (); 00040 00041 for (CORBA::ULong i = 0; 00042 i < this->num_policies (); 00043 ++i) 00044 { 00045 CORBA::Policy_var policy = this->get_policy_by_index (i); 00046 00047 // If this policy is client exposed, add it to the list. 00048 if (policy->_tao_scope () & TAO_POLICY_CLIENT_EXPOSED) 00049 { 00050 client_exposed_policies->length (cep_index + 1); 00051 (*client_exposed_policies)[cep_index] = policy->copy (); 00052 cep_index++; 00053 } 00054 } 00055 } 00056 00057 void 00058 TAO_POA_Policy_Set::validate_policies (TAO_Policy_Validator &validator, 00059 TAO_ORB_Core &orb_core) 00060 { 00061 // Just give a last chance for all the unloaded validators in other 00062 // libraries to be registered 00063 orb_core.load_policy_validators (validator); 00064 00065 // Validate that all of the specified policies make sense. 00066 validator.validate (this->impl_ ); 00067 00068 // Verify that all policies are legal for the currently loaded 00069 // POA extensions. 00070 for (CORBA::ULong i = 0; 00071 i < this->impl_.num_policies (); 00072 i++) 00073 { 00074 CORBA::Policy_var policy = this->impl_.get_policy_by_index (i); 00075 00076 CORBA::PolicyType type = policy->policy_type (); 00077 00078 if (validator.legal_policy (type) == 0) 00079 { 00080 #if !defined (CORBA_E_MICRO) 00081 // An invalid policy was specified. Let the user know about 00082 // it. 00083 throw PortableServer::POA::InvalidPolicy (); 00084 #else 00085 ACE_ERROR ((LM_ERROR, "Invalid policy\n")); 00086 #endif 00087 } 00088 } 00089 } 00090 00091 TAO_END_VERSIONED_NAMESPACE_DECL