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 83 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
 

Definition at line 127 of file DII_Reply_Dispatcher.cpp.

References TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR, and TAO_ENCAP_BYTE_ORDER.

00130   : TAO_Asynch_Reply_Dispatcher_Base (orb_core),
00131     db_ (sizeof buf_,
00132          ACE_Message_Block::MB_DATA,
00133          this->buf_,
00134          orb_core->input_cdr_buffer_allocator (),
00135          orb_core->locking_strategy (),
00136          ACE_Message_Block::DONT_DELETE,
00137          orb_core->input_cdr_dblock_allocator ()),
00138     reply_cdr_ (&db_,
00139                 ACE_Message_Block::DONT_DELETE,
00140                 TAO_ENCAP_BYTE_ORDER,
00141                 TAO_DEF_GIOP_MAJOR,
00142                 TAO_DEF_GIOP_MINOR,
00143                 orb_core),
00144     callback_ (callback)
00145 {
00146 }

TAO_DII_Asynch_Reply_Dispatcher::~TAO_DII_Asynch_Reply_Dispatcher void   )  [virtual]
 

Definition at line 148 of file DII_Reply_Dispatcher.cpp.

References CORBA::release().

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


Member Function Documentation

void TAO_DII_Asynch_Reply_Dispatcher::connection_closed void   )  [virtual]
 

Implements TAO_Asynch_Reply_Dispatcher_Base.

Definition at line 209 of file DII_Reply_Dispatcher.cpp.

References CORBA::Request::_tao_reply_stub(), TAO_Asynch_Reply_Dispatcher_Base::decr_refcount(), TAO_debug_level, and TAO_PLUGGABLE_MESSAGE_SYSTEM_EXCEPTION.

00210 {
00211   try
00212     {
00213       // Generate a fake exception....
00214       CORBA::COMM_FAILURE comm_failure (0,
00215                                         CORBA::COMPLETED_MAYBE);
00216 
00217       TAO_OutputCDR out_cdr;
00218 
00219       comm_failure._tao_encode (out_cdr);
00220 
00221       // Turn into an output CDR
00222       TAO_InputCDR cdr (out_cdr);
00223       CORBA::Request::_tao_reply_stub (
00224           this->reply_cdr_,
00225           this->callback_,
00226           TAO_PLUGGABLE_MESSAGE_SYSTEM_EXCEPTION);
00227     }
00228   catch (const CORBA::Exception& ex)
00229     {
00230       if (TAO_debug_level >= 4)
00231         {
00232           ex._tao_print_exception (
00233             "DII_Asynch_Reply_Dispacher::connection_closed");
00234         }
00235     }
00236 
00237   (void) this->decr_refcount ();
00238 }

int TAO_DII_Asynch_Reply_Dispatcher::dispatch_reply TAO_Pluggable_Reply_Params param  )  [virtual]
 

The Reply_Dispatcher methods.

Implements TAO_Asynch_Reply_Dispatcher_Base.

Definition at line 155 of file DII_Reply_Dispatcher.cpp.

References CORBA::Request::_tao_reply_stub(), ACE_BIT_DISABLED, ACE_DEBUG, ACE_TEXT, ACE_InputCDR::clone_from(), TAO_Asynch_Reply_Dispatcher_Base::decr_refcount(), ACE_Data_Block::flags(), TAO_Pluggable_Reply_Params::input_cdr_, LM_DEBUG, ACE_Data_Block::release(), TAO_Pluggable_Reply_Params_Base::reply_status_, TAO_Pluggable_Reply_Params_Base::svc_ctx_, and TAO_debug_level.

00157 {
00158   this->reply_status_ = params.reply_status_;
00159 
00160   // Transfer the <params.input_cdr_>'s content to this->reply_cdr_
00161   ACE_Data_Block *db =
00162     this->reply_cdr_.clone_from (*params.input_cdr_);
00163 
00164   // See whether we need to delete the data block by checking the
00165   // flags. We cannot be happy that we initally allocated the
00166   // datablocks of the stack. If this method is called twice, as is in
00167   // some cases where the same invocation object is used to make two
00168   // invocations like forwarding, the release becomes essential.
00169   if (ACE_BIT_DISABLED (db->flags (),
00170                         ACE_Message_Block::DONT_DELETE))
00171     db->release ();
00172 
00173   // Steal the buffer, that way we don't do any unnecesary copies of
00174   // this data.
00175   CORBA::ULong max = params.svc_ctx_.maximum ();
00176   CORBA::ULong len = params.svc_ctx_.length ();
00177   IOP::ServiceContext* context_list = params.svc_ctx_.get_buffer (1);
00178   this->reply_service_info_.replace (max, len, context_list, 1);
00179 
00180   if (TAO_debug_level >= 4)
00181     {
00182       ACE_DEBUG ((LM_DEBUG,
00183                   ACE_TEXT ("(%P | %t):")
00184                   ACE_TEXT ("TAO_DII_Asynch_Reply_Dispatcher::dispatch_reply: status = %d\n"),
00185                   this->reply_status_));
00186     }
00187 
00188   try
00189     {
00190       // Call the handler with the reply data.
00191       CORBA::Request::_tao_reply_stub (this->reply_cdr_,
00192                                        this->callback_,
00193                                        this->reply_status_);
00194     }
00195   catch (const CORBA::Exception& ex)
00196     {
00197       if (TAO_debug_level >= 4)
00198         {
00199           ex._tao_print_exception ("Exception during reply handler");
00200         }
00201     }
00202   // This was dynamically allocated. Now the job is done.
00203   (void) this->decr_refcount ();
00204 
00205   return 1;
00206 }


Member Data Documentation

char TAO_DII_Asynch_Reply_Dispatcher::buf_[ACE_CDR::DEFAULT_BUFSIZE] [private]
 

The buffer that is used to initialise the data block.

Reimplemented from TAO_Asynch_Reply_Dispatcher_Base.

Definition at line 99 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 109 of file DII_Reply_Dispatcher.h.

ACE_Data_Block TAO_DII_Asynch_Reply_Dispatcher::db_ [private]
 

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

Reimplemented from TAO_Asynch_Reply_Dispatcher_Base.

Definition at line 103 of file DII_Reply_Dispatcher.h.

TAO_InputCDR TAO_DII_Asynch_Reply_Dispatcher::reply_cdr_ [private]
 

CDR stream for reading the input.

Reimplemented from TAO_Asynch_Reply_Dispatcher_Base.

Definition at line 106 of file DII_Reply_Dispatcher.h.


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 13:37:46 2008 for TAO_DynamicInterface by doxygen 1.3.6