Public Member Functions | Private Attributes

TAO_DII_Asynch_Reply_Dispatcher Class Reference

Reply dispatcher for DII asynch requests. More...

#include <DII_Reply_Dispatcher.h>

Inheritance diagram for TAO_DII_Asynch_Reply_Dispatcher:
Inheritance graph
[legend]
Collaboration diagram for TAO_DII_Asynch_Reply_Dispatcher:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TAO_DII_Asynch_Reply_Dispatcher (const Messaging::ReplyHandler_ptr callback, TAO_ORB_Core *orb_core)
virtual ~TAO_DII_Asynch_Reply_Dispatcher (void)
virtual int dispatch_reply (TAO_Pluggable_Reply_Params &param)
 The Reply_Dispatcher methods.
virtual void connection_closed (void)

Private Attributes

char buf_ [ACE_CDR::DEFAULT_BUFSIZE]
 The buffer that is used to initialise the data block.
ACE_Data_Block db_
TAO_InputCDR reply_cdr_
 CDR stream for reading the input.
const Messaging::ReplyHandler_ptr callback_
 Where the reply needs to go.

Detailed Description

Reply dispatcher for DII asynch requests.

Definition at line 81 of file DII_Reply_Dispatcher.h.


Constructor & Destructor Documentation

TAO_DII_Asynch_Reply_Dispatcher::TAO_DII_Asynch_Reply_Dispatcher ( const Messaging::ReplyHandler_ptr  callback,
TAO_ORB_Core orb_core 
)
TAO_DII_Asynch_Reply_Dispatcher::~TAO_DII_Asynch_Reply_Dispatcher ( void   )  [virtual]

Definition at line 149 of file DII_Reply_Dispatcher.cpp.

{
  // this was handed to us by the caller.
  CORBA::release(callback_);
}


Member Function Documentation

void TAO_DII_Asynch_Reply_Dispatcher::connection_closed ( void   )  [virtual]

The used for the pending reply has been closed. No reply is expected.

Todo:
If the connection was closed due to a CloseConnection message then we could re-issue the request instead of raising the exception, it would a matter of simply adding a boolean argument to this function.

Implements TAO_Reply_Dispatcher.

Definition at line 211 of file DII_Reply_Dispatcher.cpp.

{
  try
    {
      // Generate a fake exception....
      CORBA::COMM_FAILURE comm_failure (0,
                                        CORBA::COMPLETED_MAYBE);

      TAO_OutputCDR out_cdr;

      comm_failure._tao_encode (out_cdr);

      // Turn into an output CDR
      TAO_InputCDR cdr (out_cdr);
      CORBA::Request::_tao_reply_stub (
          this->reply_cdr_,
          this->callback_,
          GIOP::SYSTEM_EXCEPTION);
    }
  catch (const CORBA::Exception& ex)
    {
      if (TAO_debug_level >= 4)
        {
          ex._tao_print_exception (
            "DII_Asynch_Reply_Dispacher::connection_closed");
        }
    }

  this->intrusive_remove_ref (this);
}

int TAO_DII_Asynch_Reply_Dispatcher::dispatch_reply ( TAO_Pluggable_Reply_Params param  )  [virtual]

The Reply_Dispatcher methods.

Implements TAO_Reply_Dispatcher.

Definition at line 156 of file DII_Reply_Dispatcher.cpp.

{
  this->reply_status_ = params.reply_status ();
  this->locate_reply_status_ = params.locate_reply_status ();

  // Transfer the <params.input_cdr_>'s content to this->reply_cdr_
  ACE_Data_Block *db =
    this->reply_cdr_.clone_from (*params.input_cdr_);

  // See whether we need to delete the data block by checking the
  // flags. We cannot be happy that we initally allocated the
  // datablocks of the stack. If this method is called twice, as is in
  // some cases where the same invocation object is used to make two
  // invocations like forwarding, the release becomes essential.
  if (ACE_BIT_DISABLED (db->flags (),
                        ACE_Message_Block::DONT_DELETE))
    db->release ();

  // Steal the buffer, that way we don't do any unnecesary copies of
  // this data.
  CORBA::ULong max = params.svc_ctx_.maximum ();
  CORBA::ULong len = params.svc_ctx_.length ();
  IOP::ServiceContext* context_list = params.svc_ctx_.get_buffer (1);
  this->reply_service_info_.replace (max, len, context_list, 1);

  if (TAO_debug_level >= 4)
    {
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("(%P | %t):")
                  ACE_TEXT ("TAO_DII_Asynch_Reply_Dispatcher::dispatch_reply: status = %d\n"),
                  this->reply_status_));
    }

  try
    {
      // Call the handler with the reply data.
      CORBA::Request::_tao_reply_stub (this->reply_cdr_,
                                       this->callback_,
                                       this->reply_status_);
    }
  catch (const CORBA::Exception& ex)
    {
      if (TAO_debug_level >= 4)
        {
          ex._tao_print_exception ("Exception during reply handler");
        }
    }
  // This was dynamically allocated. Now the job is done.
  this->intrusive_remove_ref (this);

  return 1;
}


Member Data Documentation

The buffer that is used to initialise the data block.

Reimplemented from TAO_Asynch_Reply_Dispatcher_Base.

Definition at line 97 of file DII_Reply_Dispatcher.h.

const Messaging::ReplyHandler_ptr TAO_DII_Asynch_Reply_Dispatcher::callback_ [private]

Where the reply needs to go.

Definition at line 107 of file DII_Reply_Dispatcher.h.

Datablock that is created on the stack to initialise the CDR stream underneath.

Reimplemented from TAO_Asynch_Reply_Dispatcher_Base.

Definition at line 101 of file DII_Reply_Dispatcher.h.

CDR stream for reading the input.

Reimplemented from TAO_Asynch_Reply_Dispatcher_Base.

Definition at line 104 of file DII_Reply_Dispatcher.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines