diff options
author | zhangw <zhangw@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2007-01-23 15:30:41 +0000 |
---|---|---|
committer | zhangw <zhangw@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2007-01-23 15:30:41 +0000 |
commit | 18fc7bf28b6723c02aad3d376a6b9916f8a40a58 (patch) | |
tree | dcb9bff88f4ba2f8ad0424c6f91f00c75bb6a3ee | |
parent | 54191a377b67a851dc03c754a23cb8aaca6b18b2 (diff) | |
download | ATCD-18fc7bf28b6723c02aad3d376a6b9916f8a40a58.tar.gz |
Mon Jan 22 22:26:07 UTC 2007 Wallace Zhang <zhang_w@ociweb.com>
* tao/DynamicInterface/DII_Invocation.h:
* tao/DynamicInterface/DII_Invocation_Adapter.h:
* tao/DynamicInterface/DII_Invocation_Adapter.cpp:
* tao/DynamicInterface/DII_Reply_Dispatcher.h:
* tao/DynamicInterface/DII_Reply_Dispatcher.cpp:
* tao/DynamicInterface/DII_Reply_Handler.h:
* tao/DynamicInterface/DII_Reply_Handler.inl:
* tao/DynamicInterface/DII_Reply_Handler.cpp:
* tao/DynamicInterface/Request.h:
* tao/DynamicInterface/Request.cpp:
* tao/Invocation_Utils.h:
Extended TAO for support the combination of DSI and AMH.
-rw-r--r-- | TAO/ChangeLog.oci_rt9734 | 16 | ||||
-rw-r--r-- | TAO/tao/DynamicInterface/DII_Invocation.h | 37 | ||||
-rw-r--r-- | TAO/tao/DynamicInterface/DII_Invocation_Adapter.cpp | 43 | ||||
-rw-r--r-- | TAO/tao/DynamicInterface/DII_Invocation_Adapter.h | 39 | ||||
-rw-r--r-- | TAO/tao/DynamicInterface/DII_Reply_Dispatcher.cpp | 123 | ||||
-rw-r--r-- | TAO/tao/DynamicInterface/DII_Reply_Dispatcher.h | 39 | ||||
-rw-r--r-- | TAO/tao/DynamicInterface/DII_Reply_Handler.cpp | 59 | ||||
-rw-r--r-- | TAO/tao/DynamicInterface/DII_Reply_Handler.h | 122 | ||||
-rw-r--r-- | TAO/tao/DynamicInterface/DII_Reply_Handler.inl | 111 | ||||
-rw-r--r-- | TAO/tao/DynamicInterface/Request.cpp | 67 | ||||
-rw-r--r-- | TAO/tao/DynamicInterface/Request.h | 22 | ||||
-rw-r--r-- | TAO/tao/Invocation_Utils.h | 3 |
12 files changed, 676 insertions, 5 deletions
diff --git a/TAO/ChangeLog.oci_rt9734 b/TAO/ChangeLog.oci_rt9734 new file mode 100644 index 00000000000..e6b8ff7ed67 --- /dev/null +++ b/TAO/ChangeLog.oci_rt9734 @@ -0,0 +1,16 @@ +Mon Jan 22 22:26:07 UTC 2007 Wallace Zhang <zhang_w@ociweb.com> + + * tao/DynamicInterface/DII_Invocation.h: + * tao/DynamicInterface/DII_Invocation_Adapter.h: + * tao/DynamicInterface/DII_Invocation_Adapter.cpp: + * tao/DynamicInterface/DII_Reply_Dispatcher.h: + * tao/DynamicInterface/DII_Reply_Dispatcher.cpp: + * tao/DynamicInterface/DII_Reply_Handler.h: + * tao/DynamicInterface/DII_Reply_Handler.inl: + * tao/DynamicInterface/DII_Reply_Handler.cpp: + * tao/DynamicInterface/Request.h: + * tao/DynamicInterface/Request.cpp: + + * tao/Invocation_Utils.h: + + Extended TAO for support the combination of DSI and AMH. diff --git a/TAO/tao/DynamicInterface/DII_Invocation.h b/TAO/tao/DynamicInterface/DII_Invocation.h index ba3a5a6be66..ebca5adce29 100644 --- a/TAO/tao/DynamicInterface/DII_Invocation.h +++ b/TAO/tao/DynamicInterface/DII_Invocation.h @@ -31,6 +31,7 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL class TAO_DII_Deferred_Reply_Dispatcher; +class TAO_DII_Asynch_Reply_Dispatcher; namespace Dynamic { @@ -113,6 +114,42 @@ namespace TAO CORBA::Request_ptr host_; }; + +class TAO_DynamicInterface_Export TAO_GIOP_DII_Asynch_Invocation + : public TAO::Asynch_Remote_Invocation +{ + // = TITLE + // Sends a two-way request using DII and does not wait for a reply. + // + // = DESCRIPTION + // This class connects (or looks up a connection from the cache) to + // the remote server, builds the CDR stream for the Request, send + // the CDR stream and returns. + // +public: + TAO_GIOP_DII_Asynch_Invocation (TAO_Stub *data, + TAO_ORB_Core* orb_core, + CORBA::Boolean argument_flag, + const CORBA::Request_ptr req, + CORBA::Object_ptr reply_handler, + int byte_order = TAO_ENCAP_BYTE_ORDER); + // Constructor. + + int invoke (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + // Send request, block until any reply comes back, and unmarshal + // reply parameters as appropriate. + +private: + int invoke_i (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + // Implementation of the invoke() methods, handles the basic + // send/reply code and the system exceptions. + + TAO_DII_Asynch_Reply_Dispatcher *rd_; + // Reply dispatcher for the current synchronous Asynch_Invocation. +}; + } TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/DynamicInterface/DII_Invocation_Adapter.cpp b/TAO/tao/DynamicInterface/DII_Invocation_Adapter.cpp index 441c1df2f92..f7a29f0bf92 100644 --- a/TAO/tao/DynamicInterface/DII_Invocation_Adapter.cpp +++ b/TAO/tao/DynamicInterface/DII_Invocation_Adapter.cpp @@ -191,6 +191,47 @@ namespace TAO return status; } -} // End namespace TAO + DII_Asynch_Invocation_Adapter + ::DII_Asynch_Invocation_Adapter (CORBA::Object *target, + Argument **args, + int arg_count, + const char *operation, + int op_len, + CORBA::Request *req, + TAO::Invocation_Mode mode) + : DII_Invocation_Adapter (target, + args, + arg_count, + operation, + op_len, + 0, + req, + mode) + { + } + + void + DII_Asynch_Invocation_Adapter::invoke (Messaging::ReplyHandler_ptr rh + ACE_ENV_ARG_DECL) + { + ACE_UNUSED_ARG (rh); + } + + Invocation_Status + DII_Asynch_Invocation_Adapter::invoke_twoway ( + TAO_Operation_Details & op , + CORBA::Object_var &effective_target, + Profile_Transport_Resolver &r, + ACE_Time_Value *&max_wait_time + ACE_ENV_ARG_DECL) + { + ACE_UNUSED_ARG (op); + ACE_UNUSED_ARG (effective_target); + ACE_UNUSED_ARG (r); + ACE_UNUSED_ARG (max_wait_time); + return TAO_INVOKE_FAILURE; + } + +} // End namespace TAO TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/DynamicInterface/DII_Invocation_Adapter.h b/TAO/tao/DynamicInterface/DII_Invocation_Adapter.h index ac5b8e9dfd7..c5f89bc129e 100644 --- a/TAO/tao/DynamicInterface/DII_Invocation_Adapter.h +++ b/TAO/tao/DynamicInterface/DII_Invocation_Adapter.h @@ -21,6 +21,7 @@ #include "tao/Invocation_Adapter.h" +#include "tao/Messaging/Messaging.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL class ACE_Time_Value; @@ -155,6 +156,44 @@ namespace TAO /// Cache the orb_core TAO_ORB_Core * const orb_core_; }; + +/** + * + */ +class TAO_DynamicInterface_Export DII_Asynch_Invocation_Adapter + : protected DII_Invocation_Adapter +{ +public: + DII_Asynch_Invocation_Adapter ( + CORBA::Object *target, + Argument **args, + int arg_number, + const char *operation, + int op_len, + + CORBA::Request *req, + TAO::Invocation_Mode mode = TAO_DII_ASYNCH_INVOCATION); + + /// Invoke the target + void invoke (Messaging::ReplyHandler_ptr reply_handler_ptr + ACE_ENV_ARG_DECL); + + +protected: + virtual Invocation_Status invoke_twoway ( + TAO_Operation_Details &op, + CORBA::Object_var &effective_target, + Profile_Transport_Resolver &r, + ACE_Time_Value *&max_wait_time + ACE_ENV_ARG_DECL); + +private: + /// Reply dispatcher for the current Invocation. + TAO_DII_Deferred_Reply_Dispatcher *rd_; + + /// Cache the orb_core + TAO_ORB_Core *orb_core_; +}; } // End namespace TAO TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/DynamicInterface/DII_Reply_Dispatcher.cpp b/TAO/tao/DynamicInterface/DII_Reply_Dispatcher.cpp index 877570d611a..cce81c3d353 100644 --- a/TAO/tao/DynamicInterface/DII_Reply_Dispatcher.cpp +++ b/TAO/tao/DynamicInterface/DII_Reply_Dispatcher.cpp @@ -144,4 +144,127 @@ TAO_DII_Deferred_Reply_Dispatcher::connection_closed (void) (void) this->decr_refcount (); } +// Constructor. +TAO_DII_Asynch_Reply_Dispatcher::TAO_DII_Asynch_Reply_Dispatcher ( + const Messaging::ReplyHandler_ptr callback, + TAO_ORB_Core *orb_core) + : TAO_Asynch_Reply_Dispatcher_Base (orb_core), + db_ (sizeof buf_, + ACE_Message_Block::MB_DATA, + this->buf_, + orb_core->input_cdr_buffer_allocator (), + orb_core->locking_strategy (), + ACE_Message_Block::DONT_DELETE, + orb_core->input_cdr_dblock_allocator ()), + reply_cdr_ (&db_, + ACE_Message_Block::DONT_DELETE, + TAO_ENCAP_BYTE_ORDER, + TAO_DEF_GIOP_MAJOR, + TAO_DEF_GIOP_MINOR, + orb_core), + callback_ (callback) +{ +} + +// Destructor. +TAO_DII_Asynch_Reply_Dispatcher::~TAO_DII_Asynch_Reply_Dispatcher (void) +{ + // this was handed to us by the caller. + CORBA::release(callback_); +} + +// Dispatch the reply. +int +TAO_DII_Asynch_Reply_Dispatcher::dispatch_reply ( + TAO_Pluggable_Reply_Params ¶ms + ) +{ + this->reply_status_ = params.reply_status_; + + // Transfer the <params.input_cdr_>'s content to this->reply_cdr_ + ACE_Data_Block *db = + this->reply_cdr_.clone_from (*params.input_cdr_); + + // See whether we need to delete the data block by checking the + // flags. We cannot be happy that we initally allocated the + // datablocks of the stack. If this method is called twice, as is in + // some cases where the same invocation object is used to make two + // invocations like forwarding, the release becomes essential. + if (ACE_BIT_DISABLED (db->flags (), + ACE_Message_Block::DONT_DELETE)) + db->release (); + + // Steal the buffer, that way we don't do any unnecesary copies of + // this data. + CORBA::ULong max = params.svc_ctx_.maximum (); + CORBA::ULong len = params.svc_ctx_.length (); + IOP::ServiceContext* context_list = params.svc_ctx_.get_buffer (1); + this->reply_service_info_.replace (max, len, context_list, 1); + + if (TAO_debug_level >= 4) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P | %t):TAO_DII_Asynch_Reply_Dispatcher::dispatch_reply: status = %d\n"), this->reply_status_)); + } + + ACE_TRY_NEW_ENV + { + // Call the handler with the reply data. + CORBA::Request::_tao_reply_stub (this->reply_cdr_, + this->callback_, + this->reply_status_ + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + if (TAO_debug_level >= 4) + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Exception during reply handler"); + } + } + ACE_ENDTRY; + // This was dynamically allocated. Now the job is done. Commit + // suicide here. + delete this; + + return 1; +} + +void +TAO_DII_Asynch_Reply_Dispatcher::connection_closed (void) +{ + ACE_TRY_NEW_ENV + { + // Generate a fake exception.... + CORBA::COMM_FAILURE comm_failure (0, + CORBA::COMPLETED_MAYBE); + + TAO_OutputCDR out_cdr; + + comm_failure._tao_encode (out_cdr + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Turn into an output CDR + TAO_InputCDR cdr (out_cdr); + CORBA::Request::_tao_reply_stub (this->reply_cdr_, + this->callback_, + TAO_PLUGGABLE_MESSAGE_SYSTEM_EXCEPTION + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + if (TAO_debug_level >= 4) + { + ACE_PRINT_EXCEPTION ( + ACE_ANY_EXCEPTION, + "DII_Asynch_Reply_Dispacher::connection_closed" + ); + } + } + ACE_ENDTRY; +} TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/DynamicInterface/DII_Reply_Dispatcher.h b/TAO/tao/DynamicInterface/DII_Reply_Dispatcher.h index cb450106c5d..9f403653bb5 100644 --- a/TAO/tao/DynamicInterface/DII_Reply_Dispatcher.h +++ b/TAO/tao/DynamicInterface/DII_Reply_Dispatcher.h @@ -24,6 +24,7 @@ #include "tao/orbconf.h" #include "tao/Asynch_Reply_Dispatcher_Base.h" +#include "tao/Messaging/Messaging.h" TAO_BEGIN_VERSIONED_NAMESPACE_DECL @@ -73,6 +74,44 @@ private: const CORBA::Request_ptr req_; }; +class TAO_DynamicInterface_Export TAO_DII_Asynch_Reply_Dispatcher + : public TAO_Asynch_Reply_Dispatcher_Base +{ + // = TITLE + // TAO_DII_Asynch_Reply_Dispatcher + // + // = DESCRIPTION + // Reply dispatcher for DII deferred requests. + // +public: + TAO_DII_Asynch_Reply_Dispatcher (const Messaging::ReplyHandler_ptr callback, + TAO_ORB_Core *orb_core); + // Constructor. + + virtual ~TAO_DII_Asynch_Reply_Dispatcher (void); + // Destructor. + + // = The Reply_Dispatcher methods + virtual int dispatch_reply (TAO_Pluggable_Reply_Params ¶m); + + virtual void connection_closed (void); + +private: + + /// The buffer that is used to initialise the data block + char buf_[ACE_CDR::DEFAULT_BUFSIZE]; + + /// datablock that is created on teh stack to initialise the CDR + /// stream underneath. + ACE_Data_Block db_; + + /// CDR stream for reading the input. + TAO_InputCDR reply_cdr_; + + /// Where the reply needs to go. + const Messaging::ReplyHandler_ptr callback_; +}; + TAO_END_VERSIONED_NAMESPACE_DECL #include /**/ "ace/post.h" diff --git a/TAO/tao/DynamicInterface/DII_Reply_Handler.cpp b/TAO/tao/DynamicInterface/DII_Reply_Handler.cpp new file mode 100644 index 00000000000..94e9964f1fa --- /dev/null +++ b/TAO/tao/DynamicInterface/DII_Reply_Handler.cpp @@ -0,0 +1,59 @@ +#include "DynamicInterface/dynamicinterface_pch.h" +#include "Request.h" +// $Id$ + +ACE_RCSID(DynamicInterface, Request, "$Id$") + +#include "ExceptionList.h" +#include "DII_Invocation.h" + +#if defined (TAO_HAS_AMI) +#include "DII_Reply_Handler.h" +#endif /* TAO_HAS_AMI */ + +#include "tao/Object.h" +#include "tao/Pluggable_Messaging_Utils.h" + +#if !defined (__ACE_INLINE__) +# include "DII_Reply_Handler.inl" +#endif /* ! __ACE_INLINE__ */ + + +// The pseudo-object _nil method. +TAO_DII_Reply_Handler_ptr +TAO_DII_Reply_Handler::_nil (void) +{ + return (TAO_DII_Reply_Handler_ptr)0; +} + +// DII Request class implementation + +int TAO_DII_Reply_Handler::_tao_class_id = 0; +TAO_DII_Reply_Handler::TAO_DII_Reply_Handler () +{ +} + +TAO_DII_Reply_Handler::~TAO_DII_Reply_Handler (void) +{ +} + +TAO_DII_Reply_Handler_ptr +TAO_DII_Reply_Handler::_narrow (CORBA::Object_ptr obj + ACE_ENV_ARG_DECL) +{ + return TAO_DII_Reply_Handler::_unchecked_narrow (obj + ACE_ENV_ARG_PARAMETER); +} + +TAO_DII_Reply_Handler_ptr +TAO_DII_Reply_Handler::_unchecked_narrow (CORBA::Object_ptr obj + ACE_ENV_ARG_DECL) +{ + if (CORBA::is_nil (obj)) + return TAO_DII_Reply_Handler::_nil (); + + return + ACE_reinterpret_cast (TAO_DII_Reply_Handler_ptr, + &TAO_DII_Reply_Handler::_tao_class_id); +} + diff --git a/TAO/tao/DynamicInterface/DII_Reply_Handler.h b/TAO/tao/DynamicInterface/DII_Reply_Handler.h new file mode 100644 index 00000000000..3109c0aa2e6 --- /dev/null +++ b/TAO/tao/DynamicInterface/DII_Reply_Handler.h @@ -0,0 +1,122 @@ +// This may look like C, but it's really -*- C++ -*- +// $Id$ + + +// ============================================================================ +// +// = LIBRARY +// TAO_DynamicInvocation +// +// = FILENAME +// DII_Reply_Handler.h +// +// = DESCRIPTION +// Header file for handler of DII twoway asynch replies +// type. +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems, Inc. +// Adapted from Request.h by Phil Mesnier <mesnier_p@ociweb.com> +// +// ============================================================================ + +#ifndef TAO_DII_REPLY_HANDLER_H +#define TAO_DII_REPLY_HANDLER_H +#include "ace/pre.h" + +#include "tao/orbconf.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/LocalObject.h" +#include "dynamicinterface_export.h" + +class TAO_DII_Reply_Handler; +typedef TAO_DII_Reply_Handler* TAO_DII_Reply_Handler_ptr; + +class TAO_DynamicInterface_Export TAO_DII_Reply_Handler_var +{ + // = TITLE + // The T_var class for Request. + // + // = DESCRIPTION + // As any other pseudo object Request must have a T_var class, + // the interface an semantics are specified in the CORBA spec. + // + // = NOTE + // We use TAO_DII_Reply_Handler_ptr as the _ptr type instead of + // CORBA::Request_ptr, this is an attempt to reduced the cyclic + // dependencies in TAO. + // +public: + TAO_DII_Reply_Handler_var (void); + TAO_DII_Reply_Handler_var (TAO_DII_Reply_Handler_ptr); + TAO_DII_Reply_Handler_var (const TAO_DII_Reply_Handler_var &); + ~TAO_DII_Reply_Handler_var (void); + + TAO_DII_Reply_Handler_var &operator= (TAO_DII_Reply_Handler_ptr); + TAO_DII_Reply_Handler_var &operator= (const TAO_DII_Reply_Handler_var &); + TAO_DII_Reply_Handler_ptr operator-> (void) const; + + operator const TAO_DII_Reply_Handler_ptr &() const; + operator TAO_DII_Reply_Handler_ptr &(); + + // in, inout, out, _retn. + TAO_DII_Reply_Handler_ptr in (void) const; + TAO_DII_Reply_Handler_ptr &inout (void); + TAO_DII_Reply_Handler_ptr &out (void); + TAO_DII_Reply_Handler_ptr _retn (void); + TAO_DII_Reply_Handler_ptr ptr (void) const; + +private: + TAO_DII_Reply_Handler_ptr ptr_; +}; + +class TAO_DynamicInterface_Export TAO_DII_Reply_Handler + : public virtual TAO_Local_RefCounted_Object +{ + // = TITLE + // TAO_DII_Reply_Handler + // + // = DESCRIPTION + // Provides a way to create requests and populate it with parameters for + // use in the Dynamic Invocation Interface. + // +public: + TAO_DII_Reply_Handler (); + virtual ~TAO_DII_Reply_Handler (void); + + // Callback method for deferred synchronous requests. + virtual void handle_response (TAO_InputCDR &incoming + ACE_ENV_ARG_DECL_WITH_DEFAULTS) = 0; + + virtual void handle_excep (TAO_InputCDR &incoming, + CORBA::ULong reply_status + ACE_ENV_ARG_DECL_WITH_DEFAULTS) = 0; + + // CORBA Object related methods + static TAO_DII_Reply_Handler* _duplicate (TAO_DII_Reply_Handler_ptr); + static TAO_DII_Reply_Handler* _nil (void); + static TAO_DII_Reply_Handler* _narrow (CORBA::Object_ptr + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + static TAO_DII_Reply_Handler* _unchecked_narrow (CORBA::Object_ptr + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + + static int _tao_class_id; + +#if !defined(__GNUC__) || __GNUC__ > 2 || __GNUC_MINOR__ >= 8 + typedef TAO_DII_Reply_Handler_ptr _ptr_type; + typedef TAO_DII_Reply_Handler_var _var_type; +#endif /* __GNUC__ */ + // Useful for template programming. + +}; + +#if defined (__ACE_INLINE__) +# include "DII_Reply_Handler.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_DII_REPLY_HANDLER_H */ diff --git a/TAO/tao/DynamicInterface/DII_Reply_Handler.inl b/TAO/tao/DynamicInterface/DII_Reply_Handler.inl new file mode 100644 index 00000000000..957ebc9684b --- /dev/null +++ b/TAO/tao/DynamicInterface/DII_Reply_Handler.inl @@ -0,0 +1,111 @@ +// -*- C++ -*- +// $Id$ + +ACE_INLINE TAO_DII_Reply_Handler_ptr +TAO_DII_Reply_Handler::_duplicate (TAO_DII_Reply_Handler_ptr x) +{ + if (x != 0) + { + x->_add_ref (); + } + + return x; +} + +// ************************************************************* +// Inline operations for class TAO_DII_Reply_Handler_var +// ************************************************************* + +ACE_INLINE +TAO_DII_Reply_Handler_var::TAO_DII_Reply_Handler_var (void) + : ptr_ (TAO_DII_Reply_Handler::_nil ()) +{ +} + +ACE_INLINE +TAO_DII_Reply_Handler_var::TAO_DII_Reply_Handler_var (TAO_DII_Reply_Handler_ptr p) + : ptr_ (p) +{} + +ACE_INLINE +TAO_DII_Reply_Handler_var::~TAO_DII_Reply_Handler_var (void) +{ + CORBA::release (this->ptr_); +} + +ACE_INLINE TAO_DII_Reply_Handler_ptr +TAO_DII_Reply_Handler_var::ptr (void) const +{ + return this->ptr_; +} + +ACE_INLINE +TAO_DII_Reply_Handler_var::TAO_DII_Reply_Handler_var (const TAO_DII_Reply_Handler_var &p) + : ptr_ (TAO_DII_Reply_Handler::_duplicate (p.ptr ())) +{} + +ACE_INLINE TAO_DII_Reply_Handler_var & +TAO_DII_Reply_Handler_var::operator= (TAO_DII_Reply_Handler_ptr p) +{ + CORBA::release (this->ptr_); + this->ptr_ = p; + return *this; +} + +ACE_INLINE TAO_DII_Reply_Handler_var & +TAO_DII_Reply_Handler_var::operator= (const TAO_DII_Reply_Handler_var &p) +{ + if (this != &p) + { + CORBA::release (this->ptr_); + this->ptr_ = TAO_DII_Reply_Handler::_duplicate (p.ptr ()); + } + return *this; +} + +ACE_INLINE +TAO_DII_Reply_Handler_var::operator const TAO_DII_Reply_Handler_ptr &() const +{ + return this->ptr_; +} + +ACE_INLINE +TAO_DII_Reply_Handler_var::operator TAO_DII_Reply_Handler_ptr &() +{ + return this->ptr_; +} + +ACE_INLINE TAO_DII_Reply_Handler_ptr +TAO_DII_Reply_Handler_var::operator-> (void) const +{ + return this->ptr_; +} + +ACE_INLINE TAO_DII_Reply_Handler_ptr +TAO_DII_Reply_Handler_var::in (void) const +{ + return this->ptr_; +} + +ACE_INLINE TAO_DII_Reply_Handler_ptr & +TAO_DII_Reply_Handler_var::inout (void) +{ + return this->ptr_; +} + +ACE_INLINE TAO_DII_Reply_Handler_ptr & +TAO_DII_Reply_Handler_var::out (void) +{ + CORBA::release (this->ptr_); + this->ptr_ = TAO_DII_Reply_Handler::_nil (); + return this->ptr_; +} + +ACE_INLINE TAO_DII_Reply_Handler_ptr +TAO_DII_Reply_Handler_var::_retn (void) +{ + // yield ownership + TAO_DII_Reply_Handler_ptr val = this->ptr_; + this->ptr_ = TAO_DII_Reply_Handler::_nil (); + return val; +} diff --git a/TAO/tao/DynamicInterface/Request.cpp b/TAO/tao/DynamicInterface/Request.cpp index 34519883c93..324224b21b2 100644 --- a/TAO/tao/DynamicInterface/Request.cpp +++ b/TAO/tao/DynamicInterface/Request.cpp @@ -10,6 +10,11 @@ ACE_RCSID (DynamicInterface, #include "tao/DynamicInterface/DII_Arguments.h" #include "tao/DynamicInterface/Context.h" +#if defined (TAO_HAS_AMI) +#include "tao/Messaging/Asynch_Invocation_Adapter.h" +#include "tao/DynamicInterface/DII_Reply_Handler.h" +#endif /* TAO_HAS_AMI */ + #include "tao/AnyTypeCode/NVList.h" #include "tao/Object.h" #include "tao/Pluggable_Messaging_Utils.h" @@ -250,6 +255,68 @@ CORBA::Request::send_deferred (ACE_ENV_SINGLE_ARG_DECL) ACE_CHECK; } +#if defined (TAO_HAS_AMI) +void +CORBA::Request::sendc (CORBA::Object_ptr handler + ACE_ENV_ARG_DECL) +{ + 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 + ACE_ENV_ARG_PARAMETER); + +} + +void +CORBA::Request::_tao_reply_stub (TAO_InputCDR &_tao_in, + Messaging::ReplyHandler_ptr rh, + CORBA::ULong reply_status + ACE_ENV_ARG_DECL) +{ + // Retrieve Reply Handler object. + TAO_DII_Reply_Handler* reply_handler = dynamic_cast<TAO_DII_Reply_Handler*> (rh); + ACE_CHECK; + + // Exception handling + switch (reply_status) + { + case TAO_AMI_REPLY_OK: + case TAO_AMI_REPLY_NOT_OK: + { + reply_handler->handle_response(_tao_in ACE_ENV_ARG_PARAMETER); + break; + } + case TAO_AMI_REPLY_USER_EXCEPTION: + case TAO_AMI_REPLY_SYSTEM_EXCEPTION: + { + reply_handler->handle_excep (_tao_in, + reply_status + ACE_ENV_ARG_PARAMETER); + + break; + } + } +} +#endif /* TAO_HAS_AMI */ + void CORBA::Request::get_response (ACE_ENV_SINGLE_ARG_DECL) { diff --git a/TAO/tao/DynamicInterface/Request.h b/TAO/tao/DynamicInterface/Request.h index f7c13f398ab..649eb55d98b 100644 --- a/TAO/tao/DynamicInterface/Request.h +++ b/TAO/tao/DynamicInterface/Request.h @@ -35,6 +35,7 @@ #include "tao/Environment.h" #include "tao/CDR.h" #include "tao/AnyTypeCode/NVList.h" +#include "tao/Messaging/Messaging.h" #include "ace/SString.h" @@ -149,9 +150,24 @@ namespace CORBA //@} /// Callback method for deferred synchronous requests. - void handle_response (TAO_InputCDR &incoming, - CORBA::ULong reply_status - ACE_ENV_ARG_DECL_WITH_DEFAULTS); + void handle_response (TAO_InputCDR &incoming, + CORBA::ULong reply_status + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + +#if defined (TAO_HAS_AMI) + // The 'asychronous' send method. The object is a DSI based callback + // handler. This handler must implement Messaging::ReplyHandler + void sendc (CORBA::Object_ptr handler + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + + static void _tao_reply_stub ( + TAO_InputCDR &_tao_reply_cdr, + Messaging::ReplyHandler_ptr _tao_reply_handler, + CORBA::ULong reply_status + ACE_ENV_ARG_DECL_WITH_DEFAULTS + ); +#endif + /// Pseudo object methods. static CORBA::Request* _duplicate (CORBA::Request*); diff --git a/TAO/tao/Invocation_Utils.h b/TAO/tao/Invocation_Utils.h index d63994908f0..d719a87c7e1 100644 --- a/TAO/tao/Invocation_Utils.h +++ b/TAO/tao/Invocation_Utils.h @@ -67,7 +67,8 @@ namespace TAO TAO_ASYNCHRONOUS_POLLER_INVOCATION, /// Types of DII TAO_DII_INVOCATION, - TAO_DII_DEFERRED_INVOCATION + TAO_DII_DEFERRED_INVOCATION, + TAO_DII_ASYNCH_INVOCATION }; } |