00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Pluggable_Messaging.h 00006 * 00007 * $Id: Pluggable_Messaging.h 79012 2007-07-24 14:21:05Z johnnyw $ 00008 * 00009 * Interface for the TAO pluggable messaging framework. 00010 * 00011 * 00012 * @author Balachandran Natarajan <bala@cs.wustl.edu> 00013 */ 00014 //============================================================================= 00015 00016 #ifndef TAO_PLUGGABLE_MESSAGING_H 00017 #define TAO_PLUGGABLE_MESSAGING_H 00018 00019 #include /**/ "ace/pre.h" 00020 00021 #include /**/ "tao/TAO_Export.h" 00022 00023 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00024 # pragma once 00025 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00026 00027 #include "tao/Basic_Types.h" 00028 00029 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00030 class ACE_Time_Value; 00031 ACE_END_VERSIONED_NAMESPACE_DECL 00032 00033 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00034 00035 namespace CORBA 00036 { 00037 class Exception; 00038 } 00039 00040 class TAO_Target_Specification; 00041 class TAO_Pluggable_Reply_Params; 00042 class TAO_Pluggable_Reply_Params_Base; 00043 class TAO_Transport; 00044 class TAO_Operation_Details; 00045 class TAO_Target_Specification; 00046 class TAO_OutputCDR; 00047 class TAO_Queued_Data; 00048 class TAO_GIOP_Fragmentation_Strategy; 00049 class TAO_GIOP_Message_Version; 00050 00051 // @@ The more I think I about this class, I feel that this class need 00052 // not be a ABC as it is now. Instead we have these options 00053 // (1) Parametrize this class with the "Messaging Object". Then the 00054 // implementations can just redirect the request to the class 00055 // that it has been specialised with 00056 // (2) Use a bridge pattern here ie. the interface exposed by this 00057 // class will redirect the request to the implementation which 00058 // would be "right messaging" object. 00059 // Both of them feasible. If we are not going like templates much, (2) 00060 // is seems to be a better option. 00061 // I am going to take a closer look on this after my MS defense - 00062 // Bala 00063 00064 /** 00065 * @class TAO_Pluggable_Messaging 00066 * 00067 * @brief Generic definitions Messaging class. 00068 * 00069 * This interface tries to define generic methods that could be 00070 * different messaging protocols 00071 */ 00072 class TAO_Export TAO_Pluggable_Messaging 00073 { 00074 public: 00075 /// Dtor 00076 virtual ~TAO_Pluggable_Messaging (void); 00077 00078 /// Write the RequestHeader in to the @a cdr stream. The underlying 00079 /// implementation of the mesaging should do the right thing. 00080 virtual int generate_request_header ( 00081 TAO_Operation_Details &op, 00082 TAO_Target_Specification &spec, 00083 TAO_OutputCDR &cdr) = 0; 00084 00085 /// Write the RequestHeader in to the @a cdr stream. 00086 virtual int generate_locate_request_header ( 00087 TAO_Operation_Details &op, 00088 TAO_Target_Specification &spec, 00089 TAO_OutputCDR &cdr) = 0; 00090 00091 /** 00092 * Write the reply header 00093 * The reply header is a part of any messaging protocol. The 00094 * messaging protocol implementation would implement the way the 00095 * reply header is written. 00096 */ 00097 virtual int generate_reply_header ( 00098 TAO_OutputCDR &cdr, 00099 TAO_Pluggable_Reply_Params_Base ¶ms) = 0; 00100 00101 /** 00102 * Write the locate reply header 00103 * The locate reply header is a part of any messaging protocol. The 00104 * messaging protocol implementation would implement the way the 00105 * locate reply header is written. 00106 */ 00107 virtual int generate_locate_reply_header ( 00108 TAO_OutputCDR &cdr, 00109 TAO_Pluggable_Reply_Params_Base ¶ms) = 0; 00110 00111 virtual int generate_fragment_header (TAO_OutputCDR & cdr, 00112 CORBA::ULong request_id) = 0; 00113 00114 /// Format the message in the @a cdr. May not be needed in 00115 /// general. 00116 virtual int format_message (TAO_OutputCDR &cdr) = 0; 00117 00118 /// Do any initialisations that may be needed. 00119 virtual void init (CORBA::Octet major, CORBA::Octet minor) = 0; 00120 00121 /// Parse the details of the next message from the @a qd 00122 /// and initializes the other attributes of @a qd. Returns 0 if the message 00123 /// header could not be parsed completely, returns a 1 if the message 00124 /// header could be parsed completely and returns -1 on error. As the 00125 /// parsed data is stored directly in @a qd, no state must be stored 00126 /// in instance of implementation. 00127 virtual int parse_next_message (TAO_Queued_Data &qd, 00128 size_t &mesg_length) = 0; /* out */ 00129 00130 /// Extract the details of the next message from the @a incoming 00131 /// through @a qd. Returns 0 if the message header could not be 00132 /// parsed completely, returns a 1 if the message header could be 00133 /// parsed completely and returns -1 on error. 00134 virtual int extract_next_message (ACE_Message_Block &incoming, 00135 TAO_Queued_Data *&qd) = 0; 00136 00137 /// Check whether the node @a qd needs consolidation from @a incoming 00138 /// @return 0 on success, -1 on error 00139 virtual int consolidate_node (TAO_Queued_Data *qd, 00140 ACE_Message_Block &incoming) = 0; 00141 00142 /// Parse the request message, make an upcall and send the reply back 00143 /// to the "request initiator" 00144 virtual int process_request_message (TAO_Transport *transport, 00145 TAO_Queued_Data *qd) = 0; 00146 00147 00148 /// Parse the reply message that we received and return the reply 00149 /// information through @a reply_info 00150 virtual int process_reply_message ( 00151 TAO_Pluggable_Reply_Params &reply_info, 00152 TAO_Queued_Data *qd) = 0; 00153 00154 /// Generate a reply message with the exception @a ex. 00155 virtual int generate_exception_reply ( 00156 TAO_OutputCDR &cdr, 00157 TAO_Pluggable_Reply_Params_Base ¶ms, 00158 const CORBA::Exception &ex) = 0; 00159 00160 /// Is the messaging object ready for processing BiDirectional 00161 /// request/response? 00162 virtual int is_ready_for_bidirectional (TAO_OutputCDR &msg) = 0; 00163 00164 /// Reset the messaging the object 00165 virtual void reset (void) = 0; 00166 00167 /// Header length 00168 virtual size_t header_length (void) const = 0; 00169 00170 /// Fragment header length 00171 virtual size_t fragment_header_length ( 00172 const TAO_GIOP_Message_Version& giop_version) const = 0; 00173 00174 /// Accessor for the output CDR stream 00175 virtual TAO_OutputCDR &out_stream (void) = 0; 00176 00177 /// Consolidate newly received fragment with previously arrived 00178 /// associated fragments to achieve consolidated message. All 00179 /// fragments having been received previously are being managed 00180 /// within implementation. If reliable transport is used (like TCP) 00181 /// this operation will be invoked with fragments being received 00182 /// partially ordered, last fragment being received last. Otherwise 00183 /// If un-reliable transport is used (like UDP) fragments may be 00184 /// received dis-ordered, and must be ordered before consolidation 00185 /// within implementation. @return 0 on success and @a con_msg 00186 /// points to consolidated message, 1 if there are still fragmens 00187 /// outstanding, in case of error -1 is being returned. The 00188 /// implementation is responsible to release @a qd. 00189 virtual int consolidate_fragmented_message (TAO_Queued_Data *qd, 00190 TAO_Queued_Data *&con_msg) = 0; 00191 00192 /// Discard all fragments associated to request-id encoded in 00193 /// cancel_request. Transport implementaion guarantees that this 00194 /// operation will never be invoked // concurrently by multiplpe 00195 /// threads nor concurrently to consolidate_fragmented_message 00196 /// @return -1 on failure, 0 on success, 1 no fragment on stack 00197 /// relating to CancelRequest. 00198 virtual int discard_fragmented_message (const TAO_Queued_Data *cancel_request) = 0; 00199 00200 /// Outgoing GIOP message fragmentation strategy. 00201 virtual TAO_GIOP_Fragmentation_Strategy * fragmentation_strategy (void) = 0; 00202 }; 00203 00204 TAO_END_VERSIONED_NAMESPACE_DECL 00205 00206 #include /**/ "ace/post.h" 00207 00208 #endif /*TAO_PLUGGABLE_MESSAGING_H*/