Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / tests / Collocated_Forwarding / Server_Request_Interceptor.cpp
blob14472d16d26c4253113a88d620647d5524984f9c
1 // -*- C++ -*-
2 #include "Server_Request_Interceptor.h"
3 #include "tao/PI_Server/PI_Server.h"
4 #include "tao/ORB_Constants.h"
5 #include "tao/CDR.h"
6 #include "testS.h"
8 Server_Request_Interceptor::Server_Request_Interceptor (CORBA::ULong request_pass_count)
9 : request_pass_count_ (request_pass_count)
10 , request_count_ (0)
11 , to_ (CORBA::Object::_nil ())
15 void
16 Server_Request_Interceptor::forward (
17 CORBA::Object_ptr to)
19 if (CORBA::is_nil (to))
20 throw CORBA::INV_OBJREF (
21 CORBA::SystemException::_tao_minor_code (
22 TAO::VMCID,
23 EINVAL),
24 CORBA::COMPLETED_NO);
26 ACE_TCHAR *argv[] = {NULL};
27 int argc = 0;
29 // Fetch the ORB having been initialized in main()
30 CORBA::ORB_var orb =
31 CORBA::ORB_init (argc, argv, "Server ORB");
33 CORBA::String_var s_to = orb->object_to_string (to);
35 this->to_ = orb->string_to_object (s_to.in ());
38 char *
39 Server_Request_Interceptor::name ()
41 return CORBA::string_dup ("Server_Request_Interceptor");
44 void
45 Server_Request_Interceptor::destroy ()
47 CORBA::release (this->to_);
50 void
51 Server_Request_Interceptor::receive_request_service_contexts (
52 PortableInterceptor::ServerRequestInfo_ptr)
54 this->request_count_++;
57 void
58 Server_Request_Interceptor::receive_request (
59 PortableInterceptor::ServerRequestInfo_ptr)
61 if (this->request_count_ == this->request_pass_count_)
63 ACE_DEBUG ((LM_DEBUG,
64 "SERVER: Request %d will be forwarded "
65 "to object 'to'\nSERVER: via "
66 "receive_request_service_contexts().\n",
67 this->request_count_));
69 // Throw forward exception
70 throw PortableInterceptor::ForwardRequest (this->to_);
74 void
75 Server_Request_Interceptor::send_reply (
76 PortableInterceptor::ServerRequestInfo_ptr)
80 void
81 Server_Request_Interceptor::send_exception (
82 PortableInterceptor::ServerRequestInfo_ptr)
86 void
87 Server_Request_Interceptor::send_other (
88 PortableInterceptor::ServerRequestInfo_ptr)