1 #include "server_interceptor.h"
2 #include "tao/OctetSeqC.h"
3 #include "ace/Log_Msg.h"
4 #include "tao/ORB_Constants.h"
5 #include "ace/OS_NS_string.h"
6 #include "ace/Thread.h"
8 ForwardTest_Request_Interceptor::ForwardTest_Request_Interceptor ()
9 : myname_ ("ForwardTest_Interceptor"),
10 forward_location_ (CORBA::Object::_nil ()),
11 forward_location_done_ (false)
15 ForwardTest_Request_Interceptor::ForwardTest_Request_Interceptor (CORBA::Object_ptr forward_location
)
16 : myname_ ("ForwardTest_Interceptor"),
17 forward_location_ (CORBA::Object::_duplicate (forward_location
)),
18 forward_location_done_ (false)
22 ForwardTest_Request_Interceptor::~ForwardTest_Request_Interceptor ()
27 ForwardTest_Request_Interceptor::forward_reference (CORBA::Object_ptr forward_location
)
29 if (CORBA::is_nil (forward_location
))
30 throw CORBA::INV_OBJREF (
31 CORBA::SystemException::_tao_minor_code (
35 this->forward_location_
= CORBA::Object::_duplicate (forward_location
);
39 ForwardTest_Request_Interceptor::name ()
41 return CORBA::string_dup (this->myname_
);
45 ForwardTest_Request_Interceptor::destroy ()
50 ForwardTest_Request_Interceptor::receive_request_service_contexts (
51 PortableInterceptor::ServerRequestInfo_ptr ri
)
53 CORBA::String_var operation
= ri
->operation ();
56 "%C.receive_request_service_contexts from "
61 // Ignore the "_is_a" operation since it may have been invoked
62 // locally on the server side as a side effect of another call,
63 // meaning that the client hasn't added the service context yet.
64 // Same goes for the shutdown call
65 if (ACE_OS::strcmp ("_is_a", operation
.in ()) == 0 ||
66 ACE_OS::strcmp ("shutdown", operation
.in ()) == 0)
69 if (!forward_location_done_
)
71 forward_location_done_
= true;
74 "Sending LOCATION_FORWARD, current thread %i\n",
75 ACE_Thread::self ()));
77 throw PortableInterceptor::ForwardRequest (
78 CORBA::Object::_duplicate (this->forward_location_
.in ()));
85 ForwardTest_Request_Interceptor::receive_request (
86 PortableInterceptor::ServerRequestInfo_ptr
)
91 ForwardTest_Request_Interceptor::send_reply (
92 PortableInterceptor::ServerRequestInfo_ptr
)
97 ForwardTest_Request_Interceptor::send_exception (
98 PortableInterceptor::ServerRequestInfo_ptr
)
103 ForwardTest_Request_Interceptor::send_other (
104 PortableInterceptor::ServerRequestInfo_ptr ri
)
106 // This will throw an exception if a location forward has not
107 // occurred. If an exception is thrown then something is wrong with
108 // the PortableInterceptor::ForwardRequest support.
109 CORBA::Object_var forward
= ri
->forward_reference ();
111 if (CORBA::is_nil (forward
.in ()))
112 throw CORBA::INTERNAL ();
116 ForwardTest_Request_Interceptor::forward_location_done() const
118 return forward_location_done_
;