CORBA::ServerRequest Class Reference

Class representing the CORBA ServerRequest pseudo-object. More...

#include <Server_Request.h>

Collaboration diagram for CORBA::ServerRequest:

Collaboration graph
[legend]
List of all members.

Public Types

typedef CORBA::ServerRequest_ptr _ptr_type
 Useful for template programming.

typedef CORBA::ServerRequest_var _var_type
typedef CORBA::ServerRequest_out _out_type

Public Member Functions

 ServerRequest (TAO_ServerRequest &orb_server_request)
 Constructor.

 ~ServerRequest (void)
 Destructor.

void arguments (CORBA::NVList_ptr &list)
void set_result (const CORBA::Any &value)
void set_exception (const CORBA::Any &value)
void dsi_marshal ()
 Marshal outgoing parameters.

CORBA::Context_ptr ctx (void) const
 Accessor for the Context member.

void ctx (CORBA::Context_ptr)
 Mutator for the Context member.

const char * operation (void) const
 Get the operation name.

CORBA::ULong _incr_refcnt (void)
CORBA::ULong _decr_refcnt (void)
void _tao_lazy_evaluation (bool lazy_evaluation)
 Set the lazy evaluation flag.

int _tao_incoming_byte_order (void) const
 Get the byte order of the incoming CDR stream.

void _tao_reply_byte_order (int byte_order)
 Set the byte order of the outgoing CDR stream.

TAO_ServerRequest_tao_server_request (void)
 Return a reference to the underlying TAO_ServerRequest object.

void gateway_exception_reply (ACE_CString &raw_exception)

Static Public Member Functions

ServerRequest_ptr _duplicate (ServerRequest_ptr)
ServerRequest_ptr _nil (void)

Private Attributes

bool lazy_evaluation_
 If zero then the NVList is evaluated ASAP.

CORBA::Context_ptr ctx_
 Context associated with this request.

CORBA::NVList_ptr params_
 Incoming parameters.

CORBA::Any_ptr retval_
 Return value.

CORBA::Any_ptr exception_
 Any exception which might be raised.

CORBA::ULong refcount_
 Reference counting.

TAO_SYNCH_MUTEX lock_
 Protect the refcount_ and response_received_.

TAO_ServerRequestorb_server_request_
 Request from the ORB.

int sent_gateway_exception_
 Have we sent a user exception obtained from a gateway?


Detailed Description

Class representing the CORBA ServerRequest pseudo-object.

Instantiated by the POA for DSI requests and passed up to the application. Contains a reference to the instance of TAO_ServerRequest that is passed up to the POA from the ORB.

Definition at line 68 of file Server_Request.h.


Member Typedef Documentation

typedef CORBA::ServerRequest_out CORBA::ServerRequest::_out_type
 

Definition at line 147 of file Server_Request.h.

typedef CORBA::ServerRequest_ptr CORBA::ServerRequest::_ptr_type
 

Useful for template programming.

Definition at line 145 of file Server_Request.h.

typedef CORBA::ServerRequest_var CORBA::ServerRequest::_var_type
 

Definition at line 146 of file Server_Request.h.


Constructor & Destructor Documentation

CORBA::ServerRequest::ServerRequest TAO_ServerRequest orb_server_request  ) 
 

Constructor.

Definition at line 58 of file Server_Request.cpp.

References TAO_ServerRequest::is_dsi(), and orb_server_request_.

00059   : lazy_evaluation_ (0),
00060     ctx_ (CORBA::Context::_nil ()),
00061     params_ (CORBA::NVList::_nil ()),
00062     retval_ (0),
00063     exception_ (0),
00064     refcount_ (1),
00065     orb_server_request_ (orb_server_request),
00066     sent_gateway_exception_ (0)
00067 {
00068   this->orb_server_request_.is_dsi ();
00069 }

CORBA::ServerRequest::~ServerRequest void   ) 
 

Destructor.

Definition at line 71 of file Server_Request.cpp.

References params_, and retval_.

00072 {
00073   if (this->params_ != 0)
00074     {
00075       ::CORBA::release (this->params_);
00076     }
00077 
00078   delete this->retval_;
00079   delete this->exception_;
00080 }


Member Function Documentation

CORBA::ULong CORBA::ServerRequest::_decr_refcnt void   ) 
 

Definition at line 38 of file Server_Request.cpp.

References ACE_GUARD_RETURN, and TAO_SYNCH_MUTEX.

00039 {
00040   {
00041     ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
00042                       ace_mon,
00043                       this->lock_,
00044                       0);
00045 
00046     --this->refcount_;
00047 
00048     if (this->refcount_ != 0)
00049       {
00050         return this->refcount_;
00051       }
00052   }
00053 
00054   delete this;
00055   return 0;
00056 }

ACE_INLINE CORBA::ServerRequest_ptr CORBA::ServerRequest::_duplicate ServerRequest_ptr   )  [static]
 

Definition at line 27 of file Server_Request.inl.

00028 {
00029   if (x != 0)
00030     {
00031       x->_incr_refcnt ();
00032     }
00033 
00034   return x;
00035 }

TAO_BEGIN_VERSIONED_NAMESPACE_DECL CORBA::ULong CORBA::ServerRequest::_incr_refcnt void   ) 
 

Definition at line 27 of file Server_Request.cpp.

References ACE_GUARD_RETURN, and TAO_SYNCH_MUTEX.

00028 {
00029   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
00030                     ace_mon,
00031                     this->lock_,
00032                     0);
00033 
00034   return ++this->refcount_;
00035 }

ACE_INLINE CORBA::ServerRequest_ptr CORBA::ServerRequest::_nil void   )  [static]
 

Definition at line 38 of file Server_Request.inl.

00039 {
00040   return (CORBA::ServerRequest_ptr)0;
00041 }

ACE_INLINE int CORBA::ServerRequest::_tao_incoming_byte_order void   )  const
 

Get the byte order of the incoming CDR stream.

Definition at line 68 of file Server_Request.inl.

References ACE_InputCDR::byte_order(), TAO_ServerRequest::incoming(), and orb_server_request_.

00069 {
00070   return this->orb_server_request_.incoming ()->byte_order ();
00071 }

ACE_INLINE void CORBA::ServerRequest::_tao_lazy_evaluation bool  lazy_evaluation  ) 
 

Set the lazy evaluation flag.

Definition at line 62 of file Server_Request.inl.

00063 {
00064   this->lazy_evaluation_ = lazy_evaluation;
00065 }

ACE_INLINE void CORBA::ServerRequest::_tao_reply_byte_order int  byte_order  ) 
 

Set the byte order of the outgoing CDR stream.

Definition at line 74 of file Server_Request.inl.

References orb_server_request_, TAO_ServerRequest::outgoing(), and ACE_OutputCDR::reset_byte_order().

00075 {
00076   this->orb_server_request_.outgoing ()->reset_byte_order (byte_order);
00077 }

ACE_INLINE TAO_ServerRequest & CORBA::ServerRequest::_tao_server_request void   ) 
 

Return a reference to the underlying TAO_ServerRequest object.

Definition at line 81 of file Server_Request.inl.

References orb_server_request_.

00082 {
00083   return this->orb_server_request_;
00084 }

void CORBA::ServerRequest::arguments CORBA::NVList_ptr list  ) 
 

Implementation uses this to provide the ORB with the operation's parameter list ... on return, their values are available; the list fed in has typecodes and (perhap) memory assigned.

Definition at line 85 of file Server_Request.cpp.

References ACE_CHECK, ACE_ENV_ARG_PARAMETER, ACE_THROW, TAO_ServerRequest::dsi_nvlist_align(), orb_server_request_, and params_.

00087 {
00088   // arguments() must be called before either of these.
00089   if (this->params_ != 0 || this->exception_ != 0)
00090     {
00091       ACE_THROW (CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 7, CORBA::COMPLETED_NO));
00092     }
00093 
00094   // Save params for later use when marshaling the reply.
00095   this->params_ = list;
00096 
00097   this->params_->_tao_incoming_cdr (*this->orb_server_request_.incoming (),
00098                                     CORBA::ARG_IN | CORBA::ARG_INOUT,
00099                                     this->lazy_evaluation_
00100                                     ACE_ENV_ARG_PARAMETER);
00101   ACE_CHECK;
00102 
00103   // Pass this alignment back to the TAO_ServerRequest.
00104   this->orb_server_request_.dsi_nvlist_align (
00105                                 this->params_->_tao_target_alignment ()
00106                               );
00107 }

ACE_INLINE void CORBA::ServerRequest::ctx CORBA::Context_ptr   ) 
 

Mutator for the Context member.

Definition at line 50 of file Server_Request.inl.

00051 {
00052   this->ctx_ = ctx;
00053 }

ACE_INLINE CORBA::Context_ptr CORBA::ServerRequest::ctx void   )  const
 

Accessor for the Context member.

Definition at line 44 of file Server_Request.inl.

00045 {
00046   return this->ctx_;
00047 }

void CORBA::ServerRequest::dsi_marshal  ) 
 

Marshal outgoing parameters.

Definition at line 165 of file Server_Request.cpp.

References ACE_CHECK, ACE_ENV_ARG_PARAMETER, TAO_ServerRequest::argument_flag(), TAO_ServerRequest::exception_type(), TAO_ServerRequest::init_reply(), orb_server_request_, params_, retval_, sent_gateway_exception_, TAO_GIOP_NO_EXCEPTION, and TAO_ServerRequest::tao_send_reply().

Referenced by TAO_DynamicImplementation::_dispatch().

00166 {
00167   // There was a user exception, no need to marshal any parameters.
00168   if (this->sent_gateway_exception_)
00169     {
00170       return;
00171     }
00172 
00173   if (this->orb_server_request_.exception_type () == TAO_GIOP_NO_EXCEPTION)
00174     {
00175       // In DSI, we can't rely on the skeleton to do this.
00176       if (this->retval_ == 0 && this->params_ == 0)
00177         {
00178           this->orb_server_request_.argument_flag (0);
00179         }
00180 
00181       this->orb_server_request_.init_reply ();
00182 
00183       // Send the return value, if any.
00184       if (this->retval_ != 0)
00185         {
00186           this->retval_->impl ()->marshal_value (
00187                                       *this->orb_server_request_.outgoing ()
00188                                     );
00189         }
00190 
00191       // Send the "inout" and "out" parameters.
00192       if (this->params_ != 0)
00193         {
00194           this->params_->_tao_encode (
00195                              *this->orb_server_request_.outgoing (),
00196                              CORBA::ARG_INOUT | CORBA::ARG_OUT
00197                              ACE_ENV_ARG_PARAMETER
00198                            );
00199           ACE_CHECK;
00200         }
00201     }
00202   else
00203     {
00204       // This defaults to 1, but just to be safe...
00205       this->orb_server_request_.argument_flag (1);
00206 
00207       // Write the reply header to the ORB request's outgoing CDR stream.
00208       this->orb_server_request_.init_reply ();
00209 
00210       this->exception_->impl ()->marshal_value (
00211                                      *this->orb_server_request_.outgoing ()
00212                                    );
00213     }
00214 
00215   this->orb_server_request_.tao_send_reply ();
00216 }

void CORBA::ServerRequest::gateway_exception_reply ACE_CString raw_exception  ) 
 

Returns a user exception through a TAO gateway without knowing its type.

Definition at line 219 of file Server_Request.cpp.

References TAO_ServerRequest::argument_flag(), TAO_ServerRequest::exception_type(), TAO_ServerRequest::init_reply(), orb_server_request_, TAO_ServerRequest::outgoing(), sent_gateway_exception_, TAO_GIOP_USER_EXCEPTION, TAO_ServerRequest::tao_send_reply(), and ACE_OutputCDR::write_octet_array().

00220 {
00221   // This defaults to 1, but just to be safe...
00222   this->orb_server_request_.argument_flag (1);
00223 
00224   // This reply path handles only user exceptions.
00225   this->orb_server_request_.exception_type (TAO_GIOP_USER_EXCEPTION);
00226 
00227   this->orb_server_request_.init_reply ();
00228 
00229   // We know nothing about this exception, so we marshal it as a block
00230   // of bytes. The outgoing stream's byte order has already been matched
00231   // to the original source of the reply.
00232   this->orb_server_request_.outgoing ()->write_octet_array (
00233       reinterpret_cast<const CORBA::Octet *> (raw_exception.fast_rep ()),
00234       static_cast<CORBA::ULong> (raw_exception.length () + ACE_CDR::MAX_ALIGNMENT)
00235     );
00236 
00237   // This will prevent the marshaling of any parameters into this reply.
00238   this->sent_gateway_exception_ = 1;
00239 
00240   this->orb_server_request_.tao_send_reply ();
00241 }

ACE_INLINE const char * CORBA::ServerRequest::operation void   )  const
 

Get the operation name.

Definition at line 56 of file Server_Request.inl.

References TAO_ServerRequest::operation(), and orb_server_request_.

00057 {
00058   return this->orb_server_request_.operation ();
00059 }

void CORBA::ServerRequest::set_exception const CORBA::Any &  value  ) 
 

Implementation uses this to provide the exception value which is the only result of this particular invocation.

XXX Implementation should be able to assume response has been sent when this returns, and reclaim memory it allocated.

Definition at line 138 of file Server_Request.cpp.

References ACE_CHECK, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_NEW_THROW_EX, ACE_THROW, TAO_ServerRequest::exception_type(), orb_server_request_, and TAO_GIOP_USER_EXCEPTION.

00140 {
00141   CORBA::TypeCode_var tc = value.type ();
00142 
00143   CORBA::TCKind const kind = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER);
00144   ACE_CHECK;
00145 
00146   // set_exception() can be called at any time, but the Any arg MUST
00147   // contain an exception.
00148   if (kind != CORBA::tk_except)
00149     {
00150       ACE_THROW (CORBA::BAD_PARAM (CORBA::OMGVMCID | 21,
00151                                    CORBA::COMPLETED_MAYBE));
00152     }
00153 
00154   ACE_NEW_THROW_EX (this->exception_,
00155                     CORBA::Any (value),
00156                     CORBA::NO_MEMORY ());
00157   ACE_CHECK;
00158 
00159   this->orb_server_request_.exception_type (TAO_GIOP_USER_EXCEPTION);
00160 }

void CORBA::ServerRequest::set_result const CORBA::Any &  value  ) 
 

Implementation uses this to provide the operation result ... illegal if exception() was called or params() was not called.

XXX Implementation should be able to assume response has been sent when this returns, and reclaim memory it allocated.

Definition at line 113 of file Server_Request.cpp.

References ACE_CHECK, ACE_NEW_THROW_EX, ACE_THROW, params_, and retval_.

00115 {
00116   // Setting a result when another result already exists or if an exception
00117   // exists or before the args have been processeed is an error.
00118   if (this->retval_ != 0 || this->exception_ != 0 || this->params_ == 0)
00119     {
00120       ACE_THROW (CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 8, CORBA::COMPLETED_NO));
00121     }
00122 
00123   ACE_NEW_THROW_EX (this->retval_,
00124                     CORBA::Any (value),
00125                     CORBA::NO_MEMORY ());
00126   ACE_CHECK;
00127 }


Member Data Documentation

CORBA::Context_ptr CORBA::ServerRequest::ctx_ [private]
 

Context associated with this request.

Definition at line 154 of file Server_Request.h.

CORBA::Any_ptr CORBA::ServerRequest::exception_ [private]
 

Any exception which might be raised.

Definition at line 163 of file Server_Request.h.

bool CORBA::ServerRequest::lazy_evaluation_ [private]
 

If zero then the NVList is evaluated ASAP.

Definition at line 151 of file Server_Request.h.

TAO_SYNCH_MUTEX CORBA::ServerRequest::lock_ [private]
 

Protect the refcount_ and response_received_.

Definition at line 169 of file Server_Request.h.

TAO_ServerRequest& CORBA::ServerRequest::orb_server_request_ [private]
 

Request from the ORB.

Definition at line 172 of file Server_Request.h.

Referenced by _tao_incoming_byte_order(), _tao_reply_byte_order(), _tao_server_request(), arguments(), dsi_marshal(), gateway_exception_reply(), operation(), ServerRequest(), and set_exception().

CORBA::NVList_ptr CORBA::ServerRequest::params_ [private]
 

Incoming parameters.

Definition at line 157 of file Server_Request.h.

Referenced by arguments(), dsi_marshal(), set_result(), and ~ServerRequest().

CORBA::ULong CORBA::ServerRequest::refcount_ [private]
 

Reference counting.

Definition at line 166 of file Server_Request.h.

CORBA::Any_ptr CORBA::ServerRequest::retval_ [private]
 

Return value.

Definition at line 160 of file Server_Request.h.

Referenced by dsi_marshal(), set_result(), and ~ServerRequest().

int CORBA::ServerRequest::sent_gateway_exception_ [private]
 

Have we sent a user exception obtained from a gateway?

Definition at line 175 of file Server_Request.h.

Referenced by dsi_marshal(), and gateway_exception_reply().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 13:05:09 2006 for TAO_DynamicInterface by doxygen 1.3.6