summaryrefslogtreecommitdiff
path: root/TAO/tests/POA/Deactivate_Object/server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tests/POA/Deactivate_Object/server.cpp')
-rw-r--r--TAO/tests/POA/Deactivate_Object/server.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/TAO/tests/POA/Deactivate_Object/server.cpp b/TAO/tests/POA/Deactivate_Object/server.cpp
new file mode 100644
index 00000000000..9f33c3b6f10
--- /dev/null
+++ b/TAO/tests/POA/Deactivate_Object/server.cpp
@@ -0,0 +1,63 @@
+// $Id$
+
+#include "Hello.h"
+#include "ace/OS_NS_stdio.h"
+
+ACE_RCSID (Hello,
+ server,
+ "$Id$")
+
+int
+main (int argc, char *argv[])
+{
+ try
+ {
+ CORBA::ORB_var orb =
+ CORBA::ORB_init (argc, argv);
+
+ CORBA::Object_var poa_object =
+ orb->resolve_initial_references("RootPOA");
+
+ PortableServer::POA_var root_poa =
+ PortableServer::POA::_narrow (poa_object.in ());
+
+ if (CORBA::is_nil (root_poa.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Panic: nil RootPOA\n"),
+ 1);
+
+ PortableServer::POAManager_var poa_manager =
+ root_poa->the_POAManager ();
+
+ Hello *hello_impl = 0;
+ ACE_NEW_RETURN (hello_impl,
+ Hello (orb.in ()),
+ 1);
+
+ PortableServer::ServantBase_var owner_transfer(hello_impl);
+
+ poa_manager->activate ();
+
+ PortableServer::ObjectId_var obj_id = root_poa->activate_object (hello_impl);
+
+ CORBA::Object_var obj_var = root_poa->id_to_reference (obj_id.in ());
+
+ PortableServer::ObjectId_var new_obj_id = root_poa->reference_to_id (obj_var.in ());
+
+ // Invoke reference_to_servant(). Should retrieve servant.
+ PortableServer::ServantBase_var servant =
+ root_poa->reference_to_servant (obj_var.in ());
+
+ // Assert correctness.
+ ACE_ASSERT (hello_impl == servant.in());
+
+ root_poa->deactivate_object (new_obj_id.in ());
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Exception caught:");
+ return 1;
+ }
+
+ return 0;
+}