Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / Portable_Interceptors / Benchmark / server_interceptors.cpp
blobca63b652bc12aaba1d498947833050e6655a37a6
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 ()
12 : myname_ ("Vault_Server_Interceptor")
16 Vault_Server_Request_Interceptor::~Vault_Server_Request_Interceptor ()
20 char *
21 Vault_Server_Request_Interceptor::name ()
23 return CORBA::string_dup (this->myname_);
26 void
27 Vault_Server_Request_Interceptor::destroy ()
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)
42 CORBA::String_var op = ri->operation ();
44 if (ACE_OS::strcmp (op.in (), "authenticate") == 0)
46 IOP::ServiceId id = request_ctx_id;
47 IOP::ServiceContext_var sc =
48 ri->get_request_service_context (id);
50 const char *buf =
51 reinterpret_cast<const char *> (sc->context_data.get_buffer ());
53 if (ACE_OS::strcmp (buf, "root123") != 0)
54 throw CORBA::NO_PERMISSION ();
57 if (ACE_OS::strcmp (op.in (), "update_records") == 0)
59 Dynamic::ParameterList_var paramlist =
60 ri->arguments ();
62 const Test_Interceptors::Secure_Vault::Record *record = 0;
63 CORBA::Long id;
64 CORBA::ULong i = 0; // index -- explicitly used to avoid
65 // overloaded operator ambiguity.
66 paramlist[i++].argument >>= id;
67 paramlist[i].argument >>= record;
71 void
72 Vault_Server_Request_Interceptor::send_reply (
73 PortableInterceptor::ServerRequestInfo_ptr ri)
75 CORBA::String_var op = ri->operation ();
77 if (ACE_OS::strcmp (op.in (), "update_records") == 0)
79 CORBA::Long result;
80 CORBA::Any_var result_any = ri->result ();
82 (result_any.in ()) >>= result;
86 void
87 Vault_Server_Request_Interceptor::send_exception (
88 PortableInterceptor::ServerRequestInfo_ptr)
90 // Do Nothing
93 void
94 Vault_Server_Request_Interceptor::send_other (
95 PortableInterceptor::ServerRequestInfo_ptr)
97 // Do Nothing
101 ////////////////////////////////// Context /////////////////////////
103 Vault_Server_Request_Context_Interceptor::Vault_Server_Request_Context_Interceptor ()
104 : myname_ ("Vault_Server_Context_Interceptor")
108 Vault_Server_Request_Context_Interceptor::~Vault_Server_Request_Context_Interceptor ()
112 char *
113 Vault_Server_Request_Context_Interceptor::name ()
115 return CORBA::string_dup (this->myname_);
118 void
119 Vault_Server_Request_Context_Interceptor::destroy ()
123 void
124 Vault_Server_Request_Context_Interceptor::receive_request_service_contexts(
125 PortableInterceptor::ServerRequestInfo_ptr)
127 // Do nothing
130 void
131 Vault_Server_Request_Context_Interceptor::receive_request (
132 PortableInterceptor::ServerRequestInfo_ptr ri)
134 IOP::ServiceId id = request_ctx_id;
135 IOP::ServiceContext_var sc =
136 ri->get_request_service_context (id);
138 const char *buf = reinterpret_cast<const char *> (sc->context_data.get_buffer ());
140 if (ACE_OS::strcmp (buf, "root123") !=0)
141 throw CORBA::NO_PERMISSION ();
144 void
145 Vault_Server_Request_Context_Interceptor::send_reply (
146 PortableInterceptor::ServerRequestInfo_ptr)
150 void
151 Vault_Server_Request_Context_Interceptor::send_exception (
152 PortableInterceptor::ServerRequestInfo_ptr)
156 void
157 Vault_Server_Request_Context_Interceptor::send_other (
158 PortableInterceptor::ServerRequestInfo_ptr)
160 // Do Nothing
163 ///////////////////////////////////Dynamic ////////////////////////////////////
165 Vault_Server_Request_Dynamic_Interceptor::Vault_Server_Request_Dynamic_Interceptor ()
166 : myname_ ("Vault_Server_Dynamic_Interceptor")
170 Vault_Server_Request_Dynamic_Interceptor::~Vault_Server_Request_Dynamic_Interceptor ()
174 char *
175 Vault_Server_Request_Dynamic_Interceptor::name ()
177 return CORBA::string_dup (this->myname_);
180 void
181 Vault_Server_Request_Dynamic_Interceptor::destroy ()
185 void
186 Vault_Server_Request_Dynamic_Interceptor::receive_request (
187 PortableInterceptor::ServerRequestInfo_ptr ri)
189 CORBA::String_var op = ri->operation ();
191 if (ACE_OS::strcmp (op.in (), "authenticate") == 0)
193 Dynamic::ParameterList_var paramlist =
194 ri->arguments ();
196 const char *user;
197 CORBA::ULong i = 0; // index -- explicitly used to avoid
198 // overloaded operator ambiguity.
199 paramlist[i].argument >>= user;
202 if (ACE_OS::strcmp (op.in (), "update_records") == 0)
204 Dynamic::ParameterList_var paramlist =
205 ri->arguments ();
207 const Test_Interceptors::Secure_Vault::Record *record = 0;
208 CORBA::Long id;
209 CORBA::ULong i = 0; // index -- explicitly used to avoid
210 // overloaded operator ambiguity.
211 paramlist[i++].argument >>= id;
212 paramlist[i].argument >>= record;
216 void
217 Vault_Server_Request_Dynamic_Interceptor::receive_request_service_contexts(
218 PortableInterceptor::ServerRequestInfo_ptr)
220 // Do nothing
223 void
224 Vault_Server_Request_Dynamic_Interceptor::send_reply (
225 PortableInterceptor::ServerRequestInfo_ptr ri)
227 CORBA::String_var op = ri->operation ();
229 if (ACE_OS::strcmp (op.in (), "ready") == 0)
231 CORBA::Short result;
232 CORBA::Any_var result_any = ri->result ();
234 (result_any.in ()) >>= result;
237 if (ACE_OS::strcmp (op.in (), "update_records") == 0)
239 CORBA::Long result;
240 CORBA::Any_var result_any = ri->result ();
242 (result_any.in ()) >>= result;
246 void
247 Vault_Server_Request_Dynamic_Interceptor::send_exception (
248 PortableInterceptor::ServerRequestInfo_ptr)
252 void
253 Vault_Server_Request_Dynamic_Interceptor::send_other (
254 PortableInterceptor::ServerRequestInfo_ptr)
256 // Do Nothing
259 //////////////////////////////NOOP///////////////////////////////////////
261 Vault_Server_Request_NOOP_Interceptor::Vault_Server_Request_NOOP_Interceptor ()
262 : myname_ ("Vault_Server_NOOP_Interceptor")
266 Vault_Server_Request_NOOP_Interceptor::~Vault_Server_Request_NOOP_Interceptor ()
270 char *
271 Vault_Server_Request_NOOP_Interceptor::name ()
273 return CORBA::string_dup (this->myname_);
276 void
277 Vault_Server_Request_NOOP_Interceptor::destroy ()
281 void
282 Vault_Server_Request_NOOP_Interceptor::receive_request (
283 PortableInterceptor::ServerRequestInfo_ptr)
287 void
288 Vault_Server_Request_NOOP_Interceptor::receive_request_service_contexts(
289 PortableInterceptor::ServerRequestInfo_ptr)
291 // Do nothing
294 void
295 Vault_Server_Request_NOOP_Interceptor::send_reply (
296 PortableInterceptor::ServerRequestInfo_ptr)
300 void
301 Vault_Server_Request_NOOP_Interceptor::send_exception (
302 PortableInterceptor::ServerRequestInfo_ptr)
306 void
307 Vault_Server_Request_NOOP_Interceptor::send_other (
308 PortableInterceptor::ServerRequestInfo_ptr)
310 // Do Nothing