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
228
229
230
231
232
|
// -*- C++ -*-
// $Id$
#include "Server_Request_Interceptor.h"
#include "testC.h"
#include "tao/AnyTypeCode/AnyTypeCode_Adapter_Impl.h"
#include "tao/AnyTypeCode/TypeCode.h"
#include "ace/OS_NS_string.h"
Server_Request_Interceptor::Server_Request_Interceptor (const char *name)
: Request_Interceptor (name),
scenario_ (0)
{
}
void
Server_Request_Interceptor::receive_request_service_contexts (
PortableInterceptor::ServerRequestInfo_ptr ri)
{
CORBA::Boolean server_side =
this->server_side_test (ri);
if (!server_side)
return; // Don't continue if the client side is being tested.
ACE_DEBUG ((LM_INFO,
"%C.receive_request_service_contexts",
this->name_.in ()));
if (ACE_OS::strcmp ("SERVER B", this->name_.in ()) == 0)
{
this->scenario_++;
switch (this->scenario_)
{
case 2:
// We can only throw a CORBA::SystemException or a
// PortableInteceptor::ForwardRequest exception due to
// the restricted exception specification dictated by
// the IDL for request interceptors. As such, an
// arbitrary CORBA::SystemException was chosen
// (NO_PERMISSION, in this case).
ACE_DEBUG ((LM_DEBUG,
" raised CORBA::NO_PERMISSION exception\n"));
throw CORBA::NO_PERMISSION (); // Expected exception.
default:
break;
}
}
ACE_DEBUG ((LM_DEBUG,
"\n"));
this->starting_interception_point_count_++;
}
void
Server_Request_Interceptor::receive_request (
PortableInterceptor::ServerRequestInfo_ptr ri)
{
CORBA::Boolean server_side =
this->server_side_test (ri);
if (!server_side)
return; // Don't continue if the client side is being tested.
ACE_DEBUG ((LM_INFO,
"%C.receive_request\n",
this->name_.in ()));
}
void
Server_Request_Interceptor::send_reply (
PortableInterceptor::ServerRequestInfo_ptr ri)
{
CORBA::Boolean server_side =
this->server_side_test (ri);
if (!server_side)
return; // Don't continue if the client side is being tested.
this->ending_interception_point_count_++;
ACE_DEBUG ((LM_INFO,
"%C.send_reply",
this->name_.in ()));
if (ACE_OS::strcmp ("SERVER B", this->name_.in ()) == 0)
{
// Determine which test scenario we are in
Dynamic::ParameterList_var paramlist =
ri->arguments ();
Test::TestScenario scenario;
CORBA::ULong i = 0; // index -- explicitly used to avoid
// overloaded operator ambiguity.
if (paramlist[i].argument >>= scenario)
{
switch (scenario)
{
case 3:
// We can only throw a CORBA::SystemException or a
// PortableInteceptor::ForwardRequest exception due to
// the restricted exception specification dictated by
// the IDL for request interceptors. As such, an
// arbitrary CORBA::SystemException was chosen
// (NO_PERMISSION, in this case).
ACE_DEBUG ((LM_DEBUG,
" raised CORBA::NO_PERMISSION exception\n"));
throw CORBA::NO_PERMISSION (); // Expected exception.
default:
break;
}
}
else
ACE_ERROR ((LM_ERROR,
"\nERROR: send_reply - Could not extract "
"arguments.\n"));
}
ACE_DEBUG ((LM_DEBUG,
"\n"));
}
void
Server_Request_Interceptor::send_exception (
PortableInterceptor::ServerRequestInfo_ptr ri)
{
CORBA::Boolean server_side =
this->server_side_test (ri);
if (!server_side)
return; // Don't continue if the client side is being tested.
this->ending_interception_point_count_++;
ACE_DEBUG ((LM_INFO,
"%C.send_exception",
this->name_.in ()));
if (ACE_OS::strcmp ("SERVER B", this->name_.in ()) == 0)
{
// Determine which test scenario we are in
Dynamic::ParameterList_var paramlist =
ri->arguments ();
Test::TestScenario scenario;
CORBA::ULong i = 0; // index -- explicitly used to avoid
// overloaded operator ambiguity.
if (paramlist[i].argument >>= scenario)
{
CORBA::Any_var exception;
CORBA::TypeCode_var tc;
const char *id = 0;
switch (scenario)
{
case 4:
exception = ri->sending_exception ();
tc = exception->type ();
id = tc->id ();
if (ACE_OS::strcmp (id, "IDL:Test/X:1.0") == 0)
{
// We can only throw a CORBA::SystemException or a
// PortableInteceptor::ForwardRequest exception due
// to the restricted exception specification
// dictated by the IDL for request interceptors. As
// such, an arbitrary CORBA::SystemException was
// chosen (NO_PERMISSION, in this case).
ACE_DEBUG ((LM_DEBUG,
" transformed Test::X exception to "
"CORBA::NO_PERMISSION exception\n"));
// Expected exception.
throw CORBA::NO_PERMISSION ();
}
else
{
ACE_ERROR ((LM_ERROR,
"\nERROR: send_exception - Received "
"unexpected exception!\n"));
}
break;
default:
break;
}
}
else
ACE_ERROR ((LM_ERROR,
"\nERROR: send_exception - Could not extract "
"arguments.\n"));
}
ACE_DEBUG ((LM_DEBUG,
"\n"));
}
void
Server_Request_Interceptor::send_other (
PortableInterceptor::ServerRequestInfo_ptr ri)
{
CORBA::Boolean server_side =
this->server_side_test (ri);
if (!server_side)
return; // Don't continue if the client side is being tested.
this->ending_interception_point_count_++;
ACE_DEBUG ((LM_INFO,
"%C.send_other",
this->name_.in ()));
}
CORBA::Boolean
Server_Request_Interceptor::server_side_test (
PortableInterceptor::ServerRequestInfo_ptr info)
{
CORBA::String_var op = info->operation ();
return ACE_OS::strcmp (op.in (), "server_test") == 0 ? 1 : 0;
}
|