Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / Bug_1495_Regression / server_interceptor.cpp
blob781480882a732143fbaebed5debf58859feda45f
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 ()
24 void
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 (
30 TAO::VMCID,
31 EINVAL),
32 CORBA::COMPLETED_NO);
33 this->forward_location_ = CORBA::Object::_duplicate (forward_location);
36 char *
37 Echo_Server_Request_Interceptor::name ()
39 return CORBA::string_dup (this->myname_);
42 void
43 Echo_Server_Request_Interceptor::destroy ()
47 void
48 Echo_Server_Request_Interceptor::receive_request_service_contexts (
49 PortableInterceptor::ServerRequestInfo_ptr ri)
51 CORBA::String_var operation = ri->operation ();
53 ACE_DEBUG ((LM_DEBUG,
54 "%C.receive_request_service_contexts from "
55 "\"%C\"\n",
56 this->myname_,
57 operation.in ()));
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)
65 return;
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 ());
75 void
76 Echo_Server_Request_Interceptor::receive_request (
77 PortableInterceptor::ServerRequestInfo_ptr)
79 // Do nothing
82 void
83 Echo_Server_Request_Interceptor::send_reply (
84 PortableInterceptor::ServerRequestInfo_ptr ri)
86 // No op
87 ACE_UNUSED_ARG (ri);
90 void
91 Echo_Server_Request_Interceptor::send_exception (
92 PortableInterceptor::ServerRequestInfo_ptr ri)
94 // No Op
95 ACE_UNUSED_ARG (ri);
98 void
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 ();
111 bool
112 Echo_Server_Request_Interceptor::forward_location_done() const
114 return forward_location_done_;