Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / DII_AMI_Forward / server_interceptor.cpp
blob5a6df2d5af629ffbc108714768efa734cdd2071b
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 (void)
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 (void)
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 (void)
41 return CORBA::string_dup (this->myname_);
44 void
45 ForwardTest_Request_Interceptor::destroy (void)
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)
107 // This will throw an exception if a location forward has not
108 // occurred. If an exception is thrown then something is wrong with
109 // the PortableInterceptor::ForwardRequest support.
110 CORBA::Object_var forward = ri->forward_reference ();
112 if (CORBA::is_nil (forward.in ()))
113 throw CORBA::INTERNAL ();
116 bool
117 ForwardTest_Request_Interceptor::forward_location_done() const
119 return forward_location_done_;