Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / TAO / tests / DII_AMI_Forward / server_interceptor.cpp
blobe231f671307ed5b59578af1f6e8e1279f48de1f6
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 ()
26 void
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 (
32 TAO::VMCID,
33 EINVAL),
34 CORBA::COMPLETED_NO);
35 this->forward_location_ = CORBA::Object::_duplicate (forward_location);
38 char *
39 ForwardTest_Request_Interceptor::name ()
41 return CORBA::string_dup (this->myname_);
44 void
45 ForwardTest_Request_Interceptor::destroy ()
49 void
50 ForwardTest_Request_Interceptor::receive_request_service_contexts (
51 PortableInterceptor::ServerRequestInfo_ptr ri)
53 CORBA::String_var operation = ri->operation ();
55 ACE_DEBUG ((LM_DEBUG,
56 "%C.receive_request_service_contexts from "
57 "\"%C\"\n",
58 this->myname_,
59 operation.in ()));
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)
67 return;
69 if (!forward_location_done_)
71 forward_location_done_ = true;
73 ACE_DEBUG ((LM_DEBUG,
74 "Sending LOCATION_FORWARD, current thread %i\n",
75 ACE_Thread::self ()));
77 throw PortableInterceptor::ForwardRequest (
78 CORBA::Object::_duplicate (this->forward_location_.in ()));
84 void
85 ForwardTest_Request_Interceptor::receive_request (
86 PortableInterceptor::ServerRequestInfo_ptr)
90 void
91 ForwardTest_Request_Interceptor::send_reply (
92 PortableInterceptor::ServerRequestInfo_ptr)
96 void
97 ForwardTest_Request_Interceptor::send_exception (
98 PortableInterceptor::ServerRequestInfo_ptr)
102 void
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 ();
115 bool
116 ForwardTest_Request_Interceptor::forward_location_done() const
118 return forward_location_done_;