00001
00002
00003 #include "tao/RTCORBA/RT_Stub.h"
00004
00005 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
00006
00007 #include "tao/RTCORBA/RT_Policy_i.h"
00008 #include "tao/ORB_Core.h"
00009 #include "tao/Policy_Set.h"
00010 #include "tao/Policy_Manager.h"
00011
00012
00013 ACE_RCSID (RTCORBA,
00014 RT_Stub,
00015 "RT_Stub.cpp,v 1.14 2006/04/19 09:35:58 jwillemsen Exp")
00016
00017
00018 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00019
00020 TAO_RT_Stub::TAO_RT_Stub (const char *repository_id,
00021 const TAO_MProfile &profiles,
00022 TAO_ORB_Core *orb_core)
00023 : TAO_Stub (repository_id,
00024 profiles,
00025 orb_core),
00026 priority_model_policy_ (0),
00027 priority_banded_connection_policy_ (0),
00028 client_protocol_policy_ (0),
00029 are_policies_parsed_ (0)
00030 {
00031 }
00032
00033 TAO_RT_Stub::~TAO_RT_Stub (void)
00034 {
00035 if (this->priority_model_policy_.in ())
00036 this->priority_model_policy_->destroy ();
00037
00038 if (this->priority_banded_connection_policy_.in ())
00039 this->priority_banded_connection_policy_->destroy ();
00040
00041 if (this->client_protocol_policy_.in ())
00042 this->client_protocol_policy_->destroy ();
00043 }
00044
00045 void
00046 TAO_RT_Stub::parse_policies (ACE_ENV_SINGLE_ARG_DECL)
00047 {
00048 CORBA::PolicyList_var policy_list
00049 = this->base_profiles_.policy_list (ACE_ENV_SINGLE_ARG_PARAMETER);
00050 ACE_CHECK;
00051
00052 CORBA::ULong length = policy_list->length ();
00053
00054
00055 for (CORBA::ULong i = 0; i < length; ++i)
00056 {
00057 if (policy_list[i]->policy_type () ==
00058 RTCORBA::PRIORITY_MODEL_POLICY_TYPE)
00059 this->exposed_priority_model (policy_list[i]);
00060
00061 else if (policy_list[i]->policy_type () ==
00062 RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE)
00063 this->exposed_priority_banded_connection (policy_list[i]);
00064
00065 else if (policy_list[i]->policy_type () ==
00066 RTCORBA::CLIENT_PROTOCOL_POLICY_TYPE)
00067 this->exposed_client_protocol (policy_list[i]);
00068 }
00069
00070 this->are_policies_parsed_ = 1;
00071 }
00072
00073 CORBA::Policy *
00074 TAO_RT_Stub::exposed_priority_model (ACE_ENV_SINGLE_ARG_DECL)
00075 {
00076 if (!this->are_policies_parsed_)
00077 {
00078 this->parse_policies (ACE_ENV_SINGLE_ARG_PARAMETER);
00079 ACE_CHECK_RETURN (CORBA::Policy::_nil ());
00080 }
00081
00082 return CORBA::Policy::_duplicate (this->priority_model_policy_.in ());
00083 }
00084
00085 void
00086 TAO_RT_Stub::exposed_priority_model (CORBA::Policy_ptr policy)
00087 {
00088 this->priority_model_policy_ = CORBA::Policy::_duplicate (policy);
00089 }
00090
00091 CORBA::Policy *
00092 TAO_RT_Stub::exposed_priority_banded_connection (ACE_ENV_SINGLE_ARG_DECL)
00093 {
00094 if (!this->are_policies_parsed_)
00095 {
00096 this->parse_policies (ACE_ENV_SINGLE_ARG_PARAMETER);
00097 ACE_CHECK_RETURN (CORBA::Policy::_nil ());
00098 }
00099
00100 return CORBA::Policy::_duplicate (this->priority_banded_connection_policy_.in ());
00101 }
00102
00103 void
00104 TAO_RT_Stub::exposed_priority_banded_connection (CORBA::Policy_ptr policy)
00105 {
00106 this->priority_banded_connection_policy_ =
00107 CORBA::Policy::_duplicate (policy);
00108 }
00109
00110 CORBA::Policy *
00111 TAO_RT_Stub::exposed_client_protocol (ACE_ENV_SINGLE_ARG_DECL)
00112 {
00113 if (!this->are_policies_parsed_)
00114 {
00115 this->parse_policies (ACE_ENV_SINGLE_ARG_PARAMETER);
00116 ACE_CHECK_RETURN (CORBA::Policy::_nil ());
00117 }
00118
00119 return CORBA::Policy::_duplicate (this->client_protocol_policy_.in ());
00120 }
00121
00122 void
00123 TAO_RT_Stub::exposed_client_protocol (CORBA::Policy_ptr policy)
00124 {
00125 this->client_protocol_policy_ = CORBA::Policy::_duplicate (policy);
00126 }
00127
00128 #if (TAO_HAS_CORBA_MESSAGING == 1)
00129
00130 CORBA::Policy_ptr
00131 TAO_RT_Stub::get_policy (CORBA::PolicyType type
00132 ACE_ENV_ARG_DECL)
00133 {
00134
00135
00136 if (type == RTCORBA::PRIORITY_MODEL_POLICY_TYPE)
00137 return this->exposed_priority_model (ACE_ENV_SINGLE_ARG_PARAMETER);
00138
00139 if (type == RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE)
00140 return this->effective_priority_banded_connection (ACE_ENV_SINGLE_ARG_PARAMETER);
00141
00142 if (type == RTCORBA::CLIENT_PROTOCOL_POLICY_TYPE)
00143 return this->effective_client_protocol (ACE_ENV_SINGLE_ARG_PARAMETER);
00144
00145 return this->TAO_Stub::get_policy (type ACE_ENV_ARG_PARAMETER);
00146 }
00147
00148 CORBA::Policy_ptr
00149 TAO_RT_Stub::get_cached_policy (TAO_Cached_Policy_Type type
00150 ACE_ENV_ARG_DECL)
00151 {
00152
00153
00154 if (type == TAO_CACHED_POLICY_PRIORITY_MODEL)
00155 return this->exposed_priority_model (ACE_ENV_SINGLE_ARG_PARAMETER);
00156
00157 if (type == TAO_CACHED_POLICY_RT_PRIORITY_BANDED_CONNECTION)
00158 return this->effective_priority_banded_connection (ACE_ENV_SINGLE_ARG_PARAMETER);
00159
00160 if (type == TAO_CACHED_POLICY_RT_CLIENT_PROTOCOL)
00161 return this->effective_client_protocol (ACE_ENV_SINGLE_ARG_PARAMETER);
00162
00163 return this->TAO_Stub::get_cached_policy (type ACE_ENV_ARG_PARAMETER);
00164 }
00165
00166
00167 TAO_Stub *
00168 TAO_RT_Stub::set_policy_overrides (const CORBA::PolicyList & policies,
00169 CORBA::SetOverrideType set_add
00170 ACE_ENV_ARG_DECL)
00171 {
00172
00173
00174 for (CORBA::ULong i = 0; i < policies.length (); ++i)
00175 {
00176 CORBA::Policy_ptr policy = policies[i];
00177 if (CORBA::is_nil (policy))
00178 continue;
00179
00180 CORBA::PolicyType type = policy->policy_type (ACE_ENV_SINGLE_ARG_PARAMETER);
00181 ACE_CHECK_RETURN (0);
00182
00183 if (type == RTCORBA::PRIORITY_MODEL_POLICY_TYPE ||
00184 type == RTCORBA::THREADPOOL_POLICY_TYPE ||
00185 type == RTCORBA::SERVER_PROTOCOL_POLICY_TYPE)
00186 ACE_THROW_RETURN (CORBA::NO_PERMISSION (), 0);
00187
00188 }
00189
00190
00191
00192 return this->TAO_Stub::set_policy_overrides(policies, set_add ACE_ENV_ARG_PARAMETER);
00193 }
00194
00195 #endif
00196
00197 CORBA::Policy *
00198 TAO_RT_Stub::effective_priority_banded_connection (ACE_ENV_SINGLE_ARG_DECL)
00199 {
00200
00201 CORBA::Policy_var override =
00202 this->TAO_Stub::get_cached_policy (TAO_CACHED_POLICY_RT_PRIORITY_BANDED_CONNECTION
00203 ACE_ENV_ARG_PARAMETER);
00204 ACE_CHECK_RETURN (CORBA::Policy::_nil ());
00205
00206
00207 CORBA::Policy_var exposed =
00208 this->exposed_priority_banded_connection (ACE_ENV_SINGLE_ARG_PARAMETER);
00209 ACE_CHECK_RETURN (CORBA::Policy::_nil ());
00210
00211
00212 if (CORBA::is_nil (exposed.in ()))
00213 return override._retn ();
00214
00215 if (CORBA::is_nil (override.in ()))
00216 return exposed._retn ();
00217
00218 RTCORBA::PriorityBandedConnectionPolicy_var override_policy_var =
00219 RTCORBA::PriorityBandedConnectionPolicy::_narrow (override.in ()
00220 ACE_ENV_ARG_PARAMETER);
00221 ACE_CHECK_RETURN (CORBA::Policy::_nil ());
00222
00223 TAO_PriorityBandedConnectionPolicy *override_policy =
00224 static_cast<TAO_PriorityBandedConnectionPolicy *> (override_policy_var.in ());
00225
00226 RTCORBA::PriorityBandedConnectionPolicy_var exposed_policy_var =
00227 RTCORBA::PriorityBandedConnectionPolicy::_narrow (exposed.in ()
00228 ACE_ENV_ARG_PARAMETER);
00229 ACE_CHECK_RETURN (CORBA::Policy::_nil ());
00230
00231 TAO_PriorityBandedConnectionPolicy *exposed_policy =
00232 static_cast<TAO_PriorityBandedConnectionPolicy *> (exposed_policy_var.in ());
00233
00234
00235
00236 if (exposed_policy->priority_bands_rep ().length () == 0)
00237 return override._retn ();
00238
00239 if (override_policy->priority_bands_rep ().length () == 0)
00240 return exposed._retn ();
00241
00242
00243
00244 ACE_THROW_RETURN (CORBA::INV_POLICY (),
00245 0);
00246 }
00247
00248 CORBA::Policy *
00249 TAO_RT_Stub::effective_client_protocol (ACE_ENV_SINGLE_ARG_DECL)
00250 {
00251
00252 CORBA::Policy_var override =
00253 this->TAO_Stub::get_cached_policy (TAO_CACHED_POLICY_RT_CLIENT_PROTOCOL
00254 ACE_ENV_ARG_PARAMETER);
00255 ACE_CHECK_RETURN (CORBA::Policy::_nil ());
00256
00257
00258 CORBA::Policy_var exposed =
00259 this->exposed_client_protocol (ACE_ENV_SINGLE_ARG_PARAMETER);
00260 ACE_CHECK_RETURN (CORBA::Policy::_nil ());
00261
00262
00263 if (CORBA::is_nil (exposed.in ()))
00264 return override._retn ();
00265
00266 if (CORBA::is_nil (override.in ()))
00267 return exposed._retn ();
00268
00269 RTCORBA::ClientProtocolPolicy_var override_policy_var =
00270 RTCORBA::ClientProtocolPolicy::_narrow (override.in ()
00271 ACE_ENV_ARG_PARAMETER);
00272 ACE_CHECK_RETURN (CORBA::Policy::_nil ());
00273
00274 TAO_ClientProtocolPolicy *override_policy =
00275 static_cast<TAO_ClientProtocolPolicy *> (override_policy_var.in ());
00276
00277 RTCORBA::ClientProtocolPolicy_var exposed_policy_var =
00278 RTCORBA::ClientProtocolPolicy::_narrow (exposed.in ()
00279 ACE_ENV_ARG_PARAMETER);
00280 ACE_CHECK_RETURN (CORBA::Policy::_nil ());
00281
00282 TAO_ClientProtocolPolicy *exposed_policy =
00283 static_cast<TAO_ClientProtocolPolicy *> (exposed_policy_var.in ());
00284
00285
00286
00287 RTCORBA::ProtocolList &protocols_rep_var =
00288 exposed_policy->protocols_rep ();
00289
00290 if (protocols_rep_var.length () == 0)
00291 return override._retn ();
00292
00293 if (override_policy->protocols_rep ().length () == 0)
00294 return exposed._retn ();
00295
00296
00297
00298 ACE_THROW_RETURN (CORBA::INV_POLICY (),
00299 0);
00300 }
00301
00302 TAO_END_VERSIONED_NAMESPACE_DECL
00303
00304 #endif