summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-01-23 20:34:46 +0000
committercoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-01-23 20:34:46 +0000
commit36609d06bb7c4f26141bcafae4f013db04ab2e9a (patch)
treec03cd68d9659f82d129a44f963ef0c662dbda712
parentfb27a611b4aec80e588b990daf14728ed660ed38 (diff)
downloadATCD-36609d06bb7c4f26141bcafae4f013db04ab2e9a.tar.gz
ChangeLogTag:Fri Jan 23 14:30:19 1998 Carlos O'Ryan <coryan@cs.wustl.edu>
-rw-r--r--TAO/ChangeLog-98c17
-rw-r--r--TAO/tao/poa.cpp22
-rw-r--r--TAO/tao/poa.h14
-rw-r--r--TAO/tao/servant_base.cpp7
-rw-r--r--TAO/tests/Cubit/TAO/IDL_Cubit/Makefile6
-rw-r--r--TAO/tests/Cubit/TAO/IDL_Cubit/clnt.cpp143
-rw-r--r--TAO/tests/Cubit/TAO/IDL_Cubit/clnt.h15
-rw-r--r--TAO/tests/Cubit/TAO/IDL_Cubit/cubit_i.cpp50
-rw-r--r--TAO/tests/Cubit/TAO/IDL_Cubit/cubit_i.h5
-rw-r--r--TAO/tests/Cubit/TAO/IDL_Cubit/svr.cpp159
10 files changed, 216 insertions, 222 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c
index 36bd744172a..130c1d45f17 100644
--- a/TAO/ChangeLog-98c
+++ b/TAO/ChangeLog-98c
@@ -1,3 +1,20 @@
+Fri Jan 23 14:30:19 1998 Carlos O'Ryan <coryan@cs.wustl.edu>
+
+ * tao/poa.h:
+ * tao/poa.cpp:
+ * tao/servant_base.cpp:
+ _this() was using the object id for the current servant in *all*
+ objects, now it only does so for the servant invoked.
+
+ * tests/Cubit/TAO/IDL_Cubit/Makefile:
+ * tests/Cubit/TAO/IDL_Cubit/clnt.cpp:
+ * tests/Cubit/TAO/IDL_Cubit/clnt.h:
+ * tests/Cubit/TAO/IDL_Cubit/cubit_i.cpp:
+ * tests/Cubit/TAO/IDL_Cubit/cubit_i.h:
+ * tests/Cubit/TAO/IDL_Cubit/svr.cpp:
+ Ported the Cubit test to POA, including some funky persistent
+ policies to simplify its use.
+
Sat Jan 24 01:24:24 1998 Irfan Pyarali <irfan@cs.wustl.edu>
* tao/poa.cpp (destroy_i): Changed etherealize objects to correct
diff --git a/TAO/tao/poa.cpp b/TAO/tao/poa.cpp
index 2bcfeea8bdc..f259109eef6 100644
--- a/TAO/tao/poa.cpp
+++ b/TAO/tao/poa.cpp
@@ -2181,6 +2181,7 @@ TAO_POA::dispatch_servant_i (const TAO::ObjectKey &key,
// Setup for upcall
poa->pre_invoke (key,
id.in (),
+ servant,
env);
servant->_dispatch (req,
@@ -2196,6 +2197,7 @@ TAO_POA::dispatch_servant_i (const TAO::ObjectKey &key,
void
TAO_POA::pre_invoke (const TAO::ObjectKey &key,
const PortableServer::ObjectId &id,
+ PortableServer::Servant servant,
CORBA::Environment &env)
{
ACE_UNUSED_ARG (env);
@@ -2206,7 +2208,7 @@ TAO_POA::pre_invoke (const TAO::ObjectKey &key,
poa_current->POA_impl (this);
poa_current->object_key (key);
poa_current->object_id (id);
- poa_current->in_upcall (1);
+ poa_current->servant (servant);
}
void
@@ -3178,7 +3180,7 @@ TAO_Strategy_POA_Manager::lock (void)
TAO_POA_Current::TAO_POA_Current (void)
: poa_impl_ (0),
object_id_ (0),
- in_upcall_ (0),
+ servant_ (0),
object_key_ (0),
cookie_ (0)
{
@@ -3224,7 +3226,7 @@ TAO_POA_Current::clear (void)
{
this->poa_impl_ = 0;
this->object_id_ = 0;
- this->in_upcall_ = 0;
+ this->servant_ = 0;
this->object_key_ = 0;
this->cookie_ = 0;
}
@@ -3235,7 +3237,7 @@ TAO_POA_Current::context_is_valid (void)
return
this->poa_impl_ != 0 &&
this->object_id_ != 0 &&
- this->in_upcall_ != 0 &&
+ this->servant_ != 0 &&
this->object_key_ != 0;
}
@@ -3276,15 +3278,21 @@ TAO_POA_Current::object_key (void) const
}
void
-TAO_POA_Current::in_upcall (int yesno)
+TAO_POA_Current::servant (PortableServer::Servant servant)
{
- this->in_upcall_ = yesno;
+ this->servant_ = servant;
+}
+
+PortableServer::Servant
+TAO_POA_Current::servant (void) const
+{
+ return this->servant_;
}
int
TAO_POA_Current::in_upcall (void) const
{
- return this->in_upcall_;
+ return (this->servant_ != 0);
}
PortableServer::ServantLocator::Cookie
diff --git a/TAO/tao/poa.h b/TAO/tao/poa.h
index f5b08c94d19..bdf83788ddd 100644
--- a/TAO/tao/poa.h
+++ b/TAO/tao/poa.h
@@ -486,6 +486,7 @@ protected:
virtual void pre_invoke (const TAO::ObjectKey &key,
const PortableServer::ObjectId &id,
+ PortableServer::Servant servant,
CORBA::Environment &env);
virtual void post_invoke (PortableServer::Servant servant,
@@ -738,8 +739,11 @@ public:
virtual const TAO::ObjectKey &object_key (void) const;
// Get the object key.
- virtual void in_upcall (int yesno);
- // Set whether we're in an upcall (non-zero is yes).
+ virtual void servant (PortableServer::Servant servant);
+ // Set the servant for the current upcall.
+
+ virtual PortableServer::Servant servant (void) const;
+ // Get the servant for the current upcall.
virtual int in_upcall (void) const;
// Get whether we're in an upcall (non-zero is yes).
@@ -763,15 +767,15 @@ private:
const PortableServer::ObjectId *object_id_;
// The object ID of the current context.
- int in_upcall_;
- // Flag which indicates whether we're in an upcall.
-
const TAO::ObjectKey *object_key_;
// The object key of the current context.
PortableServer::ServantLocator::Cookie cookie_;
// Servant Locator's cookie
+ PortableServer::Servant servant_;
+ // The servant for the current upcall.
+
// = Hidden because we don't allow these
TAO_POA_Current (const TAO_POA_Current &);
void operator= (const TAO_POA_Current &);
diff --git a/TAO/tao/servant_base.cpp b/TAO/tao/servant_base.cpp
index b70894d06ef..f7f197b51b6 100644
--- a/TAO/tao/servant_base.cpp
+++ b/TAO/tao/servant_base.cpp
@@ -1,3 +1,6 @@
+//
+// $Id$
+//
#include "tao/corba.h"
TAO_ServantBase::TAO_ServantBase (void)
@@ -95,7 +98,7 @@ TAO_ServantBase::_create_stub (CORBA_Environment &env)
TAO_ORB_Core *orb_core = TAO_ORB_Core_instance ();
TAO_POA_Current *poa_current = orb_core->poa_current ();
- if (poa_current->in_upcall ())
+ if (poa_current->in_upcall () && this == poa_current->servant ())
{
stub = new IIOP_Object (CORBA::string_copy (this->_interface_repository_id ()),
IIOP::Profile (orb_core->orb_params ()->addr (),
@@ -169,7 +172,7 @@ TAO_DynamicImplementation::_create_stub (CORBA::Environment &env)
// exception.
TAO_ORB_Core *orb_core = TAO_ORB_Core_instance ();
TAO_POA_Current *poa_current = orb_core->poa_current ();
- if (!poa_current->in_upcall ())
+ if (!poa_current->in_upcall () || this != poa_current->servant ())
{
CORBA::Exception *exception = new PortableServer::POA::WrongPolicy;
env.exception (exception);
diff --git a/TAO/tests/Cubit/TAO/IDL_Cubit/Makefile b/TAO/tests/Cubit/TAO/IDL_Cubit/Makefile
index e77e4f8b56a..396b2f46575 100644
--- a/TAO/tests/Cubit/TAO/IDL_Cubit/Makefile
+++ b/TAO/tests/Cubit/TAO/IDL_Cubit/Makefile
@@ -17,7 +17,7 @@ PROG_SRCS = $(IDL_SRC) svr.cpp clnt.cpp tmplinst.cpp
LSRC = $(PROG_SRCS)
CUBIT_SVR_OBJS = cubitC.o cubitS.o svr.o cubit_i.o tmplinst.o
-CUBIT_CLT_OBJS = cubitC.o clnt.o tmplinst.o
+CUBIT_CLT_OBJS = cubitC.o cubitS.o clnt.o tmplinst.o
BIN = svr clnt
BUILD = $(BIN)
@@ -76,8 +76,8 @@ check: $(TESTS)
@./clnt -n250 -O `cat obj.5` -x
@echo ''
-clean:
- -/bin/rm -rf *.o Log $(BIN) obj.* core Templates.DB .make.state
+#clean:
+# -/bin/rm -rf *.o Log $(BIN) obj.* core Templates.DB .make.state
realclean: clean
-/bin/rm -rf cubitC.* cubitS.*
diff --git a/TAO/tests/Cubit/TAO/IDL_Cubit/clnt.cpp b/TAO/tests/Cubit/TAO/IDL_Cubit/clnt.cpp
index d96f6d8740e..fdec90f5a97 100644
--- a/TAO/tests/Cubit/TAO/IDL_Cubit/clnt.cpp
+++ b/TAO/tests/Cubit/TAO/IDL_Cubit/clnt.cpp
@@ -28,21 +28,14 @@
#define quote(x) #x
Cubit_Client::Cubit_Client (void)
- : cubit_factory_key_ ("factory"),
+ : cubit_factory_key_ (0),
cubit_key_ ("key0"),
- hostname_ (ACE_DEFAULT_SERVER_HOST),
loop_count_ (250),
exit_later_ (0),
- factory_ (Cubit_Factory::_nil ()),
- objref_ (CORBA::Object::_nil ()),
cubit_ (Cubit::_nil ()),
- orb_ptr_ (0),
call_count_ (0),
error_count_ (0)
{
- ACE_Env_Value<CORBA::UShort> defport(quote(TAO_DEFAULT_SERVER_PORT),
- TAO_DEFAULT_SERVER_PORT);
- portnum_ = defport;
}
// Simple function that returns the substraction of 117 from the
@@ -59,7 +52,7 @@ Cubit_Client::func (u_int i)
int
Cubit_Client::parse_args (void)
{
- ACE_Get_Opt get_opts (argc_, argv_, "dn:h:p:k:x");
+ ACE_Get_Opt get_opts (argc_, argv_, "dn:f:k:x");
int c;
while ((c = get_opts ()) != -1)
@@ -71,13 +64,10 @@ Cubit_Client::parse_args (void)
case 'n': // loop count
loop_count_ = (u_int) ACE_OS::atoi (get_opts.optarg);
break;
- case 'h':
- hostname_ = ACE_OS::strdup (get_opts.optarg);
- break;
- case 'p':
- portnum_ = ACE_OS::atoi (get_opts.optarg);
- break;
- case 'k': // stringified objref
+ case 'f':
+ cubit_factory_key_ = ACE_OS::strdup (get_opts.optarg);
+ break;
+ case 'k':
cubit_key_ = ACE_OS::strdup (get_opts.optarg);
break;
case 'x':
@@ -89,9 +79,8 @@ Cubit_Client::parse_args (void)
"usage: %s"
" [-d]"
" [-n loopcount]"
+ " [-f cubit_factory-obj-ref-key]"
" [-k cubit-obj-ref-key]"
- " [-h hostname]"
- " [-p port]"
" [-x]"
"\n",
this->argv_ [0]),
@@ -670,10 +659,12 @@ Cubit_Client::run (void)
Cubit_Client::~Cubit_Client (void)
{
// Free resources
- CORBA::release (this->orb_ptr_);
- CORBA::release (this->objref_);
- CORBA::release (this->factory_);
CORBA::release (this->cubit_);
+
+ if (this->cubit_factory_key_ != 0)
+ ACE_OS::free (this->cubit_factory_key_);
+ if (this->cubit_key_ != 0)
+ ACE_OS::free (this->cubit_key_);
}
int
@@ -682,76 +673,62 @@ Cubit_Client::init (int argc, char **argv)
this->argc_ = argc;
this->argv_ = argv;
- // Retrieve the ORB.
- this->orb_ptr_ = CORBA::ORB_init (this->argc_,
- this->argv_,
- "internet",
- this->env_);
+ TAO_TRY
+ {
+ // Retrieve the ORB.
+ this->orb_ = CORBA::ORB_init (this->argc_,
+ this->argv_,
+ "internet",
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
- // Parse command line and verify parameters.
- if (this->parse_args () == -1)
- return -1;
+ // Parse command line and verify parameters.
+ if (this->parse_args () == -1)
+ return -1;
- if (this->env_.exception () != 0)
- {
- this->env_.print_exception ("ORB initialization");
- return -1;
- }
+ if (this->cubit_factory_key_ == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%s: no cubit factory key specified\n",
+ this->argv_[0]),
+ -1);
- if (this->cubit_key_ == 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "%s: must specify an object reference using -k <key>\n",
- this->argv_[0]),
- -1);
- // Retrieve a factory objref.
- this->objref_ = Cubit_Factory::_bind (this->hostname_,
- this->portnum_,
- this->cubit_factory_key_,
- this->env_);
+ CORBA::Object_var factory_object =
+ this->orb_->string_to_object (this->cubit_factory_key_,
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
- if (this->env_.exception () != 0)
- {
- this->env_.print_exception ("Cubit_Factory::_bind");
- return -1;
- }
+ this->factory_ =
+ Cubit_Factory::_narrow (factory_object, TAO_TRY_ENV);
+ TAO_CHECK_ENV;
- if (CORBA::is_nil (this->objref_) == CORBA::B_TRUE)
- ACE_ERROR_RETURN ((LM_ERROR,
- " _bind returned null object for key (%s), host (%s), port (%d)\n",
- this->cubit_factory_key_,
- this->hostname_,
- this->portnum_),
- -1);
-
- // Narrow the CORBA::Object reference to the stub object, checking
- // the type along the way using _is_a. There is really no need to
- // narrow <objref> because <_bind> will return us the
- // <Cubit_Factory> pointer. However, we do it so that we can
- // explicitly test the _narrow function.
- this->factory_ = Cubit_Factory::_narrow (this->objref_, this->env_);
- //CORBA::release (this->objref_);
- this->objref_->Release ();
-
- if (this->factory_ == 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- " (%P|%t) Unable to narrow object reference to a Cubit_Factory_ptr.\n"),
- -1);
-
- // Now retrieve the Cubit obj ref corresponding to the key.
- this->cubit_ =
- this->factory_->make_cubit (this->cubit_key_, this->env_);
+ if (CORBA::is_nil (this->factory_.in ()))
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "invalid factory key <%s>\n",
+ this->cubit_factory_key_),
+ -1);
+ }
- if (this->env_.exception () != 0)
+ ACE_DEBUG ((LM_DEBUG, "Factory received OK\n"));
+
+ // Now retrieve the Cubit obj ref corresponding to the key.
+ this->cubit_ =
+ this->factory_->make_cubit (this->cubit_key_,
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ if (CORBA::is_nil (this->cubit_))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "null cubit objref returned by factory\n"),
+ -1);
+ }
+ TAO_CATCHANY
{
- this->env_.print_exception ("string2object");
+ TAO_TRY_ENV.print_exception ("Cubit::init");
return -1;
}
-
- if (CORBA::is_nil (this->cubit_))
- ACE_ERROR_RETURN ((LM_ERROR,
- "null cubit objref returned by factory\n"),
- -1);
+ TAO_ENDTRY;
return 0;
}
@@ -765,8 +742,8 @@ main (int argc, char **argv)
if (cubit_client.init (argc, argv) == -1)
return 1;
- else
- return cubit_client.run ();
+
+ return cubit_client.run ();
}
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
diff --git a/TAO/tests/Cubit/TAO/IDL_Cubit/clnt.h b/TAO/tests/Cubit/TAO/IDL_Cubit/clnt.h
index 8c7c5ee3f8a..2ba3f7e50b8 100644
--- a/TAO/tests/Cubit/TAO/IDL_Cubit/clnt.h
+++ b/TAO/tests/Cubit/TAO/IDL_Cubit/clnt.h
@@ -85,37 +85,28 @@ private:
char **argv_;
// arguments from command line.
- const char *cubit_factory_key_;
+ char *cubit_factory_key_;
// Key of factory obj ref.
char *cubit_key_;
// Key of the obj ref to be retrieved via the factory.
- char *hostname_;
- // Hostname of server.
-
- CORBA::UShort portnum_;
- // default port number of server.
-
u_int loop_count_;
// Number of times to do the cube operations.
int exit_later_;
// Flag to tell server to not exit immediately
- Cubit_Factory_ptr factory_;
+ Cubit_Factory_var factory_;
// factory pointer for cubit.
- CORBA::Object_ptr objref_;
- // storage of the factory objref
-
CORBA::Environment env_;
// Environment variable
Cubit_ptr cubit_;
// Cubit obj ref
- CORBA::ORB_ptr orb_ptr_;
+ CORBA::ORB_var orb_;
// Remember our orb
u_int call_count_;
diff --git a/TAO/tests/Cubit/TAO/IDL_Cubit/cubit_i.cpp b/TAO/tests/Cubit/TAO/IDL_Cubit/cubit_i.cpp
index 82150eb7db9..5092f41b31e 100644
--- a/TAO/tests/Cubit/TAO/IDL_Cubit/cubit_i.cpp
+++ b/TAO/tests/Cubit/TAO/IDL_Cubit/cubit_i.cpp
@@ -19,66 +19,26 @@
// Constructor
-Cubit_Factory_i::Cubit_Factory_i (const char *key, int numobjs)
- : POA_Cubit_Factory (key)
+Cubit_Factory_i::Cubit_Factory_i (void)
{
- // Create implementation object with user specified key.
-
- this->numobjs_ = numobjs;
- this->my_cubit_ = new Cubit_i_ptr [this->numobjs_];
-
- static char obj_str [MAXNAMELEN];
-
- for (u_int i = 0; i < this->numobjs_; i++)
- {
- ACE_OS::memset (obj_str, '\0', MAXNAMELEN);
- ACE_OS::sprintf (obj_str, "key%d", i);
-
- my_cubit_[i] = new Cubit_i (obj_str);
-
- if (my_cubit_[i] == 0)
- ACE_ERROR ((LM_ERROR,
- " (%P|%t) Unable to create implementation object%d\n",
- i));
-
- }
}
// Destructor
Cubit_Factory_i::~Cubit_Factory_i (void)
{
- delete [] this->my_cubit_;
}
Cubit_ptr
-Cubit_Factory_i::make_cubit (const char *key, CORBA::Environment &env)
+Cubit_Factory_i::make_cubit (const char *,
+ CORBA::Environment &env)
{
- for (size_t i = 0; i < this->numobjs_; i++)
- {
- Cubit_ptr cubit = this->my_cubit_[i]->_this (env);
- if (env.exception () != 0)
- {
- env.print_exception ("my_cubit::_this");
- return Cubit::_nil ();
- }
- auto_ptr<TAO::ObjectKey> the_key = cubit->key (env);
-
- const char *obj_str = (char *) &((*the_key)[0]);
-
- // Keys matched.
- if (ACE_OS::memcmp (obj_str, key, the_key->length()) == 0)
- return cubit;
- CORBA::release (cubit);
- }
-
- return Cubit::_nil ();
+ return my_cubit_._this (env);
}
// Constructor
-Cubit_i::Cubit_i (const char *obj_name)
- : POA_Cubit (obj_name)
+Cubit_i::Cubit_i (const char *)
{
}
diff --git a/TAO/tests/Cubit/TAO/IDL_Cubit/cubit_i.h b/TAO/tests/Cubit/TAO/IDL_Cubit/cubit_i.h
index c62db28337b..800283c268e 100644
--- a/TAO/tests/Cubit/TAO/IDL_Cubit/cubit_i.h
+++ b/TAO/tests/Cubit/TAO/IDL_Cubit/cubit_i.h
@@ -82,7 +82,7 @@ class Cubit_Factory_i: public POA_Cubit_Factory
// factory object returning the cubit objrefs
{
public:
- Cubit_Factory_i (const char *key, int numobjs);
+ Cubit_Factory_i (void);
// constructor
~Cubit_Factory_i (void);
@@ -92,8 +92,7 @@ public:
// make the cubit object whose key is "key"
private:
- Cubit_i_ptr *my_cubit_;
- u_int numobjs_;
+ Cubit_i my_cubit_;
};
#endif /* _CUBIT_I_HH */
diff --git a/TAO/tests/Cubit/TAO/IDL_Cubit/svr.cpp b/TAO/tests/Cubit/TAO/IDL_Cubit/svr.cpp
index 2f19d127f31..5563ff69fea 100644
--- a/TAO/tests/Cubit/TAO/IDL_Cubit/svr.cpp
+++ b/TAO/tests/Cubit/TAO/IDL_Cubit/svr.cpp
@@ -55,72 +55,107 @@ parse_args (int argc, char *argv[])
int
main (int argc, char *argv[])
{
- CORBA::Environment env;
- char *orb_name = "internet";
-
- CORBA::ORB_ptr orb_ptr = CORBA::ORB_init (argc, argv, orb_name, env);
-
- if (env.exception () != 0)
+ TAO_TRY
{
- env.print_exception ("ORB init");
- return 1;
+ CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, 0, TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ // Initialize the Object Adapter
+ CORBA::Object_var poa_object =
+ orb->resolve_initial_references("RootPOA");
+ if (poa_object == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Unable to initialize the POA.\n"),
+ 1);
+
+ PortableServer::POA_var root_poa =
+ PortableServer::POA::_narrow (poa_object, TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ PortableServer::POAManager_var poa_manager =
+ root_poa->the_POAManager (TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ PortableServer::PolicyList policies (2);
+ policies.length (2);
+ policies[0] =
+ root_poa->create_id_assignment_policy (PortableServer::USER_ID,
+ TAO_TRY_ENV);
+ policies[1] =
+ root_poa->create_lifespan_policy (PortableServer::PERSISTENT,
+ TAO_TRY_ENV);
+
+ // We use a different POA, otherwise the user would have to
+ // change the object key each time it invokes the server.
+ PortableServer::POA_var good_poa =
+ root_poa->create_POA ("RootPOA_is_BAD",
+ poa_manager.in (),
+ policies,
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ // Parse remaining command line and verify parameters.
+ parse_args (argc, argv);
+
+ // create a factory implementation
+ Cubit_Factory_i factory_impl;
+
+ PortableServer::ObjectId_var id =
+ PortableServer::string_to_ObjectId ("factory");
+ good_poa->activate_object_with_id (id.in (),
+ &factory_impl,
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ if (TAO_debug_level > 0)
+ {
+#if 1
+ CORBA::Object_var obj =
+ good_poa->id_to_reference (id.in (), TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ CORBA::String_var str =
+ orb->object_to_string (obj.in (),
+ TAO_TRY_ENV);
+
+#else
+ Cubit_Factory_var factory =
+ factory_impl._this (TAO_TRY_ENV);
+
+ CORBA::String_var str =
+ orb->object_to_string (factory.in (),
+ TAO_TRY_ENV);
+
+#endif
+
+ ACE_DEBUG ((LM_DEBUG,
+ "The IOR is: <%s>\n", str.in ()));
+ }
+
+ poa_manager->activate (TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ // Handle requests for this object until we're killed, or one of
+ // the methods asks us to exit.
+ if (orb->run () == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "run"), -1);
+
+ root_poa->destroy (CORBA::B_TRUE,
+ CORBA::B_TRUE,
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV
}
-
- // Initialize the Object Adapter
- CORBA::POA_ptr oa_ptr = orb_ptr->POA_init (argc, argv, "POA");
-
- if (oa_ptr == 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- " (%P|%t) Unable to initialize the POA.\n"),
- 1);
-
- // Parse remaining command line and verify parameters.
- parse_args (argc, argv);
-
- // create a factory implementation
- POA_Cubit_Factory_ptr factory;
-
- ACE_NEW_RETURN (factory, Cubit_Factory_i ("factory", num_of_objs), 1);
-
- if (TAO_debug_level > 0)
+ TAO_CATCH (CORBA::SystemException, sysex)
{
- CORBA::Object_ptr obj = factory->_this (env);
- if (env.exception () != 0)
- {
- env.print_exception ("factor::_this");
- return 1;
- }
-
- // Stringify the objref we'll be implementing, and print it to
- // stdout. Someone will take that string and give it to a
- // client. Then release the object.
-
- CORBA::String str =
- orb_ptr->object_to_string (obj, env);
- CORBA::release (obj);
-
- if (env.exception () != 0)
- {
- env.print_exception ("object2string");
- return 1;
- }
-
- ACE_OS::puts ((char *) str);
- ACE_OS::fflush (stdout);
-
- CORBA::release (obj);
- //dmsg1 ("Object Created at: '%ul'", obj);
- dmsg1 ("listening as object '%s'", str);
+ TAO_TRY_ENV.print_exception ("System Exception");
+ return -1;
}
-
- // Handle requests for this object until we're killed, or one of the
- // methods asks us to exit.
- if (orb_ptr->run () == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "run"), -1);
-
- // Free resources
- CORBA::release (oa_ptr);
- CORBA::release (orb_ptr);
+ TAO_CATCH (CORBA::UserException, userex)
+ {
+ TAO_TRY_ENV.print_exception ("User Exception");
+ return -1;
+ }
+ TAO_ENDTRY;
return 0;
}