Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Portable_Interceptors / Benchmark / server_interceptors.cpp
blob1cb6435172c48a747bbe94aa24132d30e6a2c69d
1 #include "server_interceptors.h"
3 #include "tao/AnyTypeCode/DynamicC.h"
4 #include "tao/AnyTypeCode/TypeCode.h"
5 #include "ace/OS_NS_string.h"
6 #include "ace/Log_Msg.h"
8 const CORBA::ULong request_ctx_id = 0xdead;
9 //const CORBA::ULong reply_ctx_id = 0xbeef; // Never used.
11 Vault_Server_Request_Interceptor::Vault_Server_Request_Interceptor (void)
12 : myname_ ("Vault_Server_Interceptor")
16 Vault_Server_Request_Interceptor::~Vault_Server_Request_Interceptor ()
20 char *
21 Vault_Server_Request_Interceptor::name (void)
23 return CORBA::string_dup (this->myname_);
26 void
27 Vault_Server_Request_Interceptor::destroy (void)
31 void
32 Vault_Server_Request_Interceptor::receive_request_service_contexts (
33 PortableInterceptor::ServerRequestInfo_ptr)
35 // Do nothing
38 void
39 Vault_Server_Request_Interceptor::receive_request (
40 PortableInterceptor::ServerRequestInfo_ptr ri)
43 CORBA::String_var op = ri->operation ();
45 if (ACE_OS::strcmp (op.in (), "authenticate") == 0)
47 IOP::ServiceId id = request_ctx_id;
48 IOP::ServiceContext_var sc =
49 ri->get_request_service_context (id);
51 const char *buf =
52 reinterpret_cast<const char *> (sc->context_data.get_buffer ());
54 if (ACE_OS::strcmp (buf, "root123") != 0)
55 throw CORBA::NO_PERMISSION ();
58 if (ACE_OS::strcmp (op.in (), "update_records") == 0)
60 Dynamic::ParameterList_var paramlist =
61 ri->arguments ();
63 const Test_Interceptors::Secure_Vault::Record *record = 0;
64 CORBA::Long id;
65 CORBA::ULong i = 0; // index -- explicitly used to avoid
66 // overloaded operator ambiguity.
67 paramlist[i++].argument >>= id;
68 paramlist[i].argument >>= record;
72 void
73 Vault_Server_Request_Interceptor::send_reply (
74 PortableInterceptor::ServerRequestInfo_ptr ri)
77 CORBA::String_var op = ri->operation ();
79 if (ACE_OS::strcmp (op.in (), "update_records") == 0)
81 CORBA::Long result;
82 CORBA::Any_var result_any = ri->result ();
84 (result_any.in ()) >>= result;
88 void
89 Vault_Server_Request_Interceptor::send_exception (
90 PortableInterceptor::ServerRequestInfo_ptr)
92 // Do Nothing
95 void
96 Vault_Server_Request_Interceptor::send_other (
97 PortableInterceptor::ServerRequestInfo_ptr)
99 // Do Nothing
103 ////////////////////////////////// Context /////////////////////////
105 Vault_Server_Request_Context_Interceptor::Vault_Server_Request_Context_Interceptor (void)
106 : myname_ ("Vault_Server_Context_Interceptor")
110 Vault_Server_Request_Context_Interceptor::~Vault_Server_Request_Context_Interceptor ()
114 char *
115 Vault_Server_Request_Context_Interceptor::name ()
117 return CORBA::string_dup (this->myname_);
120 void
121 Vault_Server_Request_Context_Interceptor::destroy ()
125 void
126 Vault_Server_Request_Context_Interceptor::receive_request_service_contexts(
127 PortableInterceptor::ServerRequestInfo_ptr)
129 // Do nothing
132 void
133 Vault_Server_Request_Context_Interceptor::receive_request (
134 PortableInterceptor::ServerRequestInfo_ptr ri)
137 IOP::ServiceId id = request_ctx_id;
138 IOP::ServiceContext_var sc =
139 ri->get_request_service_context (id);
141 const char *buf = reinterpret_cast<const char *> (sc->context_data.get_buffer ());
143 if (ACE_OS::strcmp (buf, "root123") !=0)
144 throw CORBA::NO_PERMISSION ();
147 void
148 Vault_Server_Request_Context_Interceptor::send_reply (
149 PortableInterceptor::ServerRequestInfo_ptr)
154 void
155 Vault_Server_Request_Context_Interceptor::send_exception (
156 PortableInterceptor::ServerRequestInfo_ptr)
160 void
161 Vault_Server_Request_Context_Interceptor::send_other (
162 PortableInterceptor::ServerRequestInfo_ptr)
164 // Do Nothing
167 ///////////////////////////////////Dynamic ////////////////////////////////////
169 Vault_Server_Request_Dynamic_Interceptor::Vault_Server_Request_Dynamic_Interceptor (void)
170 : myname_ ("Vault_Server_Dynamic_Interceptor")
174 Vault_Server_Request_Dynamic_Interceptor::~Vault_Server_Request_Dynamic_Interceptor ()
178 char *
179 Vault_Server_Request_Dynamic_Interceptor::name ()
181 return CORBA::string_dup (this->myname_);
184 void
185 Vault_Server_Request_Dynamic_Interceptor::destroy ()
189 void
190 Vault_Server_Request_Dynamic_Interceptor::receive_request (
191 PortableInterceptor::ServerRequestInfo_ptr ri)
194 CORBA::String_var op = ri->operation ();
196 if (ACE_OS::strcmp (op.in (), "authenticate") == 0)
198 Dynamic::ParameterList_var paramlist =
199 ri->arguments ();
201 const char *user;
202 CORBA::ULong i = 0; // index -- explicitly used to avoid
203 // overloaded operator ambiguity.
204 paramlist[i].argument >>= user;
207 if (ACE_OS::strcmp (op.in (), "update_records") == 0)
209 Dynamic::ParameterList_var paramlist =
210 ri->arguments ();
212 const Test_Interceptors::Secure_Vault::Record *record = 0;
213 CORBA::Long id;
214 CORBA::ULong i = 0; // index -- explicitly used to avoid
215 // overloaded operator ambiguity.
216 paramlist[i++].argument >>= id;
217 paramlist[i].argument >>= record;
221 void
222 Vault_Server_Request_Dynamic_Interceptor::receive_request_service_contexts(
223 PortableInterceptor::ServerRequestInfo_ptr)
225 // Do nothing
228 void
229 Vault_Server_Request_Dynamic_Interceptor::send_reply (
230 PortableInterceptor::ServerRequestInfo_ptr ri)
233 CORBA::String_var op = ri->operation ();
235 if (ACE_OS::strcmp (op.in (), "ready") == 0)
237 CORBA::Short result;
238 CORBA::Any_var result_any = ri->result ();
240 (result_any.in ()) >>= result;
243 if (ACE_OS::strcmp (op.in (), "update_records") == 0)
245 CORBA::Long result;
246 CORBA::Any_var result_any = ri->result ();
248 (result_any.in ()) >>= result;
252 void
253 Vault_Server_Request_Dynamic_Interceptor::send_exception (
254 PortableInterceptor::ServerRequestInfo_ptr)
258 void
259 Vault_Server_Request_Dynamic_Interceptor::send_other (
260 PortableInterceptor::ServerRequestInfo_ptr)
262 // Do Nothing
265 //////////////////////////////NOOP///////////////////////////////////////
267 Vault_Server_Request_NOOP_Interceptor::Vault_Server_Request_NOOP_Interceptor (void)
268 : myname_ ("Vault_Server_NOOP_Interceptor")
272 Vault_Server_Request_NOOP_Interceptor::~Vault_Server_Request_NOOP_Interceptor ()
276 char *
277 Vault_Server_Request_NOOP_Interceptor::name (void)
279 return CORBA::string_dup (this->myname_);
282 void
283 Vault_Server_Request_NOOP_Interceptor::destroy ()
287 void
288 Vault_Server_Request_NOOP_Interceptor::receive_request (
289 PortableInterceptor::ServerRequestInfo_ptr)
293 void
294 Vault_Server_Request_NOOP_Interceptor::receive_request_service_contexts(
295 PortableInterceptor::ServerRequestInfo_ptr)
297 // Do nothing
300 void
301 Vault_Server_Request_NOOP_Interceptor::send_reply (
302 PortableInterceptor::ServerRequestInfo_ptr)
307 void
308 Vault_Server_Request_NOOP_Interceptor::send_exception (
309 PortableInterceptor::ServerRequestInfo_ptr)
313 void
314 Vault_Server_Request_NOOP_Interceptor::send_other (
315 PortableInterceptor::ServerRequestInfo_ptr)
317 // Do Nothing