diff options
Diffstat (limited to 'TAO/tests/POA/On_Demand_Activation/Servant_Locator.cpp')
-rw-r--r-- | TAO/tests/POA/On_Demand_Activation/Servant_Locator.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/TAO/tests/POA/On_Demand_Activation/Servant_Locator.cpp b/TAO/tests/POA/On_Demand_Activation/Servant_Locator.cpp new file mode 100644 index 00000000000..6b5df82f885 --- /dev/null +++ b/TAO/tests/POA/On_Demand_Activation/Servant_Locator.cpp @@ -0,0 +1,43 @@ +#include "Servant_Locator.h" +#include "MyFooServant.h" + +MyFooServantLocator::MyFooServantLocator (void) + : counter_ (0) +{ +} + + +PortableServer::Servant +MyFooServantLocator::preinvoke (const PortableServer::ObjectId &oid, + PortableServer::POA_ptr poa, + const char *operation, + PortableServer::ServantLocator::Cookie &cookie, + CORBA::Environment &env) +{ + CORBA::String_var s = PortableServer::ObjectId_to_string (oid); + if (ACE_OS::strstr (s.in (), "Foo") != 0) + { + PortableServer::Servant servant = new MyFooServant (poa, ++this->counter_); + cookie = servant; + return servant; + } + else + { + CORBA::Exception *exception = new CORBA::OBJECT_NOT_EXIST (CORBA::COMPLETED_NO); + env.exception (exception); + return 0; + } +} + +void +MyFooServantLocator::postinvoke (const PortableServer::ObjectId &oid, + PortableServer::POA_ptr poa, + const char *operation, + PortableServer::ServantLocator::Cookie cookie, + PortableServer::Servant servant, + CORBA::Environment &env) +{ + PortableServer::Servant my_servant = (PortableServer::Servant) cookie; + ACE_ASSERT (servant == my_servant); + delete servant; +} |