Beispiel #1
0
void
activate (T & obj_ref,
          PortableServer::POA_ptr poa,
          PortableServer::ServantBase * servant,
          TAO_EC_Object_Deactivator & suggested_object_deactivator)
{
  // Activate the servant into the POA.
  PortableServer::ObjectId_var obj_id =
    poa->activate_object (servant);

  suggested_object_deactivator.set_values (poa, obj_id.in ());

  // Get the object reference of the activated object.
  CORBA::Object_var obj =
    poa->id_to_reference (obj_id.in ());

  // Don't try to use T::_obj_type::_narrow, some compilers don't like it so
  // do this in two steps
  typedef typename T::_obj_type my_object_type;

  obj_ref =
    my_object_type::_narrow (obj.in());

  if (CORBA::is_nil (obj_ref.in ()))
  {
    throw CORBA::INTERNAL ();
  }
}
Beispiel #2
0
int
create_object (PortableServer::POA_ptr poa,
               CORBA::ORB_ptr orb,
               Test_i *server_impl,
               const ACE_TCHAR *filename)
{
  // Register with poa.
  PortableServer::ObjectId_var id =
    poa->activate_object (server_impl);


  CORBA::Object_var server =
    poa->id_to_reference (id.in ());

  // Print out the IOR.
  CORBA::String_var ior =
    orb->object_to_string (server.in ());

  ACE_DEBUG ((LM_DEBUG, "<%C>\n\n", ior.in ()));

  // Print ior to the file.
  if (filename != 0)
    {
      FILE *output_file= ACE_OS::fopen (filename, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file for writing IOR: %s",
                           filename),
                          -1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);
    }

  return 0;
}
Beispiel #3
0
void
LiveEntry::do_ping (PortableServer::POA_ptr poa)
{
  this->callback_ = new PingReceiver (this, poa);
  PortableServer::ObjectId_var oid = poa->activate_object (this->callback_.in());
  CORBA::Object_var obj = poa->id_to_reference (oid.in());
  ImplementationRepository::AMI_ServerObjectHandler_var cb =
    ImplementationRepository::AMI_ServerObjectHandler::_narrow (obj.in());
  {
    ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_);
    this->liveliness_ = LS_PING_AWAY;
  }
  try
    {
      this->ref_->sendc_ping (cb.in());
      if (ImR_Locator_i::debug () > 3)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("(%P|%t) LiveEntry::do_ping, ")
                          ACE_TEXT ("sendc_ping returned OK\n")));
        }
    }
  catch (const CORBA::Exception &ex)
    {
      if (ImR_Locator_i::debug () > 3)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("(%P|%t) LiveEntry::do_ping, ")
                          ACE_TEXT ("sendc_ping threw %C\n"), ex._name()));
        }
      this->status (LS_DEAD);
    }
}
Beispiel #4
0
CosNotifyFilter::FilterFactory_ptr
TAO_Notify_ETCL_FilterFactory::create (PortableServer::POA_ptr filter_poa)
{
  this->filter_poa_ = PortableServer::POA::_duplicate(filter_poa);

  CORBA::Object_var object = CORBA::Object::_nil();
  try
    {
      PortableServer::ObjectId_var id = filter_poa->activate_object (this);
      object = filter_poa->id_to_reference (id.in());
    }
  catch (PortableServer::POA::ServantAlreadyActive&)
    {
      try
        {
          object = filter_poa->servant_to_reference (this);
        }
      catch (CORBA::Exception& )
        {
         return CosNotifyFilter::FilterFactory::_nil();
        }
    }

  return  CosNotifyFilter::FilterFactory::_narrow (object.in ());
}
Beispiel #5
0
int
make_ior (CORBA::ORB_ptr orb,
          PortableServer::POA_ptr poa,
          Hello * servant,
          const ACE_TCHAR *ior_file)
{
  CORBA::String_var poa_name = poa->the_name();
  ACE_DEBUG ((LM_DEBUG, "Creating IOR from %C\n", poa_name.in()));

  PortableServer::ObjectId_var oid = poa->activate_object (servant);
  CORBA::Object_var o = poa->id_to_reference (oid.in ());


  if (host_form == from_hostname || host_form == use_localhost)
    {
      CORBA::String_var ior =
        orb->object_to_string (o.in ());

      FILE *output_file= ACE_OS::fopen (ior_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file %s for writing IOR: %C",
                           ior_file,
                           ior.in ()),
                          1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);
    }
  return 0;
}
Beispiel #6
0
void
test_reference_to_servant_active_object(PortableServer::POA_ptr root_poa)
{
  test_i test;
  CORBA::ULong expected_refcount = 1;

  PortableServer::ObjectId_var id =
    root_poa->activate_object (&test);
  expected_refcount++;

  CORBA::Object_var object =
    root_poa->id_to_reference (id.in ());

  PortableServer::ServantBase_var servant =
    root_poa->reference_to_servant (object.in ());
  ++expected_refcount;

  root_poa->deactivate_object (id.in ());
  --expected_refcount;

  CORBA::ULong refcount =
    test._refcount_value ();

  ACE_UNUSED_ARG (refcount);
  ACE_UNUSED_ARG (expected_refcount);
  ACE_ASSERT (expected_refcount == refcount);
}
CosNotifyFilter::FilterFactory_ptr
TAO_Notify_Tests_RT_Test_FilterFactory::create (PortableServer::POA_ptr filter_poa)
{
  this->filter_poa_ = PortableServer::POA::_duplicate(filter_poa); // save the filter poa.

  PortableServer::ObjectId_var id = filter_poa->activate_object (this);

  CORBA::Object_var object = filter_poa->id_to_reference (id.in ());

  CosNotifyFilter::FilterFactory_var filter = CosNotifyFilter::FilterFactory::_narrow (object.in ());

  return filter._retn();
}
CosNaming::NamingContext_ptr
TAO_Transient_Naming_Context::make_new_context (PortableServer::POA_ptr poa,
                                                const char *poa_id,
                                                size_t context_size)
{
  // Put together a servant for the new Naming Context.

  TAO_Transient_Naming_Context *context_impl = 0;
  ACE_NEW_THROW_EX (context_impl,
                    TAO_Transient_Naming_Context (poa,
                                                  poa_id,
                                                  context_size),
                    CORBA::NO_MEMORY ());

  // Put <context_impl> into the auto pointer temporarily, in case next
  // allocation fails.
  ACE_Auto_Basic_Ptr<TAO_Transient_Naming_Context> temp (context_impl);

  TAO_Naming_Context *context = 0;
  ACE_NEW_THROW_EX (context,
                    TAO_Naming_Context (context_impl),
                    CORBA::NO_MEMORY ());

  // Let <implementation> know about it's <interface>.
  context_impl->interface (context);

  // Release auto pointer, and start using reference counting to
  // control our servant.
  temp.release ();
  PortableServer::ServantBase_var s = context;

  // Register the new context with the POA.
#if defined (CORBA_E_MICRO)
  PortableServer::ObjectId_var id = poa->activate_object (context);
#else
  PortableServer::ObjectId_var id =
    PortableServer::string_to_ObjectId (poa_id);

  poa->activate_object_with_id (id.in (), context);
#endif /* CORBA_E_MICRO */

  CosNaming::NamingContext_var result = context->_this ();

  return result._retn ();
}
Beispiel #9
0
CORBA::Object_ptr
AppHelper::activate_servant(PortableServer::POA_ptr poa,
                            PortableServer::Servant servant)
{
  // Activate the servant using the Child POA.
  PortableServer::ObjectId_var oid
    = poa->activate_object(servant);

  CORBA::Object_var obj
    = poa->servant_to_reference(servant);

  if (CORBA::is_nil(obj.in()))
    {
      ACE_ERROR((LM_ERROR,
                 "(%P|%t) Failed to convert servant_to_ref.\n"));
      throw TestAppException();
    }

  return obj._retn();
}
Beispiel #10
0
void
create_object (PortableServer::POA_ptr poa,
               CORBA::ORB_ptr orb,
               PortableServer::Servant servant,
               const ACE_TCHAR *filename)
{
  // Register with poa.
  PortableServer::ObjectId_var id =
    poa->activate_object (servant);

  CORBA::Object_var object =
    poa->id_to_reference (id.in ());

  CORBA::String_var ior =
    orb->object_to_string (object.in ());

  FILE *output_file= ACE_OS::fopen (filename, "w");
  ACE_OS::fprintf (output_file, "%s", ior.in ());
  ACE_OS::fclose (output_file);
}
Beispiel #11
0
void
ReconnectionCallback_i::init (
  PortableServer::POA_ptr poa,
  CosNotifyChannelAdmin::EventChannelFactory_ptr ecf)
{
  this->ecf_ = CosNotifyChannelAdmin::EventChannelFactory::_duplicate (ecf);
  PortableServer::ObjectId_var reconnection_callback_id =
    poa->activate_object (this);

  CORBA::Object_var obj =
    poa->id_to_reference (reconnection_callback_id.in ());

  NotifyExt::ReconnectionCallback_var callback =
    NotifyExt::ReconnectionCallback::_narrow (obj.in ());

  NotifyExt::ReconnectionRegistry_var registry =
    NotifyExt::ReconnectionRegistry::_narrow (ecf);

  this->callback_id_ = registry->register_callback (callback.in ());
  this->id_is_valid_ = true;
}
Beispiel #12
0
int
run_buffer_size (CORBA::ORB_ptr orb,
                 PortableServer::POA_ptr root_poa,
                 Test::AMI_Buffering_ptr ami_buffering,
                 Test::AMI_Buffering_Admin_ptr ami_buffering_admin)
{
  TAO::BufferingConstraint buffering_constraint;
  buffering_constraint.mode = TAO::BUFFER_MESSAGE_BYTES;
  buffering_constraint.message_count = 0;
  buffering_constraint.message_bytes = BUFFER_SIZE;
  buffering_constraint.timeout = 0;

  Test::AMI_Buffering_var flusher;
  int test_failed =
    configure_policies (orb, buffering_constraint,
                        ami_buffering, flusher.out ());

  if (test_failed != 0)
    return test_failed;

  Test::Payload payload (PAYLOAD_LENGTH);
  payload.length (PAYLOAD_LENGTH);

  Reply_Handler *reply_handler_impl;
  ACE_NEW_RETURN (reply_handler_impl,
                  Reply_Handler,
                  1);
  PortableServer::ServantBase_var owner_transfer(reply_handler_impl);

  PortableServer::ObjectId_var id =
    root_poa->activate_object (reply_handler_impl);

  CORBA::Object_var object_act = root_poa->id_to_reference (id.in ());

  Test::AMI_AMI_BufferingHandler_var reply_handler =
    Test::AMI_AMI_BufferingHandler::_narrow (object_act.in ());

  CORBA::ULong bytes_sent = 0;
  for (int i = 0; i != iterations; ++i)
    {
      sync_server (orb, flusher.in ());

      CORBA::ULong initial_bytes_received =
        ami_buffering_admin->bytes_received_count ();

      if (initial_bytes_received != bytes_sent)
        {
          test_failed = 1;
          ACE_DEBUG ((LM_DEBUG,
                      "DEBUG: Iteration %d data lost (%u != %u)\n",
                      i, initial_bytes_received, bytes_sent));
        }

      while (1)
        {
          ami_buffering->sendc_receive_data (reply_handler.in (),
                                             payload);
          bytes_sent += PAYLOAD_LENGTH;

          CORBA::ULong bytes_received =
            ami_buffering_admin->bytes_received_count ();

          ACE_Time_Value tv (0, 10 * 1000);
          orb->run (tv);

          CORBA::ULong payload_delta =
            bytes_sent - initial_bytes_received;
          if (bytes_received != initial_bytes_received)
            {
              // The queue has been flushed, check that enough data
              // has been sent.  The check cannot be precise because
              // the ORB counts the GIOP message overhead, in this
              // test we assume the overhead to be less than 10%

              if (payload_delta < CORBA::ULong (GIOP_OVERHEAD * BUFFER_SIZE))
                {
                  test_failed = 1;
                  ACE_DEBUG ((LM_DEBUG,
                              "DEBUG: Iteration %d flush before "
                              "minimum buffer size was reached. "
                              "Sent = %u, Minimum buffer = %u bytes\n",
                              i,
                              payload_delta, BUFFER_SIZE));
                }
              break;
            }

          if (payload_delta > 2 * BUFFER_SIZE)
            {
              test_failed = 1;
              ACE_DEBUG ((LM_DEBUG,
                          "DEBUG: Iteration %d no flush past "
                          "buffer size threshold. "
                          "Sent = %u, Minimum buffer = %u bytes\n",
                          i,
                          payload_delta, BUFFER_SIZE));
              break;
            }
        }
    }

  int liveness_test_failed =
    run_liveness_test (orb,
                       reply_handler.in (),
                       ami_buffering,
                       flusher.in (),
                       ami_buffering_admin);

  if (liveness_test_failed)
    test_failed = 1;

  return test_failed;
}
Beispiel #13
0
int
run_timeout_reactive (CORBA::ORB_ptr orb,
                      PortableServer::POA_ptr root_poa,
                      Test::AMI_Buffering_ptr ami_buffering,
                      Test::AMI_Buffering_Admin_ptr ami_buffering_admin)
{
  TAO::BufferingConstraint buffering_constraint;
  buffering_constraint.mode = TAO::BUFFER_TIMEOUT;
  buffering_constraint.message_count = 0;
  buffering_constraint.message_bytes = 0;
  buffering_constraint.timeout = TIMEOUT_MILLISECONDS * 10000;

  Test::AMI_Buffering_var flusher;
  int test_failed =
    configure_policies (orb, buffering_constraint,
                        ami_buffering, flusher.out ());

  if (test_failed != 0)
    return test_failed;

  Test::Payload payload (PAYLOAD_LENGTH);
  payload.length (PAYLOAD_LENGTH);
  for (int j = 0; j != PAYLOAD_LENGTH; ++j)
    payload[j] = CORBA::Octet(j % 256);

  Reply_Handler *reply_handler_impl = 0;
  ACE_NEW_RETURN (reply_handler_impl,
                  Reply_Handler,
                  1);
  PortableServer::ServantBase_var owner_transfer(reply_handler_impl);

  PortableServer::ObjectId_var id =
    root_poa->activate_object (reply_handler_impl);

  CORBA::Object_var object_act = root_poa->id_to_reference (id.in ());

  Test::AMI_AMI_BufferingHandler_var reply_handler =
    Test::AMI_AMI_BufferingHandler::_narrow (object_act.in ());

  CORBA::ULong send_count = 0;
  int retry_attempt = 0;
  for (int i = 0; i != iterations; ++i)
    {
      sync_server (orb, flusher.in ());

      CORBA::ULong initial_receive_count =
        ami_buffering_admin->request_count ();

      if (initial_receive_count != send_count)
        {
          test_failed = 1;
          ACE_DEBUG ((LM_DEBUG,
                      "DEBUG: Iteration %d message lost (%u != %u)\n",
                      i, initial_receive_count, send_count));
        }
      ACE_Time_Value start = ACE_OS::gettimeofday ();
      for (int j = 0; j != 20; ++j)
        {
          ami_buffering->sendc_receive_data (reply_handler.in (),
                                             payload);
          send_count++;
        }
      while (1)
        {
          CORBA::ULong receive_count =
            ami_buffering_admin->request_count ();

          ACE_Time_Value tv (0, 10 * 1000);
          orb->run (tv);

          ACE_Time_Value elapsed = ACE_OS::gettimeofday () - start;
          if (receive_count != initial_receive_count)
            {
              if (elapsed.msec () < TIMEOUT_MILLISECONDS)
                {
                  test_failed = 1;
                  ACE_DEBUG ((LM_DEBUG,
                              "DEBUG: Iteration %d flush before "
                              "timeout expired. "
                              "Elapsed = %d, Timeout = %d msecs\n",
                              i,
                              elapsed.msec (), TIMEOUT_MILLISECONDS));
                }
              // terminate the while loop.
              break;
            }

          if (elapsed.msec () > TIMEOUT_TOLERANCE)
            {
              if (retry_attempt++ < 10) {
                ACE_DEBUG ((LM_DEBUG, "DEBUG: Retry attempt %d beyond TIMEOUT_TOLERANCE.\n",
                            retry_attempt));
                continue;
              }

              test_failed = 1;
              ACE_DEBUG ((LM_DEBUG,
                          "DEBUG: Iteration %d no flush past "
                          "timeout threshold. "
                          "Elapsed = %d, Timeout = %d msecs\n",
                          i,
                          elapsed.msec (), TIMEOUT_TOLERANCE));
              break;
            }
        }
    }

#if 0
  int liveness_test_failed =
    run_liveness_test (orb,
                       reply_handler.in (),
                       ami_buffering,
                       flusher.in (),
                       ami_buffering_admin);

  if (liveness_test_failed)
    test_failed = 1;
#endif /* 0 */


  return test_failed;
}
Beispiel #14
0
int
run_message_count (CORBA::ORB_ptr orb,
                   PortableServer::POA_ptr root_poa,
                   Test::AMI_Buffering_ptr ami_buffering,
                   Test::AMI_Buffering_Admin_ptr ami_buffering_admin)
{
  TAO::BufferingConstraint buffering_constraint;
  buffering_constraint.mode = TAO::BUFFER_MESSAGE_COUNT;
  buffering_constraint.message_count = BUFFERED_MESSAGES_COUNT;
  buffering_constraint.message_bytes = 0;
  buffering_constraint.timeout = 0;

  Test::AMI_Buffering_var flusher;
  int test_failed =
    configure_policies (orb, buffering_constraint,
                        ami_buffering, flusher.out ());

  if (test_failed != 0)
    return test_failed;

  Test::Payload payload (PAYLOAD_LENGTH);
  payload.length (PAYLOAD_LENGTH);
  for (int j = 0; j != PAYLOAD_LENGTH; ++j)
    payload[j] = CORBA::Octet(j % 256);

  Reply_Handler *reply_handler_impl = 0;
  ACE_NEW_RETURN (reply_handler_impl,
                  Reply_Handler,
                  1);
  PortableServer::ServantBase_var owner_transfer(reply_handler_impl);

  PortableServer::ObjectId_var id =
    root_poa->activate_object (reply_handler_impl);

  CORBA::Object_var object_act = root_poa->id_to_reference (id.in ());

  Test::AMI_AMI_BufferingHandler_var reply_handler =
    Test::AMI_AMI_BufferingHandler::_narrow (object_act.in ());

  CORBA::ULong send_count = 0;
  for (int i = 0; i != iterations; ++i)
    {
      sync_server (orb, flusher.in ());

      CORBA::ULong initial_receive_count =
        ami_buffering_admin->request_count ();

      if (initial_receive_count != send_count)
        {
          test_failed = 1;
          ACE_DEBUG ((LM_DEBUG,
                      "DEBUG: Iteration %d message lost (%u != %u)\n",
                      i, initial_receive_count, send_count));
        }

      while (1)
        {
          ami_buffering->sendc_receive_data (reply_handler.in (),
                                             payload);
          send_count++;

          CORBA::ULong receive_count =
            ami_buffering_admin->request_count ();

          ACE_Time_Value tv (0, 10 * 1000);
          orb->run (tv);

          CORBA::ULong iteration_count =
            send_count - initial_receive_count;
          if (receive_count != initial_receive_count)
            {
              if (iteration_count < CORBA::ULong(BUFFERED_MESSAGES_COUNT))
                {
                  test_failed = 1;
                  ACE_DEBUG ((LM_DEBUG,
                              "DEBUG: Iteration %d flush before "
                              "message count reached. "
                              "Iteration count = %u, Threshold = %u\n",
                              i,
                              iteration_count, BUFFERED_MESSAGES_COUNT));
                }
              break;
            }

          if (iteration_count > 2 * BUFFERED_MESSAGES_COUNT)
            {
              test_failed = 1;
              ACE_DEBUG ((LM_DEBUG,
                          "DEBUG: Iteration %d no flush past "
                          "message count threshold. "
                          "Iteration count = %u, Threshold = %u\n",
                          i,
                          iteration_count, BUFFERED_MESSAGES_COUNT));
              break;
            }
        }
    }

  int liveness_test_failed =
    run_liveness_test (orb,
                       reply_handler.in (),
                       ami_buffering,
                       flusher.in (),
                       ami_buffering_admin);

  if (liveness_test_failed)
    test_failed = 1;

  return test_failed;
}
Beispiel #15
0
void
test_poas (CORBA::ORB_ptr orb,
           PortableServer::POA_ptr root_poa,
           PortableServer::POA_ptr first_poa,
           PortableServer::POA_ptr second_poa,
           PortableServer::POA_ptr third_poa,
           PortableServer::POA_ptr forth_poa,
           int perform_deactivation_test)
{
  {
    test_i servant (root_poa);

    CORBA::Object_var obj = root_poa->create_reference ("IDL:test:1.0");

    CORBA::String_var string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ObjectId_var id = root_poa->reference_to_id (obj.in ());

    root_poa->activate_object_with_id (id.in (),
                                       &servant);

    obj = root_poa->id_to_reference (id.in ());

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ServantBase_var servant_from_reference =
      root_poa->reference_to_servant (obj.in ());

    PortableServer::ServantBase_var servant_from_id =
      root_poa->id_to_servant (id.in ());

    if (servant_from_reference.in () != servant_from_id.in ()
        || servant_from_reference.in () != &servant)
      {
        ACE_ERROR ((LM_ERROR,
                    "Mismatched servant_from_reference, "
                    "servant_from_id and &servant\n"));
      }

    obj = root_poa->servant_to_reference (&servant);

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    obj = servant._this ();

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ObjectId_var id_from_servant = root_poa->servant_to_id (&servant);

    ACE_ASSERT (id_from_servant.in () == id.in ());

    root_poa->deactivate_object (id.in ());

    if (perform_deactivation_test)
      {
        root_poa->activate_object_with_id (id.in (),
                                           &servant);

        servant_from_reference = root_poa->reference_to_servant (obj.in ());

        ACE_ASSERT (servant_from_reference.in () == &servant);

        root_poa->deactivate_object (id.in ());
      }
  }

  {
    test_i servant (root_poa);

    PortableServer::ObjectId_var id = root_poa->activate_object (&servant);

    CORBA::Object_var obj = root_poa->id_to_reference (id.in ());

    CORBA::String_var string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    obj = root_poa->create_reference_with_id (id.in (),
                                              "IDL:test:1.0");

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    root_poa->deactivate_object (id.in ());
  }

  {
    test_i servant (first_poa);

    CORBA::Object_var obj = first_poa->create_reference ("IDL:test:1.0");

    CORBA::String_var string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ObjectId_var id = first_poa->reference_to_id (obj.in ());

    first_poa->activate_object_with_id (id.in (),
                                        &servant);

    obj = first_poa->id_to_reference (id.in ());

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ServantBase_var servant_from_reference =
      first_poa->reference_to_servant (obj.in ());

    PortableServer::ServantBase_var servant_from_id =
      first_poa->id_to_servant (id.in ());

    if (servant_from_reference .in () != servant_from_id.in ()
        || servant_from_reference.in () != &servant)
      {
        ACE_ERROR ((LM_ERROR,
                    "Mismatched servant_from_reference, "
                    "servant_from_id and &servant\n"));
      }

    first_poa->deactivate_object (id.in ());

    if (perform_deactivation_test)
      {
        first_poa->activate_object_with_id (id.in (),
                                            &servant);

        servant_from_reference = first_poa->reference_to_servant (obj.in ());

        ACE_ASSERT (servant_from_reference.in () == &servant);

        first_poa->deactivate_object (id.in ());
      }
  }

  {
    test_i servant (first_poa);

    PortableServer::ObjectId_var id = first_poa->activate_object (&servant);

    CORBA::Object_var obj = first_poa->id_to_reference (id.in ());

    CORBA::String_var string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    obj = first_poa->create_reference_with_id (id.in (),
                                               "IDL:test:1.0");

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    first_poa->deactivate_object (id.in ());
  }

  {
    test_i servant (second_poa);

    CORBA::Object_var obj = second_poa->create_reference ("IDL:test:1.0");

    CORBA::String_var string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ObjectId_var id = second_poa->reference_to_id (obj.in ());

    second_poa->activate_object_with_id (id.in (),
                                         &servant);

    obj = second_poa->id_to_reference (id.in ());

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ServantBase_var servant_from_reference =
      second_poa->reference_to_servant (obj.in ());

    PortableServer::ServantBase_var servant_from_id =
      second_poa->id_to_servant (id.in ());

    if (servant_from_reference.in () != servant_from_id.in ()
        || servant_from_reference.in () != &servant)
      {
        ACE_ERROR ((LM_ERROR,
                    "Mismatched servant_from_reference, "
                    "servant_from_id and &servant\n"));
      }

    obj = second_poa->servant_to_reference (&servant);

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    obj = servant._this ();

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ObjectId_var id_from_servant = second_poa->servant_to_id (&servant);

    ACE_ASSERT (id_from_servant.in () == id.in ());

    second_poa->deactivate_object (id.in ());

    if (perform_deactivation_test)
      {
        second_poa->activate_object_with_id (id.in (),
                                             &servant);

        servant_from_reference = second_poa->reference_to_servant (obj.in ());

        ACE_ASSERT (servant_from_reference.in () == &servant);

        second_poa->deactivate_object (id.in ());
      }
  }

  {
    test_i servant (second_poa);

    PortableServer::ObjectId_var id = second_poa->activate_object (&servant);

    CORBA::Object_var obj = second_poa->id_to_reference (id.in ());

    CORBA::String_var string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    obj = second_poa->create_reference_with_id (id.in (),
                                                "IDL:test:1.0");

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    second_poa->deactivate_object (id.in ());
  }

  {
    test_i servant (third_poa);
    PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId ("hello");

    CORBA::Object_var obj = third_poa->create_reference_with_id (id.in (),
                                                                 "IDL:test:1.0");

    CORBA::String_var string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ObjectId_var id_from_reference = third_poa->reference_to_id (obj.in ());

    string = PortableServer::ObjectId_to_string (id_from_reference.in ());
    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    ACE_ASSERT (id_from_reference.in () == id.in ());

    third_poa->activate_object_with_id (id.in (),
                                        &servant);

    obj = third_poa->id_to_reference (id.in ());

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ServantBase_var servant_from_reference =
      third_poa->reference_to_servant (obj.in ());

    PortableServer::ServantBase_var servant_from_id =
      third_poa->id_to_servant (id.in ());

    if (servant_from_reference.in () != servant_from_id.in ()
        || servant_from_reference.in () != &servant)
      {
        ACE_ERROR ((LM_ERROR,
                    "Mismatched servant_from_reference, "
                    "servant_from_id and &servant\n"));
      }

    obj = third_poa->servant_to_reference (&servant);

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    obj = servant._this ();

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ObjectId_var id_from_servant = third_poa->servant_to_id (&servant);

    string = PortableServer::ObjectId_to_string (id_from_servant.in ());
    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    ACE_ASSERT (id_from_servant.in () == id.in ());

    third_poa->deactivate_object (id.in ());

    if (perform_deactivation_test)
      {
        third_poa->activate_object_with_id (id.in (),
                                            &servant);

        servant_from_reference = third_poa->reference_to_servant (obj.in ());

        ACE_ASSERT (servant_from_reference.in () == &servant);

        third_poa->deactivate_object (id.in ());
      }
  }

  {
    test_i servant (forth_poa);
    PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId ("hello");

    CORBA::Object_var obj = forth_poa->create_reference_with_id (id.in (),
                                                                 "IDL:test:1.0");

    CORBA::String_var string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ObjectId_var id_from_reference = forth_poa->reference_to_id (obj.in ());

    string = PortableServer::ObjectId_to_string (id_from_reference.in ());
    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    ACE_ASSERT (id_from_reference.in () == id.in ());

    forth_poa->activate_object_with_id (id.in (),
                                        &servant);

    obj = forth_poa->id_to_reference (id.in ());

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ServantBase_var servant_from_reference =
      forth_poa->reference_to_servant (obj.in ());

    PortableServer::ServantBase_var servant_from_id =
      forth_poa->id_to_servant (id.in ());

    if (servant_from_reference.in () != servant_from_id.in ()
        || servant_from_reference.in () != &servant)
      {
        ACE_ERROR ((LM_ERROR,
                    "Mismatched servant_from_reference, "
                    "servant_from_id and &servant\n"));
      }

    forth_poa->deactivate_object (id.in ());

    if (perform_deactivation_test)
      {
        forth_poa->activate_object_with_id (id.in (),
                                            &servant);

        servant_from_reference = forth_poa->reference_to_servant (obj.in ());

        ACE_ASSERT (servant_from_reference.in () == &servant);

        forth_poa->deactivate_object (id.in ());
      }
  }
}