TAO_Synch_Reply_Dispatcher Class Reference

Reply dispatcher for Synchronous Method Invocation (SMI)s. More...

#include <Synch_Reply_Dispatcher.h>

Inheritance diagram for TAO_Synch_Reply_Dispatcher:

Inheritance graph
[legend]
Collaboration diagram for TAO_Synch_Reply_Dispatcher:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_Synch_Reply_Dispatcher (TAO_ORB_Core *orb_core, IOP::ServiceContextList &sc)
 Constructor.

virtual ~TAO_Synch_Reply_Dispatcher (void)
 Destructor.

TAO_InputCDRreply_cdr (void)
 Return the reply CDR.

virtual int dispatch_reply (TAO_Pluggable_Reply_Params &params)
virtual void connection_closed (void)

Protected Attributes

IOP::ServiceContextListreply_service_info_
 The service context list.


Private Attributes

TAO_ORB_Coreorb_core_
 Cache the ORB Core pointer.

char buf_ [ACE_CDR::DEFAULT_BUFSIZE]
 The buffer that is used to initialise the data block.

ACE_Data_Block db_
TAO_InputCDR reply_cdr_

Detailed Description

Reply dispatcher for Synchronous Method Invocation (SMI)s.

Definition at line 44 of file Synch_Reply_Dispatcher.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Synch_Reply_Dispatcher::TAO_Synch_Reply_Dispatcher TAO_ORB_Core orb_core,
IOP::ServiceContextList sc
 

Constructor.

Definition at line 16 of file Synch_Reply_Dispatcher.cpp.

References TAO_LF_Invocation_Event::state_changed_i(), TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR, and TAO_ENCAP_BYTE_ORDER.

00020   : reply_service_info_ (sc),
00021     orb_core_ (orb_core),
00022     db_ (sizeof buf_,
00023          ACE_Message_Block::MB_DATA,
00024          this->buf_,
00025          this->orb_core_->input_cdr_buffer_allocator (),
00026          this->orb_core_->locking_strategy (),
00027          ACE_Message_Block::DONT_DELETE,
00028          this->orb_core_->input_cdr_dblock_allocator ()),
00029     reply_cdr_ (&db_,
00030                 ACE_Message_Block::DONT_DELETE,
00031                 TAO_ENCAP_BYTE_ORDER,
00032                 TAO_DEF_GIOP_MAJOR,
00033                 TAO_DEF_GIOP_MINOR,
00034                 orb_core)
00035 {
00036   // As a TAO_LF_Event we start in the active state....
00037   this->state_changed_i (TAO_LF_Event::LFS_ACTIVE);
00038 }

TAO_Synch_Reply_Dispatcher::~TAO_Synch_Reply_Dispatcher void   )  [virtual]
 

Destructor.

Definition at line 41 of file Synch_Reply_Dispatcher.cpp.

00042 {
00043 }


Member Function Documentation

void TAO_Synch_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 114 of file Synch_Reply_Dispatcher.cpp.

References TAO_LF_Event::state_changed().

00115 {
00116   this->state_changed (TAO_LF_Event::LFS_CONNECTION_CLOSED,
00117                        this->orb_core_->leader_follower ());
00118 }

int TAO_Synch_Reply_Dispatcher::dispatch_reply TAO_Pluggable_Reply_Params params  )  [virtual]
 

Dispatch the reply. Return 1 on sucess, -1 on error.

Todo:
Pluggable Messaging: this method has too many arguments, the "Right Thing"[tm] is for the Transport Object to create a "ClientReply" that encapsulates all we need to process a reply. Naturally it is possible that different messaging protocols implement different variants of such ClientReply class.

Implements TAO_Reply_Dispatcher.

Definition at line 52 of file Synch_Reply_Dispatcher.cpp.

References ACE_BIT_DISABLED, ACE_ERROR, ACE_InputCDR::clone_from(), TAO_InputCDR::clr_mb_flags(), ACE_Data_Block::flags(), TAO::unbounded_value_sequence< ServiceContext >::get_buffer(), TAO_Pluggable_Reply_Params::input_cdr_, TAO::unbounded_value_sequence< ServiceContext >::length(), LM_ERROR, TAO::unbounded_value_sequence< ServiceContext >::maximum(), ACE_Data_Block::release(), TAO::unbounded_value_sequence< ServiceContext >::replace(), TAO_Pluggable_Reply_Params_Base::reply_status_, TAO_LF_Event::state_changed(), TAO_Pluggable_Reply_Params_Base::svc_ctx_, and TAO_debug_level.

00054 {
00055   if (params.input_cdr_ == 0)
00056     return -1;
00057 
00058   this->reply_status_ = params.reply_status_;
00059 
00060   // Steal the buffer, that way we don't do any unnecesary copies of
00061   // this data.
00062   CORBA::ULong const max = params.svc_ctx_.maximum ();
00063   CORBA::ULong const len = params.svc_ctx_.length ();
00064   IOP::ServiceContext* context_list = params.svc_ctx_.get_buffer (1);
00065   this->reply_service_info_.replace (max, len, context_list, 1);
00066 
00067   // Must reset the message state, it is possible that the same reply
00068   // dispatcher is used because the request must be re-sent.
00069   //this->message_state_.reset (0);
00070 
00071   // Transfer the <params.input_cdr_>'s content to this->reply_cdr_
00072   if (ACE_BIT_DISABLED ((*params.input_cdr_).start()->data_block()->flags(),
00073                         ACE_Message_Block::DONT_DELETE))
00074   {
00075     // Data block is on the heap, so just duplicate it.
00076     this->reply_cdr_ = *params.input_cdr_;
00077     this->reply_cdr_.clr_mb_flags( ACE_Message_Block::DONT_DELETE );
00078   }
00079   else
00080   {
00081     ACE_Data_Block *db =
00082       this->reply_cdr_.clone_from (*params.input_cdr_);
00083 
00084     if (db == 0)
00085       {
00086         if (TAO_debug_level > 2)
00087           {
00088             ACE_ERROR ((LM_ERROR,
00089                         "TAO (%P|%t) - Synch_Reply_Dispatcher::dispatch_reply "
00090                         "clone_from failed \n"));
00091           }
00092         return -1;
00093       }
00094 
00095     // See whether we need to delete the data block by checking the
00096     // flags. We cannot be happy that we initally allocated the
00097     // datablocks of the stack. If this method is called twice, as is in
00098     // some cases where the same invocation object is used to make two
00099     // invocations like forwarding, the release becomes essential.
00100     if (ACE_BIT_DISABLED (db->flags (),
00101                           ACE_Message_Block::DONT_DELETE))
00102       {
00103         db->release ();
00104       }
00105   }
00106 
00107   this->state_changed (TAO_LF_Event::LFS_SUCCESS,
00108                        this->orb_core_->leader_follower ());
00109 
00110   return 1;
00111 }

TAO_InputCDR & TAO_Synch_Reply_Dispatcher::reply_cdr void   ) 
 

Return the reply CDR.

Definition at line 46 of file Synch_Reply_Dispatcher.cpp.

00047 {
00048   return this->reply_cdr_;
00049 }


Member Data Documentation

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

The buffer that is used to initialise the data block.

Definition at line 80 of file Synch_Reply_Dispatcher.h.

ACE_Data_Block TAO_Synch_Reply_Dispatcher::db_ [private]
 

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

Definition at line 84 of file Synch_Reply_Dispatcher.h.

TAO_ORB_Core* TAO_Synch_Reply_Dispatcher::orb_core_ [private]
 

Cache the ORB Core pointer.

Definition at line 70 of file Synch_Reply_Dispatcher.h.

TAO_InputCDR TAO_Synch_Reply_Dispatcher::reply_cdr_ [private]
 

CDR stream which has the reply information that needs to be demarshalled by the stubs

Definition at line 88 of file Synch_Reply_Dispatcher.h.

IOP::ServiceContextList& TAO_Synch_Reply_Dispatcher::reply_service_info_ [protected]
 

The service context list.

Definition at line 66 of file Synch_Reply_Dispatcher.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 12:23:49 2006 for TAO by doxygen 1.3.6