Go to the documentation of this file.00001
00002
00003 #include "tao/IORInterceptor/IORInterceptor_Adapter_Impl.h"
00004 #include "tao/IORInterceptor/IORInfo.h"
00005 #include "tao/debug.h"
00006 #include "tao/ORB_Constants.h"
00007 #include "tao/PI/PI.h"
00008 #include "tao/PortableServer/Root_POA.h"
00009 #include "tao/PortableServer/Non_Servant_Upcall.h"
00010
00011 ACE_RCSID (IORInterceptor,
00012 IORInterceptor_Adapter_Impl,
00013 "$Id: IORInterceptor_Adapter_Impl.cpp 83957 2008-12-03 08:09:57Z johnnyw $")
00014
00015
00016 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00017
00018 TAO_IORInterceptor_Adapter_Impl::~TAO_IORInterceptor_Adapter_Impl (void)
00019 {
00020 }
00021
00022 void
00023 TAO_IORInterceptor_Adapter_Impl::add_interceptor (
00024 PortableInterceptor::IORInterceptor_ptr i)
00025 {
00026 this->ior_interceptor_list_.add_interceptor (i);
00027 }
00028
00029 void
00030 TAO_IORInterceptor_Adapter_Impl::add_interceptor (
00031 PortableInterceptor::IORInterceptor_ptr i,
00032 const CORBA::PolicyList& policies)
00033 {
00034 this->ior_interceptor_list_.add_interceptor (i, policies);
00035 }
00036
00037 void
00038 TAO_IORInterceptor_Adapter_Impl::destroy_interceptors (void)
00039 {
00040 this->ior_interceptor_list_.destroy_interceptors ();
00041
00042 delete this;
00043 }
00044
00045 void
00046 TAO_IORInterceptor_Adapter_Impl::establish_components (TAO_Root_POA* poa)
00047 {
00048 size_t const interceptor_count = this->ior_interceptor_list_.size ();
00049
00050 if (interceptor_count == 0)
00051 return;
00052
00053 TAO_IORInfo *tao_info = 0;
00054 ACE_NEW_THROW_EX (tao_info,
00055 TAO_IORInfo (poa),
00056 CORBA::NO_MEMORY (
00057 CORBA::SystemException::_tao_minor_code (
00058 TAO::VMCID,
00059 ENOMEM),
00060 CORBA::COMPLETED_NO));
00061
00062 PortableInterceptor::IORInfo_var info = tao_info;
00063
00064
00065
00066 TAO::Portable_Server::Non_Servant_Upcall non_servant_upcall (*poa);
00067 ACE_UNUSED_ARG (non_servant_upcall);
00068
00069 for (size_t i = 0; i < interceptor_count; ++i)
00070 {
00071 try
00072 {
00073 this->ior_interceptor_list_.interceptor (i)->establish_components (
00074 info.in ());
00075 }
00076 catch (const ::CORBA::Exception& ex)
00077 {
00078
00079
00080
00081
00082
00083 if (TAO_debug_level > 1)
00084 {
00085 CORBA::String_var name =
00086 this->ior_interceptor_list_.interceptor (i)->name ();
00087
00088
00089 if (name.in () != 0)
00090 {
00091 ACE_DEBUG ((LM_WARNING,
00092 "(%P|%t) Exception thrown while processing "
00093 "IORInterceptor \"%C\">\n",
00094 name.in ()));
00095 }
00096
00097 ex._tao_print_exception (
00098 "Ignoring exception in "
00099 "IORInterceptor::establish_components");
00100 }
00101 }
00102 }
00103
00104 tao_info->components_established ();
00105
00106 this->components_established (info.in ());
00107
00108
00109
00110 tao_info->invalidate ();
00111 }
00112
00113 void
00114 TAO_IORInterceptor_Adapter_Impl::components_established (
00115 PortableInterceptor::IORInfo_ptr info)
00116 {
00117
00118
00119
00120 size_t const interceptor_count = this->ior_interceptor_list_.size ();
00121
00122
00123
00124
00125 for (size_t j = 0; j < interceptor_count; ++j)
00126 {
00127 try
00128 {
00129 PortableInterceptor::IORInterceptor_ptr ior_interceptor =
00130 this->ior_interceptor_list_.interceptor (j);
00131
00132 PortableInterceptor::IORInterceptor_3_0_var ior_3_interceptor =
00133 PortableInterceptor::IORInterceptor_3_0::_narrow (ior_interceptor);
00134 if (!CORBA::is_nil (ior_3_interceptor.in ()))
00135 {
00136 ior_3_interceptor->components_established (info);
00137 }
00138 }
00139 catch (const ::CORBA::Exception&)
00140 {
00141 throw ::CORBA::OBJ_ADAPTER (CORBA::OMGVMCID | 6,
00142 CORBA::COMPLETED_NO);
00143 }
00144 }
00145 }
00146
00147 void
00148 TAO_IORInterceptor_Adapter_Impl::adapter_state_changed (
00149 const TAO::ObjectReferenceTemplate_Array &array_obj_ref_template,
00150 PortableInterceptor::AdapterState state)
00151 {
00152 size_t const interceptor_count = this->ior_interceptor_list_.size ();
00153
00154 if (interceptor_count == 0)
00155 return;
00156
00157 PortableInterceptor::ObjectReferenceTemplateSeq seq_obj_ref_template;
00158
00159 seq_obj_ref_template.length (
00160 static_cast <CORBA::ULong> (array_obj_ref_template.size()));
00161
00162 for (size_t counter = 0; counter < array_obj_ref_template.size(); ++counter)
00163 {
00164 PortableInterceptor::ObjectReferenceTemplate *member =
00165 array_obj_ref_template[counter];
00166
00167 CORBA::add_ref (member);
00168
00169 seq_obj_ref_template[counter] = member;
00170 }
00171
00172 for (size_t i = 0; i < interceptor_count; ++i)
00173 {
00174 PortableInterceptor::IORInterceptor_ptr ior_interceptor =
00175 this->ior_interceptor_list_.interceptor (i);
00176
00177 PortableInterceptor::IORInterceptor_3_0_var ior_3_interceptor =
00178 PortableInterceptor::IORInterceptor_3_0::_narrow (ior_interceptor);
00179 if (!CORBA::is_nil (ior_3_interceptor.in ()))
00180 {
00181 ior_3_interceptor->adapter_state_changed (seq_obj_ref_template, state);
00182 }
00183 }
00184 }
00185
00186 void
00187 TAO_IORInterceptor_Adapter_Impl::adapter_manager_state_changed (
00188 const char * id,
00189 PortableInterceptor::AdapterState state)
00190 {
00191
00192
00193
00194 size_t const interceptor_count = this->ior_interceptor_list_.size ();
00195
00196 if (interceptor_count == 0)
00197 return;
00198
00199 for (size_t i = 0; i < interceptor_count; ++i)
00200 {
00201 PortableInterceptor::IORInterceptor_ptr ior_interceptor =
00202 this->ior_interceptor_list_.interceptor (i);
00203
00204 PortableInterceptor::IORInterceptor_3_0_var ior_3_interceptor =
00205 PortableInterceptor::IORInterceptor_3_0::_narrow (ior_interceptor);
00206 if (!CORBA::is_nil (ior_3_interceptor.in ()))
00207 {
00208 ior_3_interceptor->adapter_manager_state_changed (id, state);
00209 }
00210 }
00211 }
00212
00213 TAO_END_VERSIONED_NAMESPACE_DECL