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 */)
35 CORBA::String_var s
= PortableServer::ObjectId_to_string (oid
);
38 "The OID is <%s>\n", s
.in ()));
39 if (ACE_OS::strstr (s
.in (), "Simple_Server") == 0)
41 throw CORBA::OBJECT_NOT_EXIST ();
45 Simple_Server_var server
=
46 Simple_Server::_narrow (this->objref_
.in ());
49 "Got the narrowed secondary server too...\n"));
52 "About to throw exception..\n"));
54 throw PortableServer::ForwardRequest (
55 CORBA::Object::_duplicate (
60 Servant_Locator::postinvoke (const PortableServer::ObjectId
&,
61 PortableServer::POA_ptr
,
63 PortableServer::ServantLocator::Cookie
,
64 PortableServer::Servant
)
69 Servant_Locator::set (CORBA::Object_var objref
)
71 this->objref_
= CORBA::Object::_duplicate (objref
.in ());