00001
00002
00003 #include "tao/PI/ORBInitInfoC.h"
00004 #include "tao/PI/InterceptorC.h"
00005 #include "tao/SystemException.h"
00006 #include "tao/ORB_Constants.h"
00007 #include "tao/debug.h"
00008
00009 #include "ace/os_include/os_stddef.h"
00010 #include "ace/OS_NS_string.h"
00011 #include "ace/Log_Msg.h"
00012
00013 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00014
00015 namespace TAO
00016 {
00017 template <typename InterceptorType, typename DetailsType>
00018 Interceptor_List<InterceptorType,DetailsType>::Interceptor_List (void)
00019 {
00020 }
00021
00022 template <typename InterceptorType, typename DetailsType>
00023 typename Interceptor_List<InterceptorType,DetailsType>::RegisteredInterceptor&
00024 Interceptor_List<InterceptorType,DetailsType>::registered_interceptor (
00025 size_t index)
00026 {
00027 return this->interceptors_[index];
00028 }
00029
00030 template <typename InterceptorType, typename DetailsType>
00031 typename Interceptor_List<InterceptorType,DetailsType>::InterceptorType_ptr_type
00032 Interceptor_List<InterceptorType,DetailsType>::interceptor (size_t index)
00033 {
00034 return this->interceptors_[index].interceptor_.in ();
00035 }
00036
00037 template <typename InterceptorType, typename DetailsType>
00038 size_t
00039 Interceptor_List<InterceptorType,DetailsType>::size (void)
00040 {
00041 return this->interceptors_.size ();
00042 }
00043
00044 template <typename InterceptorType, typename DetailsType>
00045 void
00046 Interceptor_List<InterceptorType,DetailsType>::add_interceptor (
00047 InterceptorType_ptr_type interceptor
00048 ACE_ENV_ARG_DECL)
00049 {
00050 if (!CORBA::is_nil (interceptor))
00051 {
00052 const size_t old_len = this->interceptors_.size ();
00053
00054
00055
00056
00057 if (old_len > 0)
00058 {
00059
00060
00061 CORBA::String_var name =
00062 interceptor->name (ACE_ENV_SINGLE_ARG_PARAMETER);
00063 ACE_CHECK;
00064
00065 if (ACE_OS::strlen (name.in ()) != 0)
00066 {
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 for (size_t i = 0; i < old_len; ++i)
00083 {
00084 CORBA::String_var existing_name =
00085 this->interceptor (i)->name ();
00086
00087 if (ACE_OS::strcmp (existing_name.in (),
00088 name.in ()) == 0)
00089 {
00090 ACE_THROW (PortableInterceptor::ORBInitInfo::DuplicateName ());
00091 }
00092 }
00093 }
00094 }
00095
00096
00097 const size_t new_len = old_len + 1;
00098 this->interceptors_.size (new_len);
00099
00100
00101 this->interceptors_[old_len].interceptor_ =
00102 InterceptorType::_duplicate (interceptor);
00103 }
00104 else
00105 {
00106 ACE_THROW (
00107 CORBA::INV_OBJREF (
00108 CORBA::SystemException::_tao_minor_code (
00109 0,
00110 EINVAL
00111 ),
00112 CORBA::COMPLETED_NO
00113 )
00114 );
00115 }
00116 }
00117
00118 template <typename InterceptorType, typename DetailsType>
00119 void
00120 Interceptor_List<InterceptorType,DetailsType>::add_interceptor (
00121 InterceptorType_ptr_type interceptor,
00122 const CORBA::PolicyList& policies
00123 ACE_ENV_ARG_DECL)
00124 {
00125 if (!CORBA::is_nil (interceptor))
00126 {
00127 const size_t old_len = this->interceptors_.size ();
00128
00129
00130
00131
00132 if (old_len > 0)
00133 {
00134
00135
00136 CORBA::String_var name =
00137 interceptor->name (ACE_ENV_SINGLE_ARG_PARAMETER);
00138 ACE_CHECK;
00139
00140 if (ACE_OS::strlen (name.in ()) != 0)
00141 {
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157 for (size_t i = 0; i < old_len; ++i)
00158 {
00159 CORBA::String_var existing_name =
00160 this->interceptor (i)->name ();
00161
00162 if (ACE_OS::strcmp (existing_name.in (),
00163 name.in ()) == 0)
00164 {
00165 ACE_THROW (PortableInterceptor::ORBInitInfo::DuplicateName ());
00166 }
00167 }
00168 }
00169 }
00170
00171
00172 DetailsType details;
00173 details.apply_policies(policies ACE_ENV_ARG_PARAMETER);
00174 ACE_CHECK;
00175
00176
00177 const size_t new_len = old_len + 1;
00178 this->interceptors_.size (new_len);
00179
00180
00181 this->interceptors_[old_len].interceptor_ =
00182 InterceptorType::_duplicate (interceptor);
00183
00184
00185 this->interceptors_[old_len].details_ = details;
00186 }
00187 else
00188 {
00189 ACE_THROW (
00190 CORBA::INV_OBJREF (
00191 CORBA::SystemException::_tao_minor_code (
00192 0,
00193 EINVAL
00194 ),
00195 CORBA::COMPLETED_NO
00196 )
00197 );
00198 }
00199 }
00200
00201 template <typename InterceptorType, typename DetailsType>
00202 void
00203 Interceptor_List<InterceptorType,DetailsType>::destroy_interceptors (
00204 ACE_ENV_SINGLE_ARG_DECL)
00205 {
00206 const size_t len = this->interceptors_.size ();
00207 size_t ilen = len;
00208
00209 ACE_TRY
00210 {
00211 for (size_t k = 0; k < len; ++k)
00212 {
00213
00214
00215
00216 --ilen;
00217
00218 this->interceptor (k)->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
00219 ACE_TRY_CHECK;
00220
00221
00222
00223
00224
00225
00226 this->interceptors_.size (ilen);
00227 }
00228 }
00229 ACE_CATCHALL
00230 {
00231
00232 if (TAO_debug_level > 3)
00233 {
00234 ACE_DEBUG ((LM_DEBUG,
00235 ACE_TEXT ("TAO (%P|%t) - Exception in ")
00236 ACE_TEXT ("Interceptor_List")
00237 ACE_TEXT ("::destroy_interceptors () \n")));
00238 }
00239 }
00240 ACE_ENDTRY;
00241 ACE_CHECK;
00242 }
00243 }
00244
00245 TAO_END_VERSIONED_NAMESPACE_DECL