diff options
author | bala <balanatarajan@users.noreply.github.com> | 2003-07-09 01:32:50 +0000 |
---|---|---|
committer | bala <balanatarajan@users.noreply.github.com> | 2003-07-09 01:32:50 +0000 |
commit | 9b1ead4470594250ce3d8be2674188b0c5c83fce (patch) | |
tree | a5f1be81d1e2ca1a2d88ce5ac9de4a86b85f12cf /TAO | |
parent | 424c95433da9d8019923f6f804e288f5d141fc32 (diff) | |
download | ATCD-9b1ead4470594250ce3d8be2674188b0c5c83fce.tar.gz |
ChangeLogTag:Tue Jul 8 20:24:06 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu>
Diffstat (limited to 'TAO')
-rw-r--r-- | TAO/ChangeLog_ref | 26 | ||||
-rw-r--r-- | TAO/tao/Invocation_Base.cpp | 20 | ||||
-rw-r--r-- | TAO/tao/Invocation_Base.h | 2 | ||||
-rw-r--r-- | TAO/tao/Synch_Invocation.cpp | 68 | ||||
-rw-r--r-- | TAO/tao/Synch_Invocation.h | 3 | ||||
-rw-r--r-- | TAO/tao/TODO | 8 | ||||
-rw-r--r-- | TAO/tao/UB_String_Argument_T.cpp | 4 | ||||
-rw-r--r-- | TAO/tao/operation_details.cpp | 35 | ||||
-rw-r--r-- | TAO/tao/operation_details.h | 27 | ||||
-rw-r--r-- | TAO/tao/operation_details.i | 18 |
10 files changed, 183 insertions, 28 deletions
diff --git a/TAO/ChangeLog_ref b/TAO/ChangeLog_ref index 8c31d684633..1c43d6094ec 100644 --- a/TAO/ChangeLog_ref +++ b/TAO/ChangeLog_ref @@ -1,3 +1,29 @@ +Tue Jul 8 20:24:06 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu> + + * tao/operation_details.i: + * tao/operation_details.cpp (corba_exception): + * tao/operation_details.h: This class will henceforth have the + information about the exceptions declared in the IDL for every + operation. This detail would be used by the ORB to find out the + right exception that needs to be raised if the incoming GIOP + message is flagged as a user defined exception. This information + is used by the new Invocation classes. A new method, + corba_exception () has been added which converts a repo id into + an equivalent CORBA exception + + * tao/Invocation_Base.h: + * tao/Invocation_Base.cpp: The invoke () creates the + TAO_Operation_Details object with the exception list and a count + of the number of the exceptions specified in the IDL file. + + * tao/Synch_Invocation.h: + * tao/Synch_Invocation.cpp: Added support for raising the right + type of user exceptions to the application if the message + received indicates the content to be of type user exception. + + * tao/UB_String_Argument_T.cpp: Fixed compile errors on win32 by + applying the right const qualifier. + Tue Jul 8 15:00:12 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu> * tao/Synch_Invocation.cpp (TAO): diff --git a/TAO/tao/Invocation_Base.cpp b/TAO/tao/Invocation_Base.cpp index d41befe81ca..648deb66e15 100644 --- a/TAO/tao/Invocation_Base.cpp +++ b/TAO/tao/Invocation_Base.cpp @@ -38,8 +38,8 @@ Invocation_Base::Invocation_Base (CORBA::Object *target, void - Invocation_Base::invoke (TAO_Exception_Data * /*ex_data*/, - long /*ex_count*/ + Invocation_Base::invoke (TAO_Exception_Data *ex_data, + unsigned long ex_count ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { @@ -59,19 +59,25 @@ Invocation_Base::Invocation_Base (CORBA::Object *target, /*if (stub->orb_core ()->is_service_invocation ()) return stub->orb_core ()->invoke_services (); */ + + // Initial state TAO::Invocation_Status status = TAO_INVOKE_START; - while (status != TAO_INVOKE_SUCCESS) + TAO_Operation_Details op_details (this->operation_, + this->op_len_, + this->number_args_ != 0, + ex_data, + ex_count); + + while (status != TAO_INVOKE_SUCCESS || + status != TAO_INVOKE_FAILURE) { Profile_Transport_Resolver resolver (stub); resolver.resolve (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; - TAO_Operation_Details op_details (this->operation_, - this->op_len_, - this->number_args_ != 0); - + // Update the request id now that we have a transport op_details.request_id (resolver.transport ()->tms ()->request_id ()); if (this->type_ == TAO_ONEWAY_INVOCATION) diff --git a/TAO/tao/Invocation_Base.h b/TAO/tao/Invocation_Base.h index eac6b0e9a7a..8ad3f74c729 100644 --- a/TAO/tao/Invocation_Base.h +++ b/TAO/tao/Invocation_Base.h @@ -77,7 +77,7 @@ namespace TAO void invoke (TAO_Exception_Data *ex, - long ex_count + unsigned long ex_count ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)); diff --git a/TAO/tao/Synch_Invocation.cpp b/TAO/tao/Synch_Invocation.cpp index e98e7407194..f802e989359 100644 --- a/TAO/tao/Synch_Invocation.cpp +++ b/TAO/tao/Synch_Invocation.cpp @@ -115,6 +115,11 @@ namespace TAO int i = 0; + // At this point it can be assumed that the GIOP/whatever protocol + // header and the reply header are already handled. Further it + // can be assumed that the reply body contains the details + // required for further processing. All the other details should + // have been handled in the reply dispatcher/protocol framework. switch (rd.reply_status ()) { case TAO_PLUGGABLE_MESSAGE_NO_EXCEPTION: @@ -131,12 +136,11 @@ namespace TAO return this->location_forward (cdr ACE_ENV_ARG_PARAMETER); case TAO_PLUGGABLE_MESSAGE_USER_EXCEPTION: - // return this->handle_user_exception (ACE_ENV_SINGLE_ARG_PARAMETER); - break; + return this->handle_user_exception (cdr + ACE_ENV_ARG_PARAMETER); case TAO_PLUGGABLE_MESSAGE_SYSTEM_EXCEPTION: // return this->handle_system_exception (ACE_ENV_SINGLE_ARG_PARAMETER) break; - #if 0 { // @@ Add the location macros for this exceptions... @@ -232,11 +236,6 @@ namespace TAO { CORBA::Object_var forward_reference; - // It can be assumed that the GIOP header and the reply header - // are already handled. Further it can be assumed that the - // reply body contains an object reference to the new object. - // This object pointer will be now extracted. - if ((inp_stream >> forward_reference.out ()) == 0) { ACE_THROW_RETURN (CORBA::MARSHAL (), @@ -266,8 +265,59 @@ namespace TAO return TAO_INVOKE_RESTART; } + Invocation_Status + Synch_Twoway_Invocation::handle_user_exception (TAO_InputCDR &cdr + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + // Pull the exception from the stream. + CORBA::String_var buf; + + if ((cdr >> buf.inout ()) == 0) + { + // Could not demarshal the exception id, raise an local + // CORBA::MARSHAL + ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, + CORBA::COMPLETED_MAYBE), + TAO_INVOKE_FAILURE); + } + + CORBA::Exception *exception = + this->detail_.corba_exception (buf.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO_INVOKE_FAILURE); + + exception->_tao_decode (cdr + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (TAO_INVOKE_FAILURE); + + if (TAO_debug_level > 5) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO: (%P|%t) Synch_Twoway_Invocation::handle_user_exception - ") + ACE_TEXT ("raising exception %s\n"), + buf.in ())); + } + + // @@ Think about a better way to raise the exception here, + // maybe we need some more macros? +#if defined (TAO_HAS_EXCEPTIONS) + // If we have native exceptions, we must manage the memory allocated + // by the call above to alloc(). Otherwise the Environment class + // manages the memory. + auto_ptr<CORBA::Exception> safety (exception); + + // Direct throw because we don't have the ACE_TRY_ENV. + exception->_raise (); +#else + // We can not use ACE_THROW here. + ACE_TRY_ENV.exception (exception); +#endif + + return TAO_INVOKE_SUCCESS; + } - /*************************************************************************/ +/*================================================================================*/ Synch_Oneway_Invocation::Synch_Oneway_Invocation (Profile_Transport_Resolver &r, TAO_Operation_Details &d) diff --git a/TAO/tao/Synch_Invocation.h b/TAO/tao/Synch_Invocation.h index 34c82839ebf..714ec2c6395 100644 --- a/TAO/tao/Synch_Invocation.h +++ b/TAO/tao/Synch_Invocation.h @@ -52,6 +52,9 @@ namespace TAO ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)); + Invocation_Status handle_user_exception (TAO_InputCDR &cdr + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); private: Invocation_Status check_reply_status (TAO_Synch_Reply_Dispatcher &rd, diff --git a/TAO/tao/TODO b/TAO/tao/TODO index e19eae26cbf..63ac211feec 100644 --- a/TAO/tao/TODO +++ b/TAO/tao/TODO @@ -4,4 +4,10 @@ . Oneways and Asynch invocation (needs investigation) . type of exception thrown to the client. Is it CORBA exception or C++ - exception if you receive one?
\ No newline at end of file + exception if you receive one? + +. Test Location forwards + +. test user exceptions + +. Move TAO_Exception_Data elsewhere diff --git a/TAO/tao/UB_String_Argument_T.cpp b/TAO/tao/UB_String_Argument_T.cpp index 3d6d83a3006..60016cb9250 100644 --- a/TAO/tao/UB_String_Argument_T.cpp +++ b/TAO/tao/UB_String_Argument_T.cpp @@ -70,7 +70,7 @@ template<typename S> CORBA::Boolean TAO::Inout_UB_String_Argument_T<S>::interceptor_replace (CORBA::Any & any) { - return any >>= (const S*) this->x_; + return any >>= (const S*&) this->x_; } // ============================================================== @@ -112,7 +112,7 @@ template<typename S, typename S_var> CORBA::Boolean TAO::Ret_UB_String_Argument_T<S,S_var>::interceptor_replace (CORBA::Any & any) { - return any >>= (const S *)this->x_.inout (); + return any >>= (const S*&) this->x_.inout (); } template<typename S, typename S_var> diff --git a/TAO/tao/operation_details.cpp b/TAO/tao/operation_details.cpp index 448b80e3a57..5f932f8da23 100644 --- a/TAO/tao/operation_details.cpp +++ b/TAO/tao/operation_details.cpp @@ -1,6 +1,41 @@ //$Id$ #include "tao/operation_details.h" +#include "tao/Stub.h" #if !defined (__ACE_INLINE__) # include "tao/operation_details.i" #endif /* ! __ACE_INLINE__ */ + +ACE_RCSID (tao, + operation_details, + "$Id$") + +CORBA::Exception * +TAO_Operation_Details::corba_exception (const char *id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + for (CORBA::ULong i = 0; i < this->ex_count_; ++i) + { + if (ACE_OS::strcmp (id, + this->ex_data_[i].id) != 0) + { + continue; + } + + // Create an exception object + CORBA::Exception *exception = + this->ex_data_[i].alloc (); + + if (exception == 0) + { + ACE_THROW_RETURN (CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE, + CORBA::COMPLETED_YES), + 0); + } + } + + ACE_THROW_RETURN (CORBA::UNKNOWN (TAO_DEFAULT_MINOR_CODE, + CORBA::COMPLETED_YES), + 0); +} diff --git a/TAO/tao/operation_details.h b/TAO/tao/operation_details.h index 3f867c3dd06..f5c424036cd 100644 --- a/TAO/tao/operation_details.h +++ b/TAO/tao/operation_details.h @@ -23,7 +23,12 @@ #include "Service_Context.h" #include "target_specification.h" +struct TAO_Exception_Data; +namespace CORBA +{ + class Exception; +} /** * @class TAO_Operation_Details * @@ -42,7 +47,9 @@ public: ///Constructor TAO_Operation_Details (const char *name, CORBA::ULong len, - CORBA::Boolean argument_flag); + CORBA::Boolean argument_flag, + TAO_Exception_Data *ex_data = 0, + CORBA::Long ex_count = 0); /// Operation name const char* opname (void) const; @@ -90,6 +97,18 @@ public: /// Set method for the addressing mode void addressing_mode (CORBA::Short addr); + /// Creates and returns a CORBA::Exception object whose repository + /// id \a ex matches the exception list that this operation + /// specified. + /** + * This step is important to decode the exception that the client + * got from the server. If the exception received from the server + * is not found in the list of exceptions specified by the operation + * this call would raise an UNKNOWN exception. + */ + CORBA::Exception *corba_exception (const char *ex + ACE_ENV_ARG_DECL); + private: /// Name of the operation being invoked. @@ -127,6 +146,12 @@ private: /// Addressing mode for this request. TAO_Target_Specification::TAO_Target_Address addressing_mode_; + + /// The type of exceptions that the operations can throw. + TAO_Exception_Data *ex_data_; + + /// Count of the exceptions that operations can throw. + CORBA::ULong ex_count_; }; #if defined (__ACE_INLINE__) diff --git a/TAO/tao/operation_details.i b/TAO/tao/operation_details.i index 5987b895223..b873a3b0dac 100644 --- a/TAO/tao/operation_details.i +++ b/TAO/tao/operation_details.i @@ -5,13 +5,17 @@ ACE_INLINE TAO_Operation_Details::TAO_Operation_Details (const char *name, CORBA::ULong len, - CORBA::Boolean argument_flag) - : opname_ (name), - opname_len_ (len), - request_id_ (0), - argument_flag_ (argument_flag), - response_flags_ (0), - addressing_mode_ (TAO_Target_Specification::Key_Addr) + CORBA::Boolean argument_flag, + TAO_Exception_Data *data, + CORBA::Long count) + : opname_ (name) + , opname_len_ (len) + , request_id_ (0) + , argument_flag_ (argument_flag) + , response_flags_ (0) + , addressing_mode_ (TAO_Target_Specification::Key_Addr) + , ex_data_ (data) + , ex_count_ (count) { } |