Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Collocated_Forwarding / Server_Request_Interceptor.cpp
blob548f1027c09cf7b88d79beeccfa1bb513c55b5e4
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 (void)
41 return CORBA::string_dup ("Server_Request_Interceptor");
44 void
45 Server_Request_Interceptor::destroy (void)
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_);
73 return;
76 void
77 Server_Request_Interceptor::send_reply (
78 PortableInterceptor::ServerRequestInfo_ptr)
82 void
83 Server_Request_Interceptor::send_exception (
84 PortableInterceptor::ServerRequestInfo_ptr)
88 void
89 Server_Request_Interceptor::send_other (
90 PortableInterceptor::ServerRequestInfo_ptr)