2 //=============================================================================
4 * @file Servant_Locator.cpp
6 * Implementation of MyFooServantLocator class , used with a POA
7 * having a NON_RETAIN policy.
9 * @author Irfan Pyarali Michael Kircher
11 //=============================================================================
14 #include "Servant_Locator.h"
15 #include "ace/Log_Msg.h"
17 #include "ace/OS_NS_string.h"
19 Servant_Locator::Servant_Locator (CORBA::ORB_ptr orb_ptr
)
20 : orb_var_ (CORBA::ORB::_duplicate (orb_ptr
))
24 Servant_Locator::~Servant_Locator ()
29 PortableServer::Servant
30 Servant_Locator::preinvoke (const PortableServer::ObjectId
&oid
,
31 PortableServer::POA_ptr
/* poa_ptr */,
32 const char * /*operation*/,
33 PortableServer::ServantLocator::Cookie
& /* cookie */)
36 CORBA::String_var s
= PortableServer::ObjectId_to_string (oid
);
39 "The OID is <%s>\n", s
.in ()));
40 if (ACE_OS::strstr (s
.in (), "Simple_Server") == 0)
42 throw CORBA::OBJECT_NOT_EXIST ();
46 Simple_Server_var server
=
47 Simple_Server::_narrow (this->objref_
.in ());
50 "Got the narrowed secondary server too...\n"));
53 "About to throw exception..\n"));
55 throw PortableServer::ForwardRequest (
56 CORBA::Object::_duplicate (
62 Servant_Locator::postinvoke (const PortableServer::ObjectId
&,
63 PortableServer::POA_ptr
,
65 PortableServer::ServantLocator::Cookie
,
66 PortableServer::Servant
)
71 Servant_Locator::set (CORBA::Object_var objref
)
73 this->objref_
= CORBA::Object::_duplicate (objref
.in ());