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 Echo_Server_Request_Interceptor::Echo_Server_Request_Interceptor ()
9 : myname_ ("Echo_Server_Interceptor")
13 Echo_Server_Request_Interceptor::Echo_Server_Request_Interceptor (CORBA::Object_ptr forward_location
)
14 : myname_ ("Echo_Server_Interceptor"),
15 forward_location_ (CORBA::Object::_duplicate (forward_location
)),
16 forward_location_done_ (false)
20 Echo_Server_Request_Interceptor::~Echo_Server_Request_Interceptor ()
25 Echo_Server_Request_Interceptor::forward_reference (CORBA::Object_ptr forward_location
)
27 if (CORBA::is_nil (forward_location
))
28 throw CORBA::INV_OBJREF (
29 CORBA::SystemException::_tao_minor_code (
33 this->forward_location_
= CORBA::Object::_duplicate (forward_location
);
37 Echo_Server_Request_Interceptor::name ()
39 return CORBA::string_dup (this->myname_
);
43 Echo_Server_Request_Interceptor::destroy ()
48 Echo_Server_Request_Interceptor::receive_request_service_contexts (
49 PortableInterceptor::ServerRequestInfo_ptr ri
)
51 CORBA::String_var operation
= ri
->operation ();
54 "%C.receive_request_service_contexts from "
59 // Ignore the "_is_a" operation since it may have been invoked
60 // locally on the server side as a side effect of another call,
61 // meaning that the client hasn't added the service context yet.
62 // Same goes for the shutdown call
63 if (ACE_OS::strcmp ("_is_a", operation
.in ()) == 0 ||
64 ACE_OS::strcmp ("shutdown", operation
.in ()) == 0)
67 forward_location_done_
= true;
69 ACE_DEBUG ((LM_DEBUG
, "Sending LOCATION_FORWARD, current thread %i\n", ACE_Thread::self ()));
71 throw PortableInterceptor::ForwardRequest (this->forward_location_
.in ());
76 Echo_Server_Request_Interceptor::receive_request (
77 PortableInterceptor::ServerRequestInfo_ptr
)
83 Echo_Server_Request_Interceptor::send_reply (
84 PortableInterceptor::ServerRequestInfo_ptr ri
)
91 Echo_Server_Request_Interceptor::send_exception (
92 PortableInterceptor::ServerRequestInfo_ptr ri
)
99 Echo_Server_Request_Interceptor::send_other (
100 PortableInterceptor::ServerRequestInfo_ptr ri
)
102 // This will throw an exception if a location forward has not
103 // occurred. If an exception is thrown then something is wrong with
104 // the PortableInterceptor::ForwardRequest support.
105 CORBA::Object_var forward
= ri
->forward_reference ();
107 if (CORBA::is_nil (forward
.in ()))
108 throw CORBA::INTERNAL ();
112 Echo_Server_Request_Interceptor::forward_location_done() const
114 return forward_location_done_
;