summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsumedh <sumedh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-01-30 20:27:14 +0000
committersumedh <sumedh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-01-30 20:27:14 +0000
commit1c09ebe77bef917ac8c496ec456a62f5c6a1bf9f (patch)
treeb1a00fc80fd1d1300a0f72d8ebfe8befcdcda7df
parent8a624687961501fb34719e24177a4d003e024c6a (diff)
downloadATCD-1c09ebe77bef917ac8c496ec456a62f5c6a1bf9f.tar.gz
Added util.cpp
-rw-r--r--TAO/orbsvcs/orbsvcs/util.cpp129
1 files changed, 129 insertions, 0 deletions
diff --git a/TAO/orbsvcs/orbsvcs/util.cpp b/TAO/orbsvcs/orbsvcs/util.cpp
new file mode 100644
index 00000000000..bf09a5dc0f6
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/util.cpp
@@ -0,0 +1,129 @@
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// cos
+//
+// = FILENAME
+// util.cpp
+//
+// = AUTHOR
+// Sumedh Mungee <sumedh@cs.wustl.edu>
+//
+//
+// ============================================================================
+
+#include "util.h"
+
+int
+TAO_ORB_Manager::init (int argc,
+ char **argv,
+ CORBA::Environment &env)
+{
+ this->orb_ = CORBA::ORB_init (argc,
+ argv,
+ 0,
+ env);
+ TAO_CHECK_ENV_RETURN (env, 1);
+
+ // Initialize the Object Adapter
+ CORBA::Object_var poa_object =
+ this->orb_->resolve_initial_references("RootPOA");
+ if (CORBA::is_nil(poa_object.in()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Unable to initialize the POA.\n"),
+ 1);
+
+ this->root_poa_ =
+ PortableServer::POA::_narrow (poa_object, env);
+
+ TAO_CHECK_ENV_RETURN (env, 1);
+
+ this->poa_manager_ =
+ this->root_poa_->the_POAManager (env);
+
+ TAO_CHECK_ENV_RETURN (env, 1);
+
+ PortableServer::PolicyList policies (2);
+ policies.length (2);
+ policies[0] =
+ this->root_poa_->create_id_assignment_policy (PortableServer::USER_ID,
+ env);
+ TAO_CHECK_ENV_RETURN (env, 1);
+
+ policies[1] =
+ this->root_poa_->create_lifespan_policy (PortableServer::PERSISTENT,
+ env);
+ TAO_CHECK_ENV_RETURN (env, 1);
+
+
+ // We use a different POA, otherwise the user would have to
+ // change the object key each time it invokes the server.
+
+ this->my_poa_ =
+ this->root_poa_->create_POA ("AVStreams_POA",
+ this->poa_manager_.in (),
+ policies,
+ env);
+ TAO_CHECK_ENV_RETURN (env, 1);
+ return 0;
+}
+
+CORBA::String_var
+TAO_ORB_Manager::activate (const char *object_name,
+ PortableServer::Servant servant,
+ CORBA_Environment &env)
+{
+
+ if (object_name == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "\n(%P|%t) TAO_ORB_Manager::register: "
+ "object_name is null!"),
+ 0);
+
+ PortableServer::ObjectId_var id =
+ PortableServer::string_to_ObjectId (object_name);
+
+ this->my_poa_->activate_object_with_id (id.in (),
+ servant,
+ env);
+ TAO_CHECK_ENV_RETURN (env, 0);
+
+ CORBA::Object_var obj =
+ this->my_poa_->id_to_reference (id.in (),
+ env);
+ TAO_CHECK_ENV_RETURN (env, 0);
+
+ CORBA::String_var str =
+ this->orb_->object_to_string (obj.in (),
+ env);
+
+ TAO_CHECK_ENV_RETURN (env, 0);
+
+ return str;
+}
+
+int
+TAO_ORB_Manager::run (CORBA::Environment &env)
+{
+ this->poa_manager_->activate (env);
+ TAO_CHECK_ENV_RETURN (env, 1);
+
+ if (this->orb_->run () == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "run"), -1);
+
+ this->root_poa_->destroy (CORBA::B_TRUE,
+ CORBA::B_TRUE,
+ env);
+ TAO_CHECK_ENV_RETURN (env, 1);
+}
+
+CORBA::ORB_var
+TAO_ORB_Manager::orb (void)
+{
+ return this->orb_;
+}
+