1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
// $Id$
#include "IORInterceptor_Adapter_Impl.h"
#include "IORInfo.h"
#include "tao/debug.h"
#include "tao/ORB_Constants.h"
#include "tao/PI/PI.h"
#include "tao/PortableServer/Root_POA.h"
#include "tao/PortableServer/Non_Servant_Upcall.h"
ACE_RCSID (IORInterceptor,
IORInterceptor_Adapter_Impl,
"$Id$")
TAO_IORInterceptor_Adapter_Impl::~TAO_IORInterceptor_Adapter_Impl (void)
{
}
void
TAO_IORInterceptor_Adapter_Impl::add_interceptor (
PortableInterceptor::IORInterceptor_ptr i
ACE_ENV_ARG_DECL
)
{
int retval =
this->ior_interceptor_list_.add_interceptor (i
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
if (retval == -1)
{
ACE_THROW (PortableInterceptor::ORBInitInfo::DuplicateName ());
}
}
void
TAO_IORInterceptor_Adapter_Impl::destroy_interceptors (ACE_ENV_SINGLE_ARG_DECL)
{
this->ior_interceptor_list_.destroy_interceptors (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
delete this;
}
void
TAO_IORInterceptor_Adapter_Impl::establish_components (
TAO_Root_POA* poa
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO::IORInterceptor_List::TYPE & interceptors =
this->ior_interceptor_list_.interceptors ();
const size_t interceptor_count = interceptors.size ();
if (interceptor_count == 0)
return;
TAO_IORInfo *tao_info = 0;
ACE_NEW_THROW_EX (tao_info,
TAO_IORInfo (poa),
CORBA::NO_MEMORY (
CORBA::SystemException::_tao_minor_code (
TAO::VMCID,
ENOMEM),
CORBA::COMPLETED_NO));
ACE_CHECK;
PortableInterceptor::IORInfo_var info = tao_info;
// Release the POA during IORInterceptor calls to avoid potential
// deadlocks.
TAO::Portable_Server::Non_Servant_Upcall non_servant_upcall (*poa);
ACE_UNUSED_ARG (non_servant_upcall);
for (size_t i = 0; i < interceptor_count; ++i)
{
ACE_TRY
{
interceptors[i]->establish_components (info.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
ACE_CATCHANY
{
// According to the Portable Interceptors specification,
// IORInterceptor::establish_components() must not throw an
// exception. If it does, then the ORB is supposed to
// ignore it and continue processing the remaining
// IORInterceptors.
if (TAO_debug_level > 1)
{
CORBA::String_var name = interceptors[i]->name (
ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
// @@ What do we do if we get an exception here?
if (name.in () != 0)
{
ACE_DEBUG ((LM_WARNING,
"(%P|%t) Exception thrown while processing "
"IORInterceptor \"%s\">\n",
ACE_TEXT_CHAR_TO_TCHAR (name.in ())));
}
ACE_PRINT_TAO_EXCEPTION (ACE_ANY_EXCEPTION,
"Ignoring exception in "
"IORInterceptor::establish_components");
}
}
ACE_ENDTRY;
ACE_CHECK;
}
tao_info->components_established ();
this->components_established (info.in ()
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
// The IORInfo instance is no longer valid. Invalidate it to
// prevent the user from peforming "illegal" operations.
tao_info->invalidate ();
}
void
TAO_IORInterceptor_Adapter_Impl::components_established (
PortableInterceptor::IORInfo_ptr info
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
// Iterate over the registered IOR interceptors so that they may be
// given the opportunity to add tagged components to the profiles
// for this servant.
TAO::IORInterceptor_List::TYPE & interceptors =
this->ior_interceptor_list_.interceptors ();
const size_t interceptor_count = interceptors.size ();
// All the establish_components() interception points have been
// invoked. Now call the components_established() interception point
// on all the IORInterceptors.
for (size_t j = 0; j < interceptor_count; ++j)
{
ACE_TRY
{
interceptors[j]->components_established (
info
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
ACE_CATCHANY
{
ACE_THROW (CORBA::OBJ_ADAPTER (CORBA::OMGVMCID | 6,
CORBA::COMPLETED_NO));
}
ACE_ENDTRY;
ACE_CHECK;
}
}
void
TAO_IORInterceptor_Adapter_Impl::adapter_state_changed (
const TAO::ObjectReferenceTemplate_Array &array_obj_ref_template,
PortableInterceptor::AdapterState state
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO::IORInterceptor_List::TYPE interceptors =
this->ior_interceptor_list_.interceptors();
const size_t interceptor_count = interceptors.size ();
if (interceptor_count == 0)
return;
PortableInterceptor::ObjectReferenceTemplateSeq seq_obj_ref_template;
seq_obj_ref_template.length (array_obj_ref_template.size());
for (size_t counter = 0; counter < array_obj_ref_template.size(); ++counter)
{
PortableInterceptor::ObjectReferenceTemplate *member =
array_obj_ref_template[counter];
CORBA::add_ref (member);
seq_obj_ref_template[counter] = member;
}
for (size_t i = 0; i < interceptor_count; ++i)
{
interceptors[i]->adapter_state_changed (seq_obj_ref_template,
state
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
}
}
void
TAO_IORInterceptor_Adapter_Impl::adapter_manager_state_changed (
PortableInterceptor::AdapterManagerId id,
PortableInterceptor::AdapterState state
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
/// Whenever the POAManager state is changed, the
/// adapter_manager_state_changed method is to be invoked on all the IOR
/// Interceptors.
TAO::IORInterceptor_List::TYPE & interceptors =
this->ior_interceptor_list_.interceptors ();
const size_t interceptor_count = interceptors.size ();
if (interceptor_count == 0)
return;
for (size_t i = 0; i < interceptor_count; ++i)
{
interceptors[i]->adapter_manager_state_changed (
id,
state
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
}
}
|