Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_GIOP_Message_Base Class Reference

Definitions of the GIOP specific stuff. More...

#include <GIOP_Message_Base.h>

Inheritance diagram for TAO_GIOP_Message_Base:

Inheritance graph
[legend]
Collaboration diagram for TAO_GIOP_Message_Base:

Collaboration graph
[legend]
List of all members.

Public Methods

 TAO_GIOP_Message_Base (TAO_ORB_Core *orb_core, size_t input_cdr_size=ACE_CDR::DEFAULT_BUFSIZE)
 Constructor. More...

virtual ~TAO_GIOP_Message_Base (void)
 Dtor. More...

virtual void init (CORBA::Octet major, CORBA::Octet minor)
 Initialize the underlying state object based on the <major> and <minor> revision numbers. More...

virtual void reset (void)
 Reset the messaging the object. More...

virtual int generate_request_header (TAO_Operation_Details &op, TAO_Target_Specification &spec, TAO_OutputCDR &cdr)
 Write the RequestHeader in to the <cdr> stream. The underlying implementation of the mesaging should do the right thing. More...

virtual int generate_locate_request_header (TAO_Operation_Details &op, TAO_Target_Specification &spec, TAO_OutputCDR &cdr)
 Write the RequestHeader in to the <cdr> stream. More...

virtual int generate_reply_header (TAO_OutputCDR &cdr, TAO_Pluggable_Reply_Params_Base &params)
 Write the reply header. More...

virtual int read_message (TAO_Transport *transport, int block=0, ACE_Time_Value *max_wait_time=0)
 This method reads the message on the connection. Returns 0 when there is short read on the connection. Returns 1 when the full message is read and handled. Returns -1 on errors. If <block> is 1, then reply is read in a blocking manner. More...

virtual int format_message (TAO_OutputCDR &cdr)
 Format the message. As we have not written the message length in the header, we make use of this oppurtunity to insert and format the message. More...

virtual int process_request_message (TAO_Transport *transport, TAO_Queued_Data *qd)
 Process the request message that we have received on the connection. More...


Detailed Description

Definitions of the GIOP specific stuff.

This class will hold the specific details common to all the GIOP versions. Some of them which are here may be shifted if things start changing between versions. This class uses the TAO_GIOP_Message_Reactive_Handler to read and parse messages.

Definition at line 43 of file GIOP_Message_Base.h.


Constructor & Destructor Documentation

TAO_GIOP_Message_Base::TAO_GIOP_Message_Base TAO_ORB_Core   orb_core,
size_t    input_cdr_size = ACE_CDR::DEFAULT_BUFSIZE
 

Constructor.

Definition at line 23 of file GIOP_Message_Base.cpp.

00025   : orb_core_ (orb_core),
00026     message_state_ (orb_core,
00027                     this)
00028 {
00029 
00030 }

TAO_GIOP_Message_Base::~TAO_GIOP_Message_Base void    [virtual]
 

Dtor.

Definition at line 33 of file GIOP_Message_Base.cpp.

00034 {
00035 
00036 }


Member Function Documentation

int TAO_GIOP_Message_Base::format_message TAO_OutputCDR   cdr [virtual]
 

Format the message. As we have not written the message length in the header, we make use of this oppurtunity to insert and format the message.

Implements TAO_Pluggable_Messaging.

Definition at line 219 of file GIOP_Message_Base.cpp.

References ACE_OutputCDR::begin, ACE_OutputCDR::buffer, ACE_CDR::consolidate, ACE_Message_Block::cont, ACE_OutputCDR::do_byte_swap, ACE_Message_Block::rd_ptr, ACE_CDR::swap_4, TAO_GIOP_MESSAGE_HEADER_LEN, TAO_GIOP_MESSAGE_SIZE_OFFSET, and ACE_OutputCDR::total_length.

00220 {
00221   // Ptr to first buffer.
00222   char *buf = (char *) stream.buffer ();
00223 
00224   // Length of all buffers.
00225   size_t total_len =
00226     stream.total_length ();
00227 
00228   // NOTE: Here would also be a fine place to calculate a digital
00229   // signature for the message and place it into a preallocated slot
00230   // in the "ServiceContext".  Similarly, this is a good spot to
00231   // encrypt messages (or just the message bodies) if that's needed in
00232   // this particular environment and that isn't handled by the
00233   // networking infrastructure (e.g., IPSEC).
00234 
00235   CORBA::ULong bodylen = ACE_static_cast(CORBA::ULong,
00236                            total_len - TAO_GIOP_MESSAGE_HEADER_LEN);
00237 
00238 #if !defined (ACE_ENABLE_SWAP_ON_WRITE)
00239   *ACE_reinterpret_cast (CORBA::ULong *, buf +
00240                          TAO_GIOP_MESSAGE_SIZE_OFFSET) = bodylen;
00241 #else
00242   if (!stream.do_byte_swap ())
00243     *ACE_reinterpret_cast (CORBA::ULong *,
00244                            buf + TAO_GIOP_MESSAGE_SIZE_OFFSET) = bodylen;
00245   else
00246     ACE_CDR::swap_4 (ACE_reinterpret_cast (char *,
00247                                            &bodylen),
00248                      buf + TAO_GIOP_MESSAGE_SIZE_OFFSET);
00249 #endif /* ACE_ENABLE_SWAP_ON_WRITE */
00250 
00251   if (TAO_debug_level > 2)
00252     {
00253       // Check whether the output cdr stream is build up of multiple
00254       // messageblocks. If so, consolidate them to one block that can be
00255       // dumped
00256       ACE_Message_Block* consolidated_block = 0;
00257       if (stream.begin()->cont () != 0)
00258         {
00259           consolidated_block = new ACE_Message_Block;
00260           ACE_CDR::consolidate (consolidated_block, stream.begin ());
00261           buf = (char *) (consolidated_block->rd_ptr ());
00262         }
00263       ///
00264       this->dump_msg ("send",
00265                       ACE_reinterpret_cast (u_char *,
00266                                             buf),
00267                       total_len);
00268 
00269       //
00270       delete consolidated_block;
00271       consolidated_block = 0;
00272       //
00273     }
00274 
00275   return 0;
00276 }

int TAO_GIOP_Message_Base::generate_locate_request_header TAO_Operation_Details   op,
TAO_Target_Specification   spec,
TAO_OutputCDR   cdr
[virtual]
 

Write the RequestHeader in to the <cdr> stream.

Implements TAO_Pluggable_Messaging.

Definition at line 100 of file GIOP_Message_Base.cpp.

References ACE_ERROR, ACE_LIB_TEXT, ACE_OutputCDR::get_version, LM_ERROR, TAO_Operation_Details::request_id, TAO_GIOP_LOCATEREQUEST, and TAO_GIOP_Message_Generator_Parser::write_locate_request_header.

00105 {
00106   // Get a parser for us
00107   TAO_GIOP_Message_Generator_Parser *generator_parser = 0;
00108 
00109   CORBA::Octet major, minor;
00110 
00111   cdr.get_version (major, minor);
00112 
00113   // Get the state information that we need to use
00114   this->set_state (major,
00115                    minor,
00116                    generator_parser);
00117 
00118   // Write the GIOP header first
00119   if (!this->write_protocol_header (TAO_GIOP_LOCATEREQUEST,
00120                                     cdr))
00121     {
00122       if (TAO_debug_level)
00123         ACE_ERROR ((LM_ERROR,
00124                     ACE_LIB_TEXT ("(%P|%t) Error in writing GIOP header \n")));
00125 
00126       return -1;
00127     }
00128 
00129   // Now call the implementation for the rest of the header
00130   if (!generator_parser->write_locate_request_header
00131       (op.request_id (),
00132        spec,
00133        cdr))
00134     {
00135       if (TAO_debug_level)
00136         ACE_ERROR ((LM_ERROR,
00137                     ACE_LIB_TEXT ("(%P|%t) Error in writing locate request header \n")));
00138 
00139 
00140       return -1;
00141 
00142     }
00143 
00144   return 0;
00145 }

int TAO_GIOP_Message_Base::generate_reply_header TAO_OutputCDR   cdr,
TAO_Pluggable_Reply_Params_Base   params
[virtual]
 

Write the reply header.

Implements TAO_Pluggable_Messaging.

Definition at line 148 of file GIOP_Message_Base.cpp.

References ACE_ANY_EXCEPTION, ACE_CATCHANY, ACE_DECLARE_NEW_CORBA_ENV, ACE_ENDTRY, ACE_ENV_ARG_PARAMETER, ACE_ERROR, ACE_LIB_TEXT, ACE_PRINT_EXCEPTION, ACE_TEXT, ACE_TRY, ACE_TRY_CHECK, ACE_OutputCDR::get_version, LM_ERROR, TAO_GIOP_REPLY, and TAO_GIOP_Message_Generator_Parser::write_reply_header.

00152 {
00153   // Get a parser for us
00154   TAO_GIOP_Message_Generator_Parser *generator_parser = 0;
00155 
00156   CORBA::Octet major, minor;
00157 
00158   cdr.get_version (major, minor);
00159 
00160   // Get the state information that we need to use
00161   this->set_state (major,
00162                    minor,
00163                    generator_parser);
00164 
00165   // Write the GIOP header first
00166   if (!this->write_protocol_header (TAO_GIOP_REPLY,
00167                                     cdr))
00168     {
00169       if (TAO_debug_level)
00170         ACE_ERROR ((LM_ERROR,
00171                     ACE_LIB_TEXT ("(%P|%t) Error in writing GIOP header \n")));
00172 
00173       return -1;
00174     }
00175 
00176   ACE_DECLARE_NEW_CORBA_ENV;
00177   ACE_TRY
00178     {
00179       // Now call the implementation for the rest of the header
00180       int result =
00181         generator_parser->write_reply_header (cdr,
00182                                               params
00183                                               ACE_ENV_ARG_PARAMETER);
00184       ACE_TRY_CHECK;
00185 
00186       if (!result)
00187         {
00188           if (TAO_debug_level > 4)
00189             ACE_ERROR ((LM_ERROR,
00190                         ACE_TEXT ("(%P|%t) Error in writing reply ")
00191                         ACE_TEXT ("header\n")));
00192 
00193           return -1;
00194         }
00195     }
00196   ACE_CATCHANY
00197     {
00198       if (TAO_debug_level > 4)
00199         ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
00200                              "TAO_GIOP_Message_Base::generate_reply_header");
00201 
00202       return -1;
00203     }
00204   ACE_ENDTRY;
00205 
00206   return 0;
00207 }

int TAO_GIOP_Message_Base::generate_request_header TAO_Operation_Details   op,
TAO_Target_Specification   spec,
TAO_OutputCDR   cdr
[virtual]
 

Write the RequestHeader in to the <cdr> stream. The underlying implementation of the mesaging should do the right thing.

Implements TAO_Pluggable_Messaging.

Definition at line 55 of file GIOP_Message_Base.cpp.

References ACE_ERROR, ACE_LIB_TEXT, ACE_OutputCDR::get_version, LM_ERROR, TAO_GIOP_REQUEST, and TAO_GIOP_Message_Generator_Parser::write_request_header.

00060 {
00061   // Get a parser for us
00062   TAO_GIOP_Message_Generator_Parser *generator_parser = 0;
00063 
00064   CORBA::Octet major, minor;
00065 
00066   cdr.get_version (major, minor);
00067 
00068   // Get the state information that we need to use
00069   this->set_state (major,
00070                    minor,
00071                    generator_parser);
00072 
00073   // Write the GIOP header first
00074   if (!this->write_protocol_header (TAO_GIOP_REQUEST,
00075                                     cdr))
00076     {
00077       if (TAO_debug_level)
00078         ACE_ERROR ((LM_ERROR,
00079                     ACE_LIB_TEXT ("(%P|%t) Error in writing GIOP header \n")));
00080 
00081       return -1;
00082     }
00083 
00084   // Now call the implementation for the rest of the header
00085   if (!generator_parser->write_request_header (op,
00086                                                spec,
00087                                                cdr))
00088     {
00089       if (TAO_debug_level)
00090         ACE_ERROR ((LM_ERROR,
00091                     ACE_LIB_TEXT ("(%P|%t) Error in writing request header \n")));
00092 
00093       return -1;
00094     }
00095 
00096   return 0;
00097 }

void TAO_GIOP_Message_Base::init CORBA::Octet    major,
CORBA::Octet    minor
[virtual]
 

Initialize the underlying state object based on the <major> and <minor> revision numbers.

Implements TAO_Pluggable_Messaging.

Definition at line 40 of file GIOP_Message_Base.cpp.

00042 {
00043   // Set the state
00044   // this->set_state (major, minor);
00045 }

int TAO_GIOP_Message_Base::process_request_message TAO_Transport   transport,
TAO_Queued_Data   qd
[virtual]
 

Process the request message that we have received on the connection.

Implements TAO_Pluggable_Messaging.

Definition at line 315 of file GIOP_Message_Base.cpp.

References ACE_BIT_ENABLED, TAO_Transport::assign_translators, ACE_Message_Block::base, TAO_Queued_Data::byte_order_, ACE_Message_Block::data_block, ACE_CDR::DEFAULT_BUFSIZE, ACE_Message_Block::DONT_DELETE, ACE_Data_Block::duplicate, ACE_Message_Block::length, TAO_Queued_Data::major_version_, ACE_OS_String::memset, ACE_Message_Block::Message_Flags, TAO_Queued_Data::minor_version_, TAO_Queued_Data::msg_block_, TAO_Queued_Data::msg_type_, ACE_Message_Block::rd_ptr, ACE_Message_Block::self_flags, TAO_ENCAP_BYTE_ORDER, TAO_GIOP_MESSAGE_HEADER_LEN, TAO_PLUGGABLE_MESSAGE_LOCATEREQUEST, TAO_PLUGGABLE_MESSAGE_REQUEST, and ACE_Message_Block::wr_ptr.

00318 {
00319   // Set the upcall thread
00320   this->orb_core_->lf_strategy ().set_upcall_thread (this->orb_core_->leader_follower ());
00321 
00322   // Get a parser for us
00323   TAO_GIOP_Message_Generator_Parser *generator_parser = 0;
00324 
00325   // Get the state information that we need to use
00326   this->set_state (qd->major_version_,
00327                    qd->minor_version_,
00328                    generator_parser);
00329 
00330   // A buffer that we will use to initialise the CDR stream
00331   char repbuf[ACE_CDR::DEFAULT_BUFSIZE];
00332 
00333 #if defined(ACE_HAS_PURIFY)
00334   (void) ACE_OS::memset (repbuf,
00335                          '\0',
00336                          sizeof repbuf);
00337 #endif /* ACE_HAS_PURIFY */
00338 
00339   // Initialze an output CDR on the stack
00340   // NOTE: Dont jump to a conclusion as to why we are using the
00341   // inpout_cdr and hence the  global pool here. These pools will move
00342   // to the lanes anyway at some point of time. Further, it would have
00343   // been awesome to have this in TSS. But for some reason the cloning
00344   // that happens when the ORB gets flow controlled while writing a
00345   // reply is messing things up. We crash horribly. Doing this adds a
00346   // lock, we need to set things like this -- put stuff in TSS here
00347   // and transfer to global memory when we get flow controlled. We
00348   // need to work on the message block to get it right!
00349   TAO_OutputCDR output (repbuf,
00350                         sizeof repbuf,
00351                         TAO_ENCAP_BYTE_ORDER,
00352                         this->orb_core_->input_cdr_buffer_allocator (),
00353                         this->orb_core_->input_cdr_dblock_allocator (),
00354                         this->orb_core_->input_cdr_msgblock_allocator (),
00355                         this->orb_core_->orb_params ()->cdr_memcpy_tradeoff (),
00356                         qd->major_version_,
00357                         qd->minor_version_);
00358 
00359   // Get the read and write positions before we steal data.
00360   size_t rd_pos = qd->msg_block_->rd_ptr () - qd->msg_block_->base ();
00361   size_t wr_pos = qd->msg_block_->wr_ptr () - qd->msg_block_->base ();
00362   rd_pos += TAO_GIOP_MESSAGE_HEADER_LEN;
00363 
00364   if (TAO_debug_level > 0)
00365     this->dump_msg ("recv",
00366                     ACE_reinterpret_cast (u_char *,
00367                                           qd->msg_block_->rd_ptr ()),
00368                     qd->msg_block_->length ());
00369 
00370 
00371   // Create a input CDR stream. We do the following
00372   //  1 - If the incoming message block has a data block with a flag
00373   //      DONT_DELETE  (for the data block) we create an input CDR
00374   //      stream the same way.
00375   //  2 - If the incoming message block had a datablock from heap just
00376   //      use it by duplicating it and make the flag 0.
00377   // NOTE: We use the same data block in which we read the message and
00378   // we pass it on to the higher layers of the ORB. So we dont to any
00379   // copies at all here. The same is also done in the higher layers.
00380 
00381   ACE_Message_Block::Message_Flags flg = 0;
00382   ACE_Data_Block *db = 0;
00383 
00384   // Get the flag in the message block
00385   flg = qd->msg_block_->self_flags ();
00386 
00387   if (ACE_BIT_ENABLED (flg,
00388                        ACE_Message_Block::DONT_DELETE))
00389     {
00390       // Use the same datablock
00391       db = qd->msg_block_->data_block ();
00392     }
00393   else
00394     {
00395       // Use a duplicated datablock as the datablock has come off the
00396       // heap.
00397       db = qd->msg_block_->data_block ()->duplicate ();
00398     }
00399 
00400 
00401   TAO_InputCDR input_cdr (db,
00402                           flg,
00403                           rd_pos,
00404                           wr_pos,
00405                           qd->byte_order_,
00406                           qd->major_version_,
00407                           qd->minor_version_,
00408                           this->orb_core_);
00409 
00410   transport->assign_translators(&input_cdr,&output);
00411 
00412   // We know we have some request message. Check whether it is a
00413   // GIOP_REQUEST or GIOP_LOCATE_REQUEST to take action.
00414 
00415   // Once we send the InputCDR stream we need to just forget about
00416   // the stream and never touch that again for anything. We basically
00417   // loose ownership of the data_block.
00418 
00419   switch (qd->msg_type_)
00420     {
00421     case TAO_PLUGGABLE_MESSAGE_REQUEST:
00422       // Should be taken care by the state specific invocations. They
00423       // could raise an exception or write things in the output CDR
00424       // stream
00425       return this->process_request (transport,
00426                                     input_cdr,
00427                                     output,
00428                                     generator_parser);
00429 
00430     case TAO_PLUGGABLE_MESSAGE_LOCATEREQUEST:
00431       return this->process_locate_request (transport,
00432                                            input_cdr,
00433                                            output,
00434                                            generator_parser);
00435     default:
00436       return -1;
00437     }
00438 }

int TAO_GIOP_Message_Base::read_message TAO_Transport   transport,
int    block = 0,
ACE_Time_Value   max_wait_time = 0
[virtual]
 

This method reads the message on the connection. Returns 0 when there is short read on the connection. Returns 1 when the full message is read and handled. Returns -1 on errors. If <block> is 1, then reply is read in a blocking manner.

Implements TAO_Pluggable_Messaging.

Definition at line 211 of file GIOP_Message_Base.cpp.

00214 {
00215   return 0;
00216 }

void TAO_GIOP_Message_Base::reset void    [virtual]
 

Reset the messaging the object.

Definition at line 49 of file GIOP_Message_Base.cpp.

00050 {
00051   // no-op
00052 }


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:16:47 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002