Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends

CORBA::Request Class Reference

CORBA::Request. More...

#include <Request.h>

Collaboration diagram for CORBA::Request:
Collaboration graph
[legend]

List of all members.

Public Types

typedef CORBA::Request_ptr _ptr_type
typedef CORBA::Request_var _var_type
typedef CORBA::Request_out _out_type

Public Member Functions

CORBA::Object_ptr target (void) const
 Return the target of this request.
const CORBA::Charoperation (void) const
 Return the operation name for the request.
CORBA::NVList_ptr arguments (void)
 Return the arguments for the request.
CORBA::NamedValue_ptr result (void)
 Return the result for the request.
CORBA::ExceptionList_ptr exceptions (void)
 Return the exceptions resulting from this request.
CORBA::Context_ptr ctx (void) const
 Accessor for the Context member.
void ctx (CORBA::Context_ptr)
 Mutator for the Context member.
CORBA::ContextList_ptr contexts (void)
void set_return_type (CORBA::TypeCode_ptr tc)
 Initialize the return type.
CORBA::Anyreturn_value (void)
 Returns reference to Any for extraction using >>=.
void invoke (void)
 Perform method resolution and invoke an appropriate method.
void send_oneway (void)
 Send a oneway request.
void handle_response (TAO_InputCDR &incoming, GIOP::ReplyStatusType reply_status)
 Callback method for deferred synchronous requests.
void sendc (CORBA::Object_ptr handler)
CORBA::ULong _incr_refcnt (void)
CORBA::ULong _decr_refcnt (void)
void _tao_lazy_evaluation (bool lazy_evaluation)
 Set the lazy evaluation flag.
int _tao_byte_order (void) const
 Get the byte order member.
void _tao_byte_order (int byte_order)
 Set the byte order member.
void raw_user_exception (TAO_InputCDR &cdr)
ACE_CStringraw_user_exception (void)
 Accessor for the input stream containing the exception.
CORBA::Boolean response_received (void)
Argument manipulation helper functions.

Arg adders, one for each type of parameter, with and without optional name. Returns reference to Any for insertion using <<=.

CORBA::Anyadd_in_arg (void)
CORBA::Anyadd_in_arg (const char *name)
CORBA::Anyadd_inout_arg (void)
CORBA::Anyadd_inout_arg (const char *name)
CORBA::Anyadd_out_arg (void)
CORBA::Anyadd_out_arg (const char *name)
The 'deferred synchronous' methods.

The 'deferred synchronous' methods.

void send_deferred (void)
void get_response (void)
CORBA::Boolean poll_response (void)

Static Public Member Functions

static void _tao_reply_stub (TAO_InputCDR &_tao_reply_cdr, Messaging::ReplyHandler_ptr _tao_reply_handler, CORBA::ULong reply_status)
static CORBA::Request_duplicate (CORBA::Request *)
 Pseudo object methods.
static CORBA::Request_nil (void)

Private Member Functions

 Request (CORBA::Object_ptr obj, CORBA::ORB_ptr orb, const CORBA::Char *op, CORBA::NVList_ptr args, CORBA::NamedValue_ptr result, CORBA::Flags flags, CORBA::ExceptionList_ptr exceptions)
 Request (CORBA::Object_ptr obj, CORBA::ORB_ptr orb, const CORBA::Char *op)
 ~Request (void)

Private Attributes

CORBA::Object_ptr target_
 Target object.
CORBA::ORB_var orb_
 Pointer to our ORB.
const char * opname_
 Operation name.
CORBA::NVList_ptr args_
 Parameter list.
CORBA::NamedValue_ptr result_
 Result of the operation.
CORBA::Flags flags_
 Invocation flags.
CORBA::ExceptionList_var exceptions_
 List of exceptions raised by the operation.
CORBA::ContextList_ptr contexts_
 List of the request's result's contexts.
CORBA::Context_ptr ctx_
 Context associated with this request.
ACE_Atomic_Op< TAO_SYNCH_MUTEX,
unsigned long > 
refcount_
 Reference counting.
TAO_SYNCH_MUTEX lock_
 Protect the response_received_.
bool lazy_evaluation_
 If not zero then the NVList is not evaluated by default.
CORBA::Boolean response_received_
 Set to true upon completion of invoke() or handle_response().
int byte_order_
 Can be reset by a gateway when passing along a request.
ACE_CString raw_user_exception_

Friends

class ::TAO_Dynamic_Adapter_Impl

Detailed Description

CORBA::Request.

Provides a way to create requests and populate it with parameters for use in the Dynamic Invocation Interface.

Definition at line 73 of file Request.h.


Member Typedef Documentation

Definition at line 202 of file Request.h.

Definition at line 200 of file Request.h.

Definition at line 201 of file Request.h.


Constructor & Destructor Documentation

CORBA::Request::Request ( CORBA::Object_ptr  obj,
CORBA::ORB_ptr  orb,
const CORBA::Char op,
CORBA::NVList_ptr  args,
CORBA::NamedValue_ptr  result,
CORBA::Flags  flags,
CORBA::ExceptionList_ptr  exceptions 
) [private]
CORBA::Request::Request ( CORBA::Object_ptr  obj,
CORBA::ORB_ptr  orb,
const CORBA::Char op 
) [private]
CORBA::Request::~Request ( void   )  [private]

Definition at line 114 of file Request.cpp.


Member Function Documentation

CORBA::ULong CORBA::Request::_decr_refcnt ( void   ) 

Definition at line 42 of file Request.cpp.

{
  CORBA::ULong const new_count = --this->refcount_;

  if (new_count == 0)
    delete this;

  return new_count;
}

static CORBA::Request* CORBA::Request::_duplicate ( CORBA::Request  )  [static]

Pseudo object methods.

CORBA::ULong CORBA::Request::_incr_refcnt ( void   ) 

Definition at line 36 of file Request.cpp.

{
  return ++this->refcount_;
}

CORBA::Request_ptr CORBA::Request::_nil ( void   )  [static]

Definition at line 38 of file Request.inl.

{
  return 0;
}

int CORBA::Request::_tao_byte_order ( void   )  const

Get the byte order member.

Definition at line 160 of file Request.inl.

{
  return this->byte_order_;
}

void CORBA::Request::_tao_byte_order ( int  byte_order  ) 

Set the byte order member.

Definition at line 166 of file Request.inl.

{
  this->byte_order_ = byte_order;
}

void CORBA::Request::_tao_lazy_evaluation ( bool  lazy_evaluation  ) 

Set the lazy evaluation flag.

Definition at line 154 of file Request.inl.

{
  this->lazy_evaluation_ = lazy_evaluation;
}

void CORBA::Request::_tao_reply_stub ( TAO_InputCDR _tao_reply_cdr,
Messaging::ReplyHandler_ptr  _tao_reply_handler,
CORBA::ULong  reply_status 
) [static]

Definition at line 260 of file Request.cpp.

{
  // Retrieve Reply Handler object.
  TAO_DII_Reply_Handler* reply_handler =
    dynamic_cast<TAO_DII_Reply_Handler*> (rh);

  // Exception handling
  switch (reply_status)
    {
    case TAO_AMI_REPLY_OK:
    case TAO_AMI_REPLY_NOT_OK:
      {
        reply_handler->handle_response(_tao_in);
        break;
      }
    case TAO_AMI_REPLY_USER_EXCEPTION:
    case TAO_AMI_REPLY_SYSTEM_EXCEPTION:
      {
        reply_handler->handle_excep (_tao_in, reply_status);
        break;
      }
    case TAO_AMI_REPLY_LOCATION_FORWARD:
    case TAO_AMI_REPLY_LOCATION_FORWARD_PERM:
      {
        reply_handler->handle_location_forward (_tao_in, reply_status);
        break;
      }
    }
}

CORBA::Any& CORBA::Request::add_in_arg ( const char *  name  ) 
CORBA::Any & CORBA::Request::add_in_arg ( void   ) 

Definition at line 94 of file Request.inl.

{
  return this->args_->add_element (CORBA::ARG_IN)->any_;
}

CORBA::Any & CORBA::Request::add_inout_arg ( void   ) 

Definition at line 106 of file Request.inl.

{
  return this->args_->add_element (CORBA::ARG_INOUT)->any_;
}

CORBA::Any& CORBA::Request::add_inout_arg ( const char *  name  ) 
CORBA::Any & CORBA::Request::add_out_arg ( void   ) 

Definition at line 118 of file Request.inl.

{
  return this->args_->add_element (CORBA::ARG_OUT)->any_;
}

CORBA::Any& CORBA::Request::add_out_arg ( const char *  name  ) 
CORBA::NVList_ptr CORBA::Request::arguments ( void   ) 

Return the arguments for the request.

Definition at line 58 of file Request.inl.

{
  return this->args_;
}

CORBA::ContextList_ptr CORBA::Request::contexts ( void   ) 

Return a list of the request's result's contexts. Since TAO does not implement Contexts, this will always be 0.

Definition at line 79 of file Request.inl.

{
  return this->contexts_;
}

CORBA::Context_ptr CORBA::Request::ctx ( void   )  const

Accessor for the Context member.

Definition at line 142 of file Request.inl.

{
  return this->ctx_;
}

void CORBA::Request::ctx ( CORBA::Context_ptr  ctx  ) 

Mutator for the Context member.

Definition at line 148 of file Request.inl.

{
  this->ctx_ = ctx;
}

CORBA::ExceptionList_ptr CORBA::Request::exceptions ( void   ) 

Return the exceptions resulting from this request.

Definition at line 72 of file Request.inl.

{
  return this->exceptions_.in ();
}

void CORBA::Request::get_response ( void   ) 

Definition at line 294 of file Request.cpp.

{
  while (!this->response_received_)
    {
      (void) this->orb_->perform_work ();
    }

  if (this->lazy_evaluation_)
    {
      this->args_->evaluate ();
    }
}

void CORBA::Request::handle_response ( TAO_InputCDR incoming,
GIOP::ReplyStatusType  reply_status 
)

Callback method for deferred synchronous requests.

Definition at line 341 of file Request.cpp.

{
  // If this request was created by a gateway, then result_
  // and/or args_ are shared by a CORBA::ServerRequest, whose
  // reply must be in the same byte order as the reply we are
  // handling here. So we set the member to be accessed later.
  this->byte_order_ = incoming.byte_order ();

  switch (reply_status)
  {
    case GIOP::NO_EXCEPTION:
      if (this->result_ != 0)
        {
          // We can be sure that the impl is a TAO::Unknown_IDL_Type.
          this->result_->value ()->impl ()->_tao_decode (incoming);
        }

      this->args_->_tao_incoming_cdr (incoming,
                                      CORBA::ARG_OUT | CORBA::ARG_INOUT,
                                      this->lazy_evaluation_);

      {
        ACE_GUARD (TAO_SYNCH_MUTEX,
                   ace_mon,
                   this->lock_);

        this->response_received_ = true;
      }

      break;
    case GIOP::USER_EXCEPTION:
    case GIOP::SYSTEM_EXCEPTION:
    case GIOP::LOCATION_FORWARD:
    case GIOP::LOCATION_FORWARD_PERM:
    default:
      // @@ (JP) Don't know what to do about any of these yet.
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("(%P|%t) unhandled reply status\n")));
  }
}

void CORBA::Request::invoke ( void   ) 

Perform method resolution and invoke an appropriate method.

If the method returns successfully, its result is placed in the result argument specified on create_request. The behavior is undefined if this Request has already been used with a previous call to invoke>, send>, or .

Note:
A default argument is set, but please note that this not recommended as the user may not be able to propagate the exceptions.

Definition at line 133 of file Request.cpp.

{
  TAO::NamedValue_Argument _tao_retval (this->result_);

  TAO::NVList_Argument _tao_in_list (this->args_,
                                     this->lazy_evaluation_);

  TAO::Argument *_tao_arg_list [] = {
    &_tao_retval,
    &_tao_in_list
  };

  TAO::DII_Invocation_Adapter _tao_call (
       this->target_,
       _tao_arg_list,
       sizeof( _tao_arg_list ) / sizeof( TAO::Argument* ),
       this->opname_,
       static_cast<CORBA::ULong> (ACE_OS::strlen (this->opname_)),
       this->exceptions_.in (),
       this);

  _tao_call.invoke (0, 0);

  // If we returned without an exception being thrown the response
  // (if any) is assumed to be received.
  this->response_received_ = true;
  
  // If this request was created by a gateway, then result_
  // and/or args_ are shared by a CORBA::ServerRequest, whose
  // reply must be in the same byte order as the reply we are
  // handling here. So we set the member to be accessed later.
  this->byte_order_ = _tao_retval.byte_order ();
}

const CORBA::Char * CORBA::Request::operation ( void   )  const

Return the operation name for the request.

Definition at line 51 of file Request.inl.

{
  return this->opname_;
}

CORBA::Boolean CORBA::Request::poll_response ( void   ) 

Definition at line 308 of file Request.cpp.

{
  CORBA::Boolean response_received = false;

  {
    ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                      ace_mon,
                      this->lock_,
                      false);
    response_received = this->response_received_;
  }

  if (!response_received)
    {
      // If we're single-threaded, the application could starve the ORB,
      // and the response never gets received, so let the ORB do an
      // atom of work, if necessary, each time we poll.
      ACE_Time_Value tv (0, 0);
      (void) this->orb_->perform_work (&tv);

      {
        ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                          ace_mon,
                          this->lock_,
                          false);
        response_received = this->response_received_;
      }
    }

  return response_received;
}

void CORBA::Request::raw_user_exception ( TAO_InputCDR cdr  ) 

Definition at line 172 of file Request.inl.

{
  this->raw_user_exception_.set (cdr.start ()->rd_ptr (),
                                 cdr.start ()->length (),
                                 1);
}

ACE_CString & CORBA::Request::raw_user_exception ( void   ) 

Accessor for the input stream containing the exception.

Definition at line 180 of file Request.inl.

{
  return this->raw_user_exception_;
}

CORBA::Boolean CORBA::Request::response_received ( void   ) 

Proprietary method to check whether a response has been received.

Definition at line 186 of file Request.inl.

{
  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                    ace_mon,
                    this->lock_,
                    false);

  return this->response_received_;
}

CORBA::NamedValue_ptr CORBA::Request::result ( void   ) 

Return the result for the request.

Definition at line 65 of file Request.inl.

{
  return this->result_;
}

CORBA::Any & CORBA::Request::return_value ( void   ) 

Returns reference to Any for extraction using >>=.

Definition at line 136 of file Request.inl.

{
  return this->result_->any_;
}

void CORBA::Request::send_deferred ( void   ) 

Definition at line 192 of file Request.cpp.

{
  {
    ACE_GUARD (TAO_SYNCH_MUTEX,
               ace_mon,
               this->lock_);

    this->response_received_ = false;
  }
  CORBA::Boolean const argument_flag = this->args_->count () ? true : false;

  TAO::NamedValue_Argument _tao_retval (this->result_);

  TAO::NVList_Argument _tao_in_list (this->args_,
                                     this->lazy_evaluation_);

  TAO::Argument *_tao_arg_list [] = {
    &_tao_retval,
    &_tao_in_list
  };

  size_t number_args = 0;

  if (argument_flag)
    number_args = 2;
  else
    number_args = 1;

  TAO::DII_Deferred_Invocation_Adapter _tao_call (
      this->target_,
      _tao_arg_list,
      number_args,
      this->opname_,
      static_cast<CORBA::ULong> (ACE_OS::strlen (this->opname_)),
      0,
      this->orb_->orb_core (),
      this);

  _tao_call.invoke (0, 0);
}

void CORBA::Request::send_oneway ( void   ) 

Send a oneway request.

Note:
A default argument is set, but please note that this not recommended as the user may not be able to propagate the exceptions.

Definition at line 168 of file Request.cpp.

{
  TAO::NamedValue_Argument _tao_retval (this->result_);

  TAO::NVList_Argument _tao_in_list (this->args_,
                                     this->lazy_evaluation_);

  TAO::Argument *_tao_arg_list [] = {
    &_tao_retval,
    &_tao_in_list
  };

  TAO::DII_Oneway_Invocation_Adapter _tao_call (
      this->target_,
      _tao_arg_list,
      sizeof( _tao_arg_list ) / sizeof( TAO::Argument* ),
      this->opname_,
      static_cast<CORBA::ULong> (ACE_OS::strlen (this->opname_)),
      TAO::TAO_SYNCHRONOUS_INVOCATION);

  _tao_call.invoke (0, 0);
}

void CORBA::Request::sendc ( CORBA::Object_ptr  handler  ) 

The 'asychronous' send method. The object is a DSI based callback handler. This handler must implement Messaging::ReplyHandler

Definition at line 235 of file Request.cpp.

{
  TAO::NamedValue_Argument _tao_retval (this->result_);

  TAO::NVList_Argument _tao_in_list (this->args_,
                                     this->lazy_evaluation_);

  TAO::Argument *_tao_arg_list [] = {
    &_tao_retval,
    &_tao_in_list
  };

  TAO::Asynch_Invocation_Adapter _tao_call (
       this->target_,
       _tao_arg_list,
       sizeof( _tao_arg_list ) / sizeof( TAO::Argument* ),
       const_cast<char *> (this->opname_),
       static_cast<CORBA::ULong> (ACE_OS::strlen (this->opname_)),
       0); // collocation proxy broker

  _tao_call.invoke (dynamic_cast<Messaging::ReplyHandler_ptr>(handler),
                    &CORBA::Request::_tao_reply_stub);
}

void CORBA::Request::set_return_type ( CORBA::TypeCode_ptr  tc  ) 

Initialize the return type.

Definition at line 130 of file Request.inl.

{
  this->result_->any_._tao_set_typecode (tc);
}

CORBA::Object_ptr CORBA::Request::target ( void   )  const

Return the target of this request.

Definition at line 44 of file Request.inl.

{
  return this->target_;
}


Friends And Related Function Documentation

friend class ::TAO_Dynamic_Adapter_Impl [friend]

Definition at line 205 of file Request.h.


Member Data Documentation

Parameter list.

Definition at line 236 of file Request.h.

Can be reset by a gateway when passing along a request.

Definition at line 269 of file Request.h.

List of the request's result's contexts.

Definition at line 251 of file Request.h.

Context associated with this request.

Definition at line 254 of file Request.h.

List of exceptions raised by the operation.

Deprecated:
Holds exceptions.

Definition at line 248 of file Request.h.

Invocation flags.

Definition at line 242 of file Request.h.

If not zero then the NVList is not evaluated by default.

Definition at line 263 of file Request.h.

TAO_SYNCH_MUTEX CORBA::Request::lock_ [private]

Protect the response_received_.

Definition at line 260 of file Request.h.

const char* CORBA::Request::opname_ [private]

Operation name.

Definition at line 233 of file Request.h.

Pointer to our ORB.

Definition at line 230 of file Request.h.

Stores user exception as a CDR stream when this request is used in a TAO gateway.

Definition at line 273 of file Request.h.

ACE_Atomic_Op<TAO_SYNCH_MUTEX, unsigned long> CORBA::Request::refcount_ [private]

Reference counting.

Definition at line 257 of file Request.h.

Set to true upon completion of invoke() or handle_response().

Definition at line 266 of file Request.h.

Result of the operation.

Definition at line 239 of file Request.h.

Target object.

Definition at line 227 of file Request.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines