GIOP_Message_Generator_Parser.cpp

Go to the documentation of this file.
00001 // GIOP_Message_Generator_Parser.cpp,v 1.16 2006/03/29 06:26:34 frehberger Exp
00002 
00003 #include "tao/GIOP_Message_Generator_Parser.h"
00004 #include "tao/Pluggable_Messaging_Utils.h"
00005 #include "tao/GIOP_Utils.h"
00006 #include "tao/debug.h"
00007 #include "tao/CDR.h"
00008 #include "ace/Log_Msg.h"
00009 
00010 
00011 ACE_RCSID (tao,
00012            GIOP_Message_Gen_Parser,
00013            "GIOP_Message_Generator_Parser.cpp,v 1.16 2006/03/29 06:26:34 frehberger Exp")
00014 
00015 
00016 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00017 
00018 TAO_GIOP_Message_Generator_Parser::~TAO_GIOP_Message_Generator_Parser (void)
00019 {
00020 }
00021 
00022 int
00023 TAO_GIOP_Message_Generator_Parser::parse_reply (
00024     TAO_InputCDR &stream,
00025     TAO_Pluggable_Reply_Params &params)
00026 {
00027 
00028   // Read the request id
00029   if (!stream.read_ulong (params.request_id_))
00030     {
00031       if (TAO_debug_level)
00032         {
00033           ACE_ERROR ((LM_ERROR,
00034                       ACE_TEXT ("TAO (%P|%t) : TAO_GIOP_Message_Generator_Parser::parse_reply :")
00035                       ACE_TEXT ("extracting request id\n")));
00036         }
00037     }
00038 
00039   // and the reply status type.  status can be NO_EXCEPTION,
00040   // SYSTEM_EXCEPTION, USER_EXCEPTION, LOCATION_FORWARD,
00041   // LOCATION_FORWARD_PERM
00042   CORBA::ULong rep_stat = 0;
00043   if (!stream.read_ulong (rep_stat))
00044     {
00045       if (TAO_debug_level > 0)
00046         ACE_ERROR ((LM_ERROR,
00047                     ACE_TEXT ("TAO (%P|%t) : TAO_GIOP_Message_Generator_Parser::parse_reply, ")
00048                     ACE_TEXT ("extracting reply status\n")));
00049       return -1;
00050     }
00051 
00052 
00053   // Pass the right Pluggable interface code to the transport layer
00054   switch (rep_stat)
00055     {
00056       // Request completed successfully
00057     case TAO_GIOP_NO_EXCEPTION:
00058       params.reply_status_ =
00059         TAO_PLUGGABLE_MESSAGE_NO_EXCEPTION;
00060       break;
00061 
00062       // Request terminated with user exception
00063     case TAO_GIOP_USER_EXCEPTION:
00064       params.reply_status_ =
00065         TAO_PLUGGABLE_MESSAGE_USER_EXCEPTION;
00066       break;
00067       // Request terminated with system exception
00068     case TAO_GIOP_SYSTEM_EXCEPTION:
00069       params.reply_status_ =
00070         TAO_PLUGGABLE_MESSAGE_SYSTEM_EXCEPTION;
00071       break;
00072       // Reply is a location forward type
00073     case TAO_GIOP_LOCATION_FORWARD:
00074       params.reply_status_ =
00075         TAO_PLUGGABLE_MESSAGE_LOCATION_FORWARD;
00076       break;
00077       // Reply is a location forward perm type
00078      // LOCATION_FORWARD_PERM is only allowed in context of
00079      // FaultTolerant featured requests and requires PortableGroup
00080      // features in forwarded object and service context
00081     case TAO_GIOP_LOCATION_FORWARD_PERM:
00082       params.reply_status_ =
00083         TAO_PLUGGABLE_MESSAGE_LOCATION_FORWARD_PERM;
00084       break;
00085       // Reply is a location forward type
00086     case TAO_GIOP_NEEDS_ADDRESSING_MODE:
00087       params.reply_status_ =
00088         TAO_PLUGGABLE_MESSAGE_NEEDS_ADDRESSING_MODE;
00089       break;
00090     default:
00091       if (TAO_debug_level > 0)
00092         ACE_DEBUG ((LM_DEBUG,
00093                     ACE_TEXT ("(%N|%l) Unknown reply status \n")));
00094     }
00095 
00096   return 0;
00097 }
00098 
00099 
00100 int
00101 TAO_GIOP_Message_Generator_Parser::parse_locate_reply (
00102     TAO_InputCDR &cdr,
00103     TAO_Pluggable_Reply_Params &params)
00104 {
00105   // Read the request id
00106   if (!cdr.read_ulong (params.request_id_))
00107     {
00108       if (TAO_debug_level > 0)
00109         ACE_ERROR ((LM_ERROR,
00110                     ACE_TEXT ("TAO (%P|%t|%N|%l):parse_locate_reply, ")
00111                     ACE_TEXT ("extracting request id\n")));
00112 
00113       return -1;
00114     }
00115 
00116   // and the reply status type.  status can be NO_EXCEPTION,
00117   // SYSTEM_EXCEPTION, USER_EXCEPTION, LOCATION_FORWARD
00118   // LOCATION_FORWARD_PERM
00119 
00120   // Please note here that we are NOT converting to the Pluggable
00121   // messaging layer exception as this is GIOP specific. Not many
00122   // messaging protocols have the locate_* messages.
00123   if (!cdr.read_ulong (params.reply_status_))
00124     {
00125       if (TAO_debug_level > 0)
00126         ACE_ERROR ((LM_ERROR,
00127                     ACE_TEXT ("TAO N|(%P|%t|l) parse_locate_reply, ")
00128                     ACE_TEXT ("extracting reply  status\n")));
00129 
00130       return -1;
00131     }
00132 
00133   return 0;
00134 
00135 }
00136 
00137 
00138 int
00139 TAO_GIOP_Message_Generator_Parser::is_ready_for_bidirectional (void)
00140 {
00141   return 0;
00142 }
00143 
00144 void
00145 TAO_GIOP_Message_Generator_Parser::marshal_reply_status (
00146     TAO_OutputCDR &output,
00147     TAO_Pluggable_Reply_Params_Base &reply
00148   )
00149 {
00150   switch (reply.reply_status_)
00151     {
00152     case TAO_PLUGGABLE_MESSAGE_NO_EXCEPTION:
00153       output.write_ulong (TAO_GIOP_NO_EXCEPTION);
00154       break;
00155     case TAO_PLUGGABLE_MESSAGE_LOCATION_FORWARD:
00156       output.write_ulong (TAO_GIOP_LOCATION_FORWARD);
00157       break;
00158     case TAO_PLUGGABLE_MESSAGE_SYSTEM_EXCEPTION:
00159       output.write_ulong (TAO_GIOP_SYSTEM_EXCEPTION);
00160       break;
00161     case TAO_PLUGGABLE_MESSAGE_USER_EXCEPTION:
00162       output.write_ulong (TAO_GIOP_USER_EXCEPTION);
00163       break;
00164     default:
00165       // Some other specific exception
00166       output.write_ulong (reply.reply_status_);
00167       break;
00168     }
00169 }
00170 
00171 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 11:54:12 2006 for TAO by doxygen 1.3.6