Go to the documentation of this file.00001
00002
00003
00004 #include "tao/Messaging/ExceptionHolder_i.h"
00005
00006 ACE_RCSID (Messaging,
00007 ExceptionHolder_i,
00008 "$Id: ExceptionHolder_i.cpp 88517 2010-01-13 08:54:34Z johnnyw $")
00009
00010 #include "tao/Messaging/Messaging.h"
00011 #include "tao/Exception_Data.h"
00012 #include "tao/CDR.h"
00013
00014 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00015
00016 namespace TAO
00017 {
00018 ExceptionHolder::ExceptionHolder (void) :
00019 data_ (0),
00020 count_ (0),
00021 char_translator_ (0),
00022 wchar_translator_ (0)
00023 {
00024 }
00025
00026 ExceptionHolder::ExceptionHolder (
00027 ::CORBA::Boolean is_system_exception,
00028 ::CORBA::Boolean byte_order,
00029 const ::CORBA::OctetSeq &marshaled_exception,
00030 ::TAO::Exception_Data* data,
00031 ::CORBA::ULong exceptions_count,
00032 ACE_Char_Codeset_Translator *char_translator,
00033 ACE_WChar_Codeset_Translator *wchar_translator) :
00034 ::OBV_Messaging::ExceptionHolder (is_system_exception, byte_order, marshaled_exception),
00035 data_ (data),
00036 count_ (exceptions_count),
00037 char_translator_ (char_translator),
00038 wchar_translator_ (wchar_translator)
00039 {
00040 }
00041
00042 ExceptionHolder::~ExceptionHolder ()
00043 {
00044 }
00045
00046 void
00047 ExceptionHolder::set_exception_data (::TAO::Exception_Data* data,
00048 ::CORBA::ULong exceptions_count)
00049 {
00050 this->data_ = data;
00051 this->count_ = exceptions_count;
00052 }
00053
00054 void ExceptionHolder::raise_exception (void)
00055 {
00056 TAO_InputCDR _tao_in ((const char*) this->marshaled_exception ().get_buffer (),
00057 this->marshaled_exception ().length (),
00058 this->byte_order ());
00059
00060 _tao_in.char_translator (this->char_translator_);
00061 _tao_in.wchar_translator (this->wchar_translator_);
00062
00063 CORBA::String_var type_id;
00064
00065 if (!(_tao_in >> type_id.inout ()))
00066 {
00067
00068
00069 throw ::CORBA::MARSHAL (TAO::VMCID, CORBA::COMPLETED_YES);
00070 }
00071
00072 if (this->is_system_exception ())
00073 {
00074 CORBA::ULong minor = 0;
00075 CORBA::ULong completion = 0;
00076 if (!(_tao_in >> minor) ||
00077 !(_tao_in >> completion))
00078 {
00079 throw ::CORBA::MARSHAL (TAO::VMCID, CORBA::COMPLETED_MAYBE);
00080 }
00081
00082 CORBA::SystemException* exception =
00083 TAO::create_system_exception (type_id.in ());
00084
00085 if (!exception)
00086 {
00087
00088
00089
00090 ACE_NEW (exception, CORBA::UNKNOWN);
00091 }
00092 exception->minor (minor);
00093 exception->completed (CORBA::CompletionStatus (completion));
00094
00095
00096 ACE_Auto_Basic_Ptr<CORBA::SystemException> e_ptr(exception);
00097 exception->_raise ();
00098
00099 return;
00100 }
00101
00102
00103
00104
00105 for (CORBA::ULong i = 0; i != this->count_; ++i)
00106 {
00107 if (ACE_OS::strcmp (type_id.in (), this->data_[i].id) != 0)
00108 continue;
00109
00110 CORBA::Exception * const exception = this->data_[i].alloc ();
00111
00112 if (exception == 0)
00113 {
00114 throw ::CORBA::NO_MEMORY (TAO::VMCID, CORBA::COMPLETED_YES);
00115 }
00116 else
00117 {
00118 exception->_tao_decode (_tao_in);
00119 }
00120
00121
00122 ACE_Auto_Basic_Ptr<CORBA::Exception> e_ptr (exception);
00123 exception->_raise ();
00124
00125 return;
00126 }
00127
00128
00129
00130
00131
00132
00133
00134 throw ::CORBA::UNKNOWN (TAO::VMCID, CORBA::COMPLETED_YES);
00135 }
00136
00137 void ExceptionHolder::raise_exception_with_list (
00138 const ::Dynamic::ExceptionList &)
00139 {
00140
00141 this->raise_exception ();
00142 }
00143
00144 CORBA::ValueBase*
00145 ExceptionHolder::_copy_value (void)
00146 {
00147 TAO::ExceptionHolder* ret_val = 0;
00148 ACE_NEW_THROW_EX (ret_val,
00149 ExceptionHolder,
00150 CORBA::NO_MEMORY ());
00151
00152
00153
00154
00155 ret_val->is_system_exception (this->is_system_exception ());
00156 ret_val->byte_order (this->byte_order ());
00157 ret_val->marshaled_exception (this->marshaled_exception ());
00158
00159 return ret_val;
00160 }
00161
00162 CORBA::ValueBase *
00163 ExceptionHolderFactory::create_for_unmarshal (void)
00164 {
00165 TAO::ExceptionHolder* ret_val = 0;
00166 ACE_NEW_THROW_EX (ret_val,
00167 ExceptionHolder,
00168 CORBA::NO_MEMORY ());
00169 return ret_val;
00170 }
00171 }
00172
00173 TAO_END_VERSIONED_NAMESPACE_DECL
00174