summaryrefslogtreecommitdiff
path: root/TAO/examples/POA/Forwarding/server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/examples/POA/Forwarding/server.cpp')
-rw-r--r--TAO/examples/POA/Forwarding/server.cpp664
1 files changed, 334 insertions, 330 deletions
diff --git a/TAO/examples/POA/Forwarding/server.cpp b/TAO/examples/POA/Forwarding/server.cpp
index a41632a6d13..3a638d4d73c 100644
--- a/TAO/examples/POA/Forwarding/server.cpp
+++ b/TAO/examples/POA/Forwarding/server.cpp
@@ -38,12 +38,11 @@ read_ior (char *filename,
{
// Open the file for reading.
ACE_HANDLE f_handle_ = ACE_OS::open (filename,0);
-
+
if (f_handle_ == ACE_INVALID_HANDLE)
ACE_ERROR_RETURN ((LM_ERROR,
"Unable to open %s for writing: %p\n",
- filename,
- "ACE_OS::open"),
+ filename),
-1);
ACE_Read_Buffer ior_buffer (f_handle_);
@@ -54,9 +53,8 @@ read_ior (char *filename,
if (first_foo_forward_to_IOR_ == 0)
ACE_ERROR_RETURN ((LM_ERROR,
- "Unable to allocate memory to read ior: %p\n",
- "ACE_Read_Buffer::read"),
- -1);
+ "Unable to allocate memory to read ior: %p\n"),
+ -1);
}
else if (foo_number == 2)
{
@@ -64,19 +62,18 @@ read_ior (char *filename,
if (second_foo_forward_to_IOR_ == 0)
ACE_ERROR_RETURN ((LM_ERROR,
- "Unable to allocate memory to read ior: %p\n",
- "ACE_Read_Buffer::read"),
+ "Unable to allocate memory to read ior: %p\n"),
-1);
}
-
+
if (foo_number == 1)
ACE_DEBUG ((LM_DEBUG,
"POA approach: Read ior: %s\n",
- first_foo_forward_to_IOR_));
+ first_foo_forward_to_IOR_));
else if (foo_number == 2)
ACE_DEBUG ((LM_DEBUG,
"Locator approach: Read ior: %s\n",
- second_foo_forward_to_IOR_));
+ second_foo_forward_to_IOR_));
return 0;
}
@@ -86,8 +83,8 @@ parse_args (int argc, char **argv)
{
ACE_Get_Opt get_opts (argc, argv, "f:g:k:l:o:O:p:");
int c;
- int result;
-
+ int result;
+
while ((c = get_opts ()) != -1)
switch (c)
{
@@ -96,8 +93,7 @@ parse_args (int argc, char **argv)
if (result < 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Unable to read ior from %s : %p\n",
- get_opts.optarg,
- "read_ior"),
+ get_opts.optarg),
-1);
break;
case 'g': // read the IOR from the file.
@@ -105,8 +101,7 @@ parse_args (int argc, char **argv)
if (result < 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Unable to read ior from %s : %p\n",
- get_opts.optarg,
- "read_ior"),
+ get_opts.optarg),
-1);
break;
case 'k':
@@ -120,22 +115,18 @@ parse_args (int argc, char **argv)
if (first_foo_ior_output_file_ == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Unable to open %s for writing: %p\n",
- get_opts.optarg,
- "ACE_OS::fopen"),
- -1);
- break;
+ get_opts.optarg), -1);
+ break;
case 'p': // output the IOR to a file.
second_foo_ior_output_file_ = ACE_OS::fopen (get_opts.optarg, "w");
if (second_foo_ior_output_file_ == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Unable to open %s for writing: %p\n",
- get_opts.optarg,
- "ACE_OS::fopen"),
- -1);
- break;
- case 'O':
+ get_opts.optarg), -1);
+ break;
+ case 'O':
break;
- case '?':
+ case '?':
default:
ACE_ERROR_RETURN ((LM_ERROR,
"\nusage: %s \n"
@@ -149,22 +140,27 @@ parse_args (int argc, char **argv)
argv [0]),
-1);
}
-
+
// Indicates successful parsing of command line.
return 0;
}
-static void
+static void
get_forward_reference (char *IOR,
CORBA::Object_var &forward_location_var,
CORBA::ORB_ptr orb_ptr,
- CORBA::Environment &ACE_TRY_ENV)
+ CORBA::Environment &env)
{
if (IOR != 0)
{
- forward_location_var = orb_ptr->string_to_object (IOR, ACE_TRY_ENV);
- ACE_CHECK;
-
+ forward_location_var = orb_ptr->string_to_object (IOR, env);
+
+ if (env.exception () != 0)
+ {
+ env.print_exception ("ORB::string_to_object");
+ return;
+ }
+
if (CORBA::is_nil (forward_location_var.in ()))
ACE_DEBUG ((LM_DEBUG,
"Error: Forward_to location is wrong\n"));
@@ -176,55 +172,47 @@ get_forward_reference (char *IOR,
// use the POA directly to do forwarding
int setup_first_poa (PortableServer::POA_ptr root_poa_ptr,
- PortableServer::POAManager_ptr poa_manager_ptr,
+ PortableServer::POAManager_ptr poa_manager_ptr,
PortableServer::POA_var &first_poa_var)
{
- //CORBA::Environment env;
-
-
+ CORBA::Environment env;
// Policies for the childPOA to be created.
- CORBA::PolicyList policies (2);
+ CORBA::PolicyList policies (2);
policies.length (2);
- char str[256];
- ACE_DECLARE_NEW_CORBA_ENV;
- ACE_TRY
+ // The next two policies are common to both
+
+ // Id Assignment Policy
+ policies[0] = root_poa_ptr->create_id_assignment_policy (PortableServer::USER_ID, env);
+ if (env.exception () != 0)
{
- // The next two policies are common to both
-
- ACE_OS::strcpy (str, "PortableServer::POA::create_id_assignment_policy");
- // Id Assignment Policy
- policies[0] = root_poa_ptr->create_id_assignment_policy (PortableServer::USER_ID,
- ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- ACE_OS::strcpy (str, "PortableServer::POA::create_lifespan_policy");
- // Lifespan policy
- policies[1] = root_poa_ptr->create_lifespan_policy (PortableServer::PERSISTENT,
- ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- ACE_CString name = "firstPOA";
-
- ACE_OS::strcpy (str, "PortableServer::POA::create_POA");
-
- // Create firstPOA as the child of RootPOA with the above policies
- // firstPOA will use SERVANT_ACTIVATOR because of RETAIN policy.
- first_poa_var = root_poa_ptr->create_POA (name.c_str (),
- poa_manager_ptr,
- policies,
- ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
+ env.print_exception ("PortableServer::POA::create_id_assignment_policy");
+ return -1;
+ }
+
+ // Lifespan policy
+ policies[1] = root_poa_ptr->create_lifespan_policy (PortableServer::PERSISTENT, env);
+ if (env.exception () != 0)
+ {
+ env.print_exception ("PortableServer::POA::create_lifespan_policy");
+ return -1;
}
- ACE_CATCHANY
+
+
+ ACE_CString name = "firstPOA";
+
+ // Create firstPOA as the child of RootPOA with the above policies
+ // firstPOA will use SERVANT_ACTIVATOR because of RETAIN policy.
+ first_poa_var = root_poa_ptr->create_POA (name.c_str (),
+ poa_manager_ptr,
+ policies,
+ env);
+ if (env.exception () != 0)
{
- ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, str);
+ env.print_exception ("PortableServer::POA::create_POA");
return -1;
}
- ACE_ENDTRY;
- ACE_CHECK_RETURN (-1);
return 0;
}
@@ -234,324 +222,340 @@ int setup_first_poa (PortableServer::POA_ptr root_poa_ptr,
// Servant_Locator to do forwarding
int setup_second_poa (PortableServer::POA_ptr root_poa,
- PortableServer::POAManager_ptr poa_manager_ptr,
+ PortableServer::POAManager_ptr poa_manager_ptr,
PortableServer::POA_var &second_poa_var)
{
- //CORBA::Environment env;
+ CORBA::Environment env;
+
// Policies for the childPOA to be created.
- CORBA::PolicyList policies (4);
+ CORBA::PolicyList policies (4);
policies.length (4);
- char str[256];
- ACE_DECLARE_NEW_CORBA_ENV;
- ACE_TRY
+ // The next two policies are common to both
+
+ // Id Assignment Policy
+ policies[0] = root_poa->create_id_assignment_policy (PortableServer::USER_ID, env);
+ if (env.exception () != 0)
{
-
- ACE_OS::strcpy (str, "PortableServer::POA::create_id_assignment_policy");
-
- // The next two policies are common to both
- // Id Assignment Policy
- policies[0] = root_poa->create_id_assignment_policy (PortableServer::USER_ID, ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- ACE_OS::strcpy (str, "PortableServer::POA::create_lifespan_policy");
- // Lifespan policy
- policies[1] = root_poa->create_lifespan_policy (PortableServer::PERSISTENT, ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- ACE_OS::strcpy (str, "PortableServer::POA::create_request_processing_policy");
- // Tell the POA to use a servant manager
- policies[2] =
- root_poa->create_request_processing_policy (PortableServer::USE_SERVANT_MANAGER, ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- ACE_OS::strcpy (str,"PortableServer::POA::create_servant_retention_policy");
-
- // Servant Retention Policy -> Use a locator
- policies[3] =
- root_poa->create_servant_retention_policy (PortableServer::NON_RETAIN, ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- ACE_CString name = "secondPOA";
-
- ACE_OS::strcpy (str,"PortableServer::POA::create_POA");
- // Create secondPOA as child of RootPOA with the above policies
- // secondPOA will use a SERVANT_LOCATOR because of NON_RETAIN
- // policy.
- second_poa_var = root_poa->create_POA (name.c_str (),
- poa_manager_ptr,
- policies,
- ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- ACE_OS::strcpy (str,"PortableServer::POA::destroy");
-
- // Creation of childPOAs is over. Destroy the Policy objects.
- for (CORBA::ULong i = 0;
- i < policies.length ();
- ++i)
- {
- CORBA::Policy_ptr policy = policies[i];
- policy->destroy (ACE_TRY_ENV);
- ACE_TRY_CHECK;
- }
-
+ env.print_exception ("PortableServer::POA::create_id_assignment_policy");
+ return -1;
+ }
+
+ // Lifespan policy
+ policies[1] = root_poa->create_lifespan_policy (PortableServer::PERSISTENT, env);
+ if (env.exception () != 0)
+ {
+ env.print_exception ("PortableServer::POA::create_lifespan_policy");
+ return -1;
+ }
+
+ // Tell the POA to use a servant manager
+ policies[2] =
+ root_poa->create_request_processing_policy (PortableServer::USE_SERVANT_MANAGER, env);
+ if (env.exception () != 0)
+ {
+ env.print_exception ("PortableServer::POA::create_request_processing_policy");
+ return -1;
+ }
+
+ // Servant Retention Policy -> Use a locator
+ policies[3] =
+ root_poa->create_servant_retention_policy (PortableServer::NON_RETAIN, env);
+ if (env.exception () != 0)
+ {
+ env.print_exception ("PortableServer::POA::create_servant_retention_policy");
+ return -1;
}
- ACE_CATCHANY
+
+ ACE_CString name = "secondPOA";
+
+ // Create secondPOA as child of RootPOA with the above policies
+ // secondPOA will use a SERVANT_LOCATOR because of NON_RETAIN
+ // policy.
+ second_poa_var = root_poa->create_POA (name.c_str (),
+ poa_manager_ptr,
+ policies,
+ env);
+ if (env.exception () != 0)
{
- ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, str);
+ env.print_exception ("PortableServer::POA::create_POA");
return -1;
}
- ACE_ENDTRY;
- ACE_CHECK_RETURN (-1);
+
+ // Creation of childPOAs is over. Destroy the Policy objects.
+ for (CORBA::ULong i = 0;
+ i < policies.length () && env.exception () == 0;
+ ++i)
+ {
+ CORBA::Policy_ptr policy = policies[i];
+ policy->destroy (env);
+ }
+ if (env.exception () != 0)
+ {
+ env.print_exception ("PortableServer::POA::destroy");
+ return -1;
+ }
return 0;
}
int create_first_servant (PortableServer::POA_ptr first_poa_ptr,
CORBA::ORB_ptr orb_ptr)
{
- //CORBA::Environment env;
- ACE_DECLARE_NEW_CORBA_ENV;
-
- char str[256];
-
- ACE_TRY
- {
- ACE_OS::strcpy (str, "get_forward_reference");
- // Get the forward_to reference to feed it into object
- // implementations
- CORBA::Object_var first_foo_forward_to_var;
-
- get_forward_reference (first_foo_forward_to_IOR_,
- first_foo_forward_to_var,
- orb_ptr,
- ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
-
- ACE_NEW_RETURN (myFirstFooServant_ptr,
- MyFirstFooServant (orb_ptr,
- first_poa_ptr,
- 27,
- first_foo_forward_to_var.in ()),
- -1);
-
- // Create ObjectId and use that ObjectId to activate the
- // first_foo_impl object.
- PortableServer::ObjectId_var first_foo_oid_var =
- PortableServer::string_to_ObjectId ("firstFoo");
-
- ACE_OS::strcpy (str,"PortableServer::POA::activate_object_with_id");
+ CORBA::Environment env;
- first_poa_ptr->activate_object_with_id (first_foo_oid_var.in (),
- myFirstFooServant_ptr,
- ACE_TRY_ENV);
- ACE_TRY_CHECK;
+ // Get the forward_to reference to feed it into object
+ // implementations
+ CORBA::Object_var first_foo_forward_to_var;
- ACE_OS::strcpy (str,"POA_Foo::_this");
+ get_forward_reference (first_foo_forward_to_IOR_,
+ first_foo_forward_to_var,
+ orb_ptr,
+ env);
- // Get Object reference for first_foo_impl object.
- Foo_var first_foo_var = myFirstFooServant_ptr->_this (ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- ACE_OS::strcpy (str, "CORBA::ORB::object_to_string");
- // Stringyfy the object reference and print it out.
- CORBA::String_var first_foo_ior_var =
- orb_ptr->object_to_string (first_foo_var.in (), ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
-
- ACE_DEBUG ((LM_DEBUG,
- "POA approach: Own IOR: %s\n",
- first_foo_ior_var.in ()));
+ if (env.exception () != 0)
+ {
+ env.print_exception ("get_forward_reference");
+ return -1;
+ }
- if (first_foo_ior_output_file_)
- {
- ACE_OS::fprintf (first_foo_ior_output_file_,
- "%s",
- first_foo_ior_var.in ());
- ACE_OS::fclose (first_foo_ior_output_file_);
+ ACE_NEW_RETURN (myFirstFooServant_ptr,
+ MyFirstFooServant (orb_ptr,
+ first_poa_ptr,
+ 27,
+ first_foo_forward_to_var.in ()),
+ -1);
+
+ // Create ObjectId and use that ObjectId to activate the
+ // first_foo_impl object.
+ PortableServer::ObjectId_var first_foo_oid_var =
+ PortableServer::string_to_ObjectId ("firstFoo");
+
+ first_poa_ptr->activate_object_with_id (first_foo_oid_var.in (),
+ myFirstFooServant_ptr,
+ env);
+ if (env.exception () != 0)
+ {
+ env.print_exception ("PortableServer::POA::activate_object_with_id");
+ return -1;
+ }
+
+ // Get Object reference for first_foo_impl object.
+ Foo_var first_foo_var = myFirstFooServant_ptr->_this (env);
- ACE_DEBUG ((LM_DEBUG, "POA approach: Wrote IOR to a file.\n"));
- }
+ if (env.exception () != 0)
+ {
+ env.print_exception ("POA_Foo::_this");
+ return -1;
}
- ACE_CATCHANY
+
+ // Stringyfy the object reference and print it out.
+ CORBA::String_var first_foo_ior_var =
+ orb_ptr->object_to_string (first_foo_var.in (), env);
+
+ if (env.exception () != 0)
{
- ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, str);
+ env.print_exception ("CORBA::ORB::object_to_string");
return -1;
}
- ACE_ENDTRY;
- ACE_CHECK_RETURN (-1);
+
+ ACE_DEBUG ((LM_DEBUG,
+ "POA approach: Own IOR: %s\n",
+ first_foo_ior_var.in ()));
+
+ if (first_foo_ior_output_file_)
+ {
+ ACE_OS::fprintf (first_foo_ior_output_file_,
+ "%s",
+ first_foo_ior_var.in ());
+ ACE_OS::fclose (first_foo_ior_output_file_);
+
+ ACE_DEBUG ((LM_DEBUG, "POA approach: Wrote IOR to a file.\n"));
+ }
return 0;
}
-int
+int
create_second_servant (PortableServer::POA_ptr second_poa_ptr,
CORBA::ORB_ptr orb_ptr)
{
- // CORBA::Environment env;
-
- ACE_DECLARE_NEW_CORBA_ENV;
- char str[256];
- ACE_TRY
+ CORBA::Environment env;
+
+ CORBA::Object_var second_foo_forward_to_var;
+ get_forward_reference (second_foo_forward_to_IOR_,
+ second_foo_forward_to_var,
+ orb_ptr,
+ env);
+ if (env.exception () != 0)
{
- CORBA::Object_var second_foo_forward_to_var;
-
- ACE_OS::strcpy (str, "get_forward_reference");
-
- get_forward_reference (second_foo_forward_to_IOR_,
- second_foo_forward_to_var,
- orb_ptr,
- ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- // instantiate the servant locator and set it for the second child
- // POA The locator gets to know where to forward to
-
- ACE_NEW_RETURN (myFooServantLocator_ptr,
- MyFooServantLocator (orb_ptr,
- second_foo_forward_to_var.in ()),
- -1);
-
- ACE_OS::strcpy (str, "PortableServer::POAManager::_this");
- PortableServer::ServantLocator_var servant_locator_var =
- myFooServantLocator_ptr->_this (ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- ACE_OS::strcpy (str, "PortableServer::POAManager::set_servant_manager");
- // Set MyFooServantLocator object as the servant Manager of
- // secondPOA.
- second_poa_ptr->set_servant_manager (servant_locator_var.in (), ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
-
- // Create the second MyFooServant
- // ======
-
- // Try to create a reference with user created ID in second_poa
- // which uses MyFooServantLocator.
-
- PortableServer::ObjectId_var second_foo_oid_var =
- PortableServer::string_to_ObjectId ("secondFoo");
-
- ACE_OS::strcpy (str,"PortableServer::POA::create_reference_with_id");
- CORBA::Object_var second_foo_var =
- second_poa_ptr->create_reference_with_id (second_foo_oid_var.in (),
- "IDL:Foo:1.0", ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- ACE_OS::strcpy (str,"CORBA::ORB::object_to_string");
- // Invoke object_to_string on the references created in firstPOA and
- // secondPOA.
- CORBA::String_var second_foo_ior_var =
- orb_ptr->object_to_string (second_foo_var.in (), ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- ACE_DEBUG ((LM_DEBUG,
- "Locator approach: Own IOR: %s\n",
- second_foo_ior_var.in ()));
-
+ env.print_exception ("get_forward_reference");
+ return -1;
+ }
- if (second_foo_ior_output_file_)
- {
- ACE_OS::fprintf (second_foo_ior_output_file_,
- "%s",
- second_foo_ior_var.in ());
- ACE_OS::fclose (second_foo_ior_output_file_);
+ // instantiate the servant locator and set it for the second child
+ // POA The locator gets to know where to forward to
+
+ ACE_NEW_RETURN (myFooServantLocator_ptr,
+ MyFooServantLocator (orb_ptr,
+ second_foo_forward_to_var.in ()),
+ -1);
+ PortableServer::ServantLocator_var servant_locator_var =
+ myFooServantLocator_ptr->_this (env);
+
+ if (env.exception () != 0)
+ {
+ env.print_exception ("PortableServer::POAManager::_this");
+ return -1;
+ }
+
+ // Set MyFooServantLocator object as the servant Manager of
+ // secondPOA.
- ACE_DEBUG ((LM_DEBUG, "Locator approach: Wrote IOR to a file.\n"));
- }
+ second_poa_ptr->set_servant_manager (servant_locator_var.in (), env);
+
+ if (env.exception () != 0)
+ {
+ env.print_exception ("PortableServer::POAManager::set_servant_manager");
+ return -1;
+ }
+
+ // Create the second MyFooServant
+ // ======
+
+ // Try to create a reference with user created ID in second_poa
+ // which uses MyFooServantLocator.
+
+ PortableServer::ObjectId_var second_foo_oid_var =
+ PortableServer::string_to_ObjectId ("secondFoo");
+
+ CORBA::Object_var second_foo_var =
+ second_poa_ptr->create_reference_with_id (second_foo_oid_var.in (),
+ "IDL:Foo:1.0", env);
+ if (env.exception () != 0)
+ {
+ env.print_exception ("PortableServer::POA::create_reference_with_id");
+ return -1;
}
- ACE_CATCHANY
+
+ // Invoke object_to_string on the references created in firstPOA and
+ // secondPOA.
+
+ CORBA::String_var second_foo_ior_var =
+ orb_ptr->object_to_string (second_foo_var.in (), env);
+
+ if (env.exception () != 0)
{
- ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, str);
+ env.print_exception ("CORBA::ORB::object_to_string");
return -1;
}
- ACE_ENDTRY;
- ACE_CHECK_RETURN (-1);
+
+ ACE_DEBUG ((LM_DEBUG,
+ "Locator approach: Own IOR: %s\n",
+ second_foo_ior_var.in ()));
+
+
+ if (second_foo_ior_output_file_)
+ {
+ ACE_OS::fprintf (second_foo_ior_output_file_,
+ "%s",
+ second_foo_ior_var.in ());
+ ACE_OS::fclose (second_foo_ior_output_file_);
+
+ ACE_DEBUG ((LM_DEBUG, "Locator approach: Wrote IOR to a file.\n"));
+ }
+
return 0;
}
int
main (int argc, char **argv)
{
+ // @@ Michael, this function is WAY too long! Can you please break
+ // it up into a number of subfunctions and put them into a class or
+ // something?! It's impossible to tell what's going on here!
int result = parse_args (argc, argv);
if (result == -1)
return -1;
- ACE_DECLARE_NEW_CORBA_ENV;
- char str[256];
- ACE_TRY
+ CORBA::Environment env;
+
+ // Initialize the ORB first.
+ CORBA::ORB_var orb_var = CORBA::ORB_init (argc, argv, 0, env);
+
+ if (env.exception () != 0)
{
- ACE_OS::strcpy (str, "CORBA::ORB_init");
- // Initialize the ORB first.
- CORBA::ORB_var orb_var = CORBA::ORB_init (argc, argv, 0, ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- // Obtain the RootPOA.
- CORBA::Object_var obj_var = orb_var->resolve_initial_references ("RootPOA");
-
- ACE_OS::strcpy (str,"PortableServer::POA::_narrow");
- // Get the POA_var object from Object_var.
- PortableServer::POA_var root_poa_var =
- PortableServer::POA::_narrow (obj_var.in (), ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
-
- // Get the POAManager of the RootPOA.
- PortableServer::POAManager_var poa_manager_var =
- root_poa_var->the_POAManager (ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
-
- PortableServer::POA_var first_poa_var;
- PortableServer::POA_var second_poa_var;
-
- if (setup_first_poa (root_poa_var.in(), poa_manager_var.in(), first_poa_var) == -1)
- return -1;
- if (setup_second_poa (root_poa_var.in(), poa_manager_var.in(), second_poa_var) == -1)
- return -1;
-
- // Create the first MyFooServant
- // =====
- if (create_first_servant (first_poa_var.in(), orb_var.in()) == -1)
- return -1;
-
- if (create_second_servant (second_poa_var.in(), orb_var.in()) == -1)
- return -1;
-
- ACE_OS::strcpy (str, "PortableServer::POAManager::activate");
-
- poa_manager_var->activate (ACE_TRY_ENV);
- ACE_TRY_CHECK;
+ env.print_exception ("CORBA::ORB_init");
+ return -1;
+ }
- if (orb_var->run () == -1)
- ACE_ERROR_RETURN ((LM_ERROR,
- "%p\n",
- "CORBA::ORB::run"),
- -1);
+ // Obtain the RootPOA.
+ CORBA::Object_var obj_var = orb_var->resolve_initial_references ("RootPOA");
+
+ // Get the POA_var object from Object_var.
+ PortableServer::POA_var root_poa_var =
+ PortableServer::POA::_narrow (obj_var.in (), env);
+
+ if (env.exception () != 0)
+ {
+ env.print_exception ("PortableServer::POA::_narrow");
+ return -1;
+ }
+
+ // Get the POAManager of the RootPOA.
+ PortableServer::POAManager_var poa_manager_var =
+ root_poa_var->the_POAManager (env);
+
+ if (env.exception () != 0)
+ {
+ env.print_exception ("PortableServer::POA::the_POAManager");
+ return -1;
+ }
+
+ PortableServer::POA_var first_poa_var;
+ PortableServer::POA_var second_poa_var;
+
+ if (setup_first_poa (root_poa_var.in(), poa_manager_var.in(), first_poa_var) == -1)
+ return -1;
+ if (setup_second_poa (root_poa_var.in(), poa_manager_var.in(), second_poa_var) == -1)
+ return -1;
+
+ // Create the first MyFooServant
+ // =====
+ if (create_first_servant (first_poa_var.in(), orb_var.in()) == -1)
+ return -1;
- ACE_OS::strcpy (str, "PortableServer::POA::destroy");
+ if (create_second_servant (second_poa_var.in(), orb_var.in()) == -1)
+ return -1;
+
+ poa_manager_var->activate (env);
+ if (env.exception () != 0)
+ {
+ env.print_exception ("PortableServer::POAManager::activate");
+ return -1;
+ }
+
+ if (orb_var->run () == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "CORBA::ORB::run"),
+ -1);
- // Destroy RootPOA. (Also destroys childPOA)
- root_poa_var->destroy (1,
- 1,
- ACE_TRY_ENV);
- ACE_TRY_CHECK;
- delete myFirstFooServant_ptr;
- delete myFooServantLocator_ptr;
+
+ // Destroy RootPOA. (Also destroys childPOA)
+ root_poa_var->destroy (1,
+ 1,
+ env);
+ delete myFirstFooServant_ptr;
+ delete myFooServantLocator_ptr;
- }
- ACE_CATCHANY
+ if (env.exception () != 0)
{
- ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, str);
+ env.print_exception ("PortableServer::POA::destroy");
return -1;
}
- ACE_ENDTRY;
- ACE_CHECK_RETURN (-1);
+
return 0;
}