Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

TAO::Asynch_Invocation_Adapter Class Reference

Generic interface for the invocation object visible to the IDL compiler. More...

#include <Asynch_Invocation_Adapter.h>

Inheritance diagram for TAO::Asynch_Invocation_Adapter:
Inheritance graph
[legend]
Collaboration diagram for TAO::Asynch_Invocation_Adapter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Asynch_Invocation_Adapter (CORBA::Object *target, Argument **args, int arg_number, const char *operation, size_t op_len, Collocation_Proxy_Broker *b, TAO::Invocation_Mode mode=TAO_ASYNCHRONOUS_CALLBACK_INVOCATION)
void invoke (Messaging::ReplyHandler_ptr reply_handler_ptr, const TAO_Reply_Handler_Stub &reply_handler_stub)
virtual void invoke (TAO::Exception_Data *ex, unsigned long ex_count)
 Invoke the target, and used by the generated code.

Protected Member Functions

virtual Invocation_Status invoke_twoway (TAO_Operation_Details &op, CORBA::Object_var &effective_target, Profile_Transport_Resolver &r, ACE_Time_Value *&max_wait_time)
 Helper method to make a two way invocation.
virtual Invocation_Status invoke_collocated_i (TAO_Stub *stub, TAO_Operation_Details &details, CORBA::Object_var &effective_target, Collocation_Strategy strat)
 Make a collocated call.

Private Member Functions

 Asynch_Invocation_Adapter (void)
 Don't allow default initializations.
 Asynch_Invocation_Adapter (const Asynch_Invocation_Adapter &)
Asynch_Invocation_Adapteroperator= (const Asynch_Invocation_Adapter &)

Private Attributes

ACE_Utils::Auto_Functor
< TAO_Asynch_Reply_Dispatcher_Base,
ARDB_Refcount_Functor
safe_rd_
 Autofunctor to manage the reply dispatcher.

Detailed Description

Generic interface for the invocation object visible to the IDL compiler.

Definition at line 60 of file Asynch_Invocation_Adapter.h.


Constructor & Destructor Documentation

TAO::Asynch_Invocation_Adapter::Asynch_Invocation_Adapter ( CORBA::Object target,
Argument **  args,
int  arg_number,
const char *  operation,
size_t  op_len,
Collocation_Proxy_Broker b,
TAO::Invocation_Mode  mode = TAO_ASYNCHRONOUS_CALLBACK_INVOCATION 
)
TAO::Asynch_Invocation_Adapter::Asynch_Invocation_Adapter ( void   )  [private]

Don't allow default initializations.

TAO::Asynch_Invocation_Adapter::Asynch_Invocation_Adapter ( const Asynch_Invocation_Adapter  )  [private]

Member Function Documentation

void TAO::Asynch_Invocation_Adapter::invoke ( Messaging::ReplyHandler_ptr  reply_handler_ptr,
const TAO_Reply_Handler_Stub reply_handler_stub 
)

Definition at line 49 of file Asynch_Invocation_Adapter.cpp.

  {
    TAO_Stub * stub =
      this->get_stub ();

    if (TAO_debug_level >= 4)
      {
        ACE_DEBUG ((LM_DEBUG,
                    "TAO_Messaging (%P|%t) - Asynch_Invocation_Adapter::"
                    "invoke\n"));
      }

    // If the reply handler is nil, we do not create a reply dispatcher.
    // The ORB will drop replies to which it cannot associate a reply
    // dispatcher.
    if (!CORBA::is_nil (reply_handler_ptr))
      {
        // New reply dispatcher on the heap or allocator, because
        // we will go out of scope and hand over the reply dispatcher
        // to the ORB.
        TAO_Asynch_Reply_Dispatcher *rd = 0;

        // Get the allocator we could use.
        ACE_Allocator* ami_allocator =
          stub->orb_core ()->lane_resources().ami_response_handler_allocator();

        // If we have an allocator, use it, else use the heap.
        if (ami_allocator)
          {
            ACE_NEW_MALLOC (
              rd,
              static_cast<TAO_Asynch_Reply_Dispatcher *> (
                ami_allocator->malloc (sizeof (TAO_Asynch_Reply_Dispatcher))),
              TAO_Asynch_Reply_Dispatcher (reply_handler_stub,
                                           reply_handler_ptr,
                                           stub->orb_core (),
                                           ami_allocator));
          }
        else
          {
            ACE_NEW (rd,
                     TAO_Asynch_Reply_Dispatcher (reply_handler_stub,
                                                  reply_handler_ptr,
                                                  stub->orb_core (),
                                                  0));
          }

        if (rd == 0)
          {
            throw ::CORBA::NO_MEMORY ();
          }

        this->safe_rd_.reset (rd);
      }

    Invocation_Adapter::invoke (0, 0);
  }

void TAO::Asynch_Invocation_Adapter::invoke ( TAO::Exception_Data *  ex,
unsigned long  ex_count 
) [virtual]

Invoke the target, and used by the generated code.

The implementation decides whether the target is remote or collocated and takes the right decision.

Parameters:
ex Array of exception data declared by the application in their IDL.
ex_count Number of elements in the array.

Reimplemented from TAO::Invocation_Adapter.

Definition at line 110 of file Asynch_Invocation_Adapter.cpp.

  {
    Invocation_Adapter::invoke (ex, ex_count );
  }

Invocation_Status TAO::Asynch_Invocation_Adapter::invoke_collocated_i ( TAO_Stub stub,
TAO_Operation_Details details,
CORBA::Object_var effective_target,
Collocation_Strategy  strat 
) [protected, virtual]

Make a collocated call.

This method creates an object that takes care of making collocated invocations and calls invoke () on it. If the invoke () returns with a location forwarded reply we return a restart

Parameters:
stub The stub object on which the invocation is made.
details The operations details of the operation that is being invoked.

Reimplemented from TAO::Invocation_Adapter.

Definition at line 119 of file Asynch_Invocation_Adapter.cpp.

  {
    if (stub->orb_core ()->orb_params ()->ami_collication ())
      {
        // When doing a collocation asynch invocation we shouldn't use the
        // stub args but use the skel args
        details.use_stub_args (false);

        TAO_AMI_Arguments_Converter_Impl* ami_arguments_converter
          = ACE_Dynamic_Service<TAO_AMI_Arguments_Converter_Impl>::instance (
            "AMI_Arguments_Converter");
        details.cac (ami_arguments_converter);

        // Release the owner ship of the reply dispatcher
        details.reply_dispatcher (this->safe_rd_.release ());

        return Invocation_Adapter::invoke_collocated_i (stub,
                                                        details,
                                                        effective_target,
                                                        strat);
      }
    else
      {
        ACE_Time_Value *max_wait_time = 0;
        return Invocation_Adapter::invoke_remote_i (stub,
                                                    details,
                                                    effective_target,
                                                    max_wait_time);
      }
  }

Invocation_Status TAO::Asynch_Invocation_Adapter::invoke_twoway ( TAO_Operation_Details details,
CORBA::Object_var effective_target,
Profile_Transport_Resolver r,
ACE_Time_Value *&  max_wait_time 
) [protected, virtual]

Helper method to make a two way invocation.

This method creates a synchronous twoway invocation object to which the actual task of request handling is delegated. Once the invocation returns this method checks whether the request is forwarded to a new location.

Reimplemented from TAO::Invocation_Adapter.

Definition at line 155 of file Asynch_Invocation_Adapter.cpp.

  {
    // Simple sanity check
    if (this->mode_ != TAO_ASYNCHRONOUS_CALLBACK_INVOCATION
        || this->type_ != TAO_TWOWAY_INVOCATION)
      {
        throw ::CORBA::INTERNAL (
          CORBA::SystemException::_tao_minor_code (
            TAO::VMCID,
            EINVAL),
          CORBA::COMPLETED_NO);
      }

    if (this->safe_rd_.get () && r.transport ())
      {
        this->safe_rd_->transport (r.transport ());
        // AMI Timeout Handling Begin
        ACE_Time_Value tmp;

        if (this->get_timeout (r.stub (), tmp))
          {
            this->safe_rd_->schedule_timer (op.request_id (), *max_wait_time);
          }
      }

    // Loose ownership of the reply dispatcher
    TAO::Asynch_Remote_Invocation asynch (
       effective_target.in (),
       r,
       op,
       this->safe_rd_.release ());

    Invocation_Status const s = asynch.remote_invocation (max_wait_time);

    if (s == TAO_INVOKE_RESTART &&
        (asynch.reply_status () == GIOP::LOCATION_FORWARD ||
         asynch.reply_status () == GIOP::LOCATION_FORWARD_PERM))
      {
        CORBA::Boolean const permanent_forward =
          (asynch.reply_status () == GIOP::LOCATION_FORWARD_PERM);

        effective_target = asynch.steal_forwarded_reference ();

        this->object_forwarded (effective_target, r.stub (), permanent_forward);
      }

    return s;
  }

Asynch_Invocation_Adapter& TAO::Asynch_Invocation_Adapter::operator= ( const Asynch_Invocation_Adapter  )  [private]

Member Data Documentation

ACE_Utils::Auto_Functor<TAO_Asynch_Reply_Dispatcher_Base, ARDB_Refcount_Functor> TAO::Asynch_Invocation_Adapter::safe_rd_ [private]

Autofunctor to manage the reply dispatcher.

Definition at line 94 of file Asynch_Invocation_Adapter.h.


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