void
Client_Request_Interceptor::receive_other (
    PortableInterceptor::ClientRequestInfo_ptr ri)
{
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("CRI: in receive_other\n")));

  CORBA::Boolean response_expected =
    ri->response_expected ();

  // Oneway
  if (!response_expected)
    return;

  PortableInterceptor::ReplyStatus reply_status;

  try
    {
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("CRI: in receive_other, before reply_status\n")));

      reply_status = ri->reply_status ();
      ACE_UNUSED_ARG (reply_status);
    }
  catch(CORBA::BAD_INV_ORDER const &e)
    {
      e._tao_print_exception ("CRI: exception");
    }

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("CRI: in receive_other, after reply_status\n")));
}
void
Client_Request_Interceptor::send_request (
    PortableInterceptor::ClientRequestInfo_ptr ri)
{
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("CRI: in send_request\n")));

  ++this->request_count_;

  CORBA::Boolean response_expected =
    ri->response_expected ();

  if (!response_expected)   // A one-way request.
    return;

  // Request 1 -- non-forwarded
  // Request 2 -- forwarded by this interception point.
  // Request 3 -- non-forwarded

  if (this->request_count_ == 2)
    {
      if (CORBA::is_nil (this->orb_.in ()))
        {
          int argc = 0;
          char **const argv= 0;
          this->orb_ = CORBA::ORB_init (argc,
                                        argv,
                                        this->orb_id_.in ());
        }

      CORBA::Object_var forward =
        this->orb_->string_to_object (this->forward_str_.in ());

      CORBA::String_var forward_str =
        this->orb_->object_to_string (forward.in ());

      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("CRI: request %d will be forwarded via send_request()\n"),
                  this->request_count_));

      // Notice that this is not a permanent forward.
      throw PortableInterceptor::ForwardRequest (forward.in ());
    }
}
  void
  Client_Request_Interceptor::send_request (PortableInterceptor::ClientRequestInfo_ptr ri)
  {
    // Test TC
    test_transport_current (ACE_TEXT ("send_request"));

    CORBA::Boolean const response_expected =
      ri->response_expected ();

    // Oneway?
    if (response_expected)
      ACE_DEBUG ((LM_DEBUG, ACE_TEXT("CRI    (%P|%t) Sending a two-way\n")));
    else
      ACE_DEBUG ((LM_DEBUG, ACE_TEXT("CRI    (%P|%t) Sending a one-way\n")));

    // Make the context to send the context to the target
    IOP::ServiceContext sc;
    sc.context_id = Test::Transport::CurrentTest::ContextTag;

    // How long can a number really get?
    char temp[32];
    {
      ACE_GUARD (TAO_SYNCH_MUTEX, monitor, this->lock_);

      ACE_OS::sprintf (temp, "%ld", this->requestID_);
      ++this->requestID_;
    }

    CORBA::ULong string_len = ACE_OS::strlen (temp) + 1;
    CORBA::Octet *buf = CORBA::OctetSeq::allocbuf (string_len);
    ACE_OS::strcpy (reinterpret_cast <char *> (buf), temp);

    sc.context_data.replace (string_len, string_len, buf, 1);

    // Add this context to the service context list.
    ri->add_request_service_context (sc, 0);
  }