Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_Exceptions Class Reference

This class is a namespace for exception-related static data and methods. More...

#include <Exception.h>

Collaboration diagram for TAO_Exceptions:

Collaboration graph
[legend]
List of all members.

Static Public Methods

void make_standard_typecode (CORBA::TypeCode_ptr &tcp, const char *name, char *buf, size_t buflen ACE_ENV_ARG_DECL_WITH_DEFAULTS)
void make_unknown_user_typecode (CORBA::TypeCode_ptr &tcp ACE_ENV_ARG_DECL_WITH_DEFAULTS)
 Make the TypeCode for the CORBA::UnknownUserException standard exception. More...

void init (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
 Runtime initialization of all standard exception typecodes. Called from <CORBA::ORB_init>. More...

void fini (void)
 Runtime finalization of all standard exception typecodes. More...

CORBA_SystemExceptioncreate_system_exception (const char *id ACE_ENV_ARG_DECL_WITH_DEFAULTS)
 Create a CORBA::SystemException given the interface repository ID. More...


Static Public Attributes

ACE_Allocatorglobal_allocator_

Static Private Attributes

int initialized_ = 0
 Flag that denotes that the TAO's CORBA exceptions have been initialized. More...


Detailed Description

This class is a namespace for exception-related static data and methods.

Definition at line 359 of file Exception.h.


Member Function Documentation

CORBA_SystemException * TAO_Exceptions::create_system_exception const char *id    ACE_ENV_ARG_DECL_WITH_DEFAULTS [static]
 

Create a CORBA::SystemException given the interface repository ID.

Definition at line 1114 of file Exception.cpp.

References ACE_ENV_ARG_DECL_NOT_USED, and STANDARD_EXCEPTION_LIST.

Referenced by TAO_GIOP_Synch_Invocation::invoke_i.

01116 {
01117 #define TAO_SYSTEM_EXCEPTION(name) \
01118   { \
01119     const char* xid = "IDL:omg.org/CORBA/" #name ":1.0"; \
01120     if (ACE_OS_String::strcmp (id, xid) == 0) \
01121       return new CORBA:: name; \
01122   }
01123   STANDARD_EXCEPTION_LIST
01124 #undef TAO_SYSTEM_EXCEPTION
01125 
01126   return 0;
01127 }

void TAO_Exceptions::fini void    [static]
 

Runtime finalization of all standard exception typecodes.

Definition at line 1130 of file Exception.cpp.

References global_allocator_, CORBA::release, and STANDARD_EXCEPTION_LIST.

Referenced by TAO_Singleton_Manager::fini.

01131 {
01132 #define TAO_SYSTEM_EXCEPTION(name) \
01133   CORBA::release (CORBA::_tc_ ## name); \
01134   CORBA::_tc_ ## name = 0;
01135   STANDARD_EXCEPTION_LIST
01136 #undef TAO_SYSTEM_EXCEPTION
01137 
01138   CORBA::release (CORBA::_tc_UnknownUserException);
01139   CORBA::_tc_UnknownUserException = 0;
01140 
01141   delete TAO_Exceptions::global_allocator_;
01142   TAO_Exceptions::global_allocator_ = 0;
01143 }

STANDARD_EXCEPTION_LIST void TAO_Exceptions::init ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS    [static]
 

Runtime initialization of all standard exception typecodes. Called from <CORBA::ORB_init>.

Definition at line 1084 of file Exception.cpp.

References ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_DECL, ACE_NEW, global_allocator_, initialized_, make_unknown_user_typecode, and STANDARD_EXCEPTION_LIST.

Referenced by CORBA_ORB::init_orb_globals.

01085 {
01086   // This routine should only be called once.
01087 
01088   // Not thread safe.  Caller must provide synchronization.
01089 
01090   if (TAO_Exceptions::initialized_ != 0)
01091     return;
01092 
01093   TAO_Exceptions::initialized_ = 1;
01094 
01095   // Initialize the start up allocator.
01096   ACE_NEW (TAO_Exceptions::global_allocator_,
01097            ACE_New_Allocator);
01098 
01099 #define TAO_SYSTEM_EXCEPTION(name) \
01100   TAO_Exceptions::make_standard_typecode (CORBA::_tc_ ## name, \
01101                                           #name, \
01102                                           (char*)tc_buf_##name, \
01103                                           sizeof(tc_buf_##name) \
01104                                            ACE_ENV_ARG_PARAMETER); \
01105   ACE_CHECK;
01106   STANDARD_EXCEPTION_LIST
01107 #undef  TAO_SYSTEM_EXCEPTION
01108 
01109   TAO_Exceptions::make_unknown_user_typecode (CORBA::_tc_UnknownUserException
01110                                               ACE_ENV_ARG_PARAMETER);
01111 }

void TAO_Exceptions::make_standard_typecode CORBA::TypeCode_ptr   tcp,
const char *    name,
char *    buf,
size_t buflen    ACE_ENV_ARG_DECL_WITH_DEFAULTS
[static]
 

Make the TypeCode for a standard exception. When used correctly, initializing system exceptions is only an exercise in CPU time; it allocates no new memory.

Definition at line 926 of file Exception.cpp.

References ACE_ASSERT, ACE_CDR_BYTE_ORDER, ACE_CHECK, ACE_DEFAULT_CDR_MEMCPY_TRADEOFF, ACE_ENV_ARG_DECL, ACE_NEW_THROW_EX, ACE_THROW, ACE_OutputCDR::buffer, global_allocator_, ACE_OutputCDR::length, ACE_OS_String::strcat, ACE_OS_String::strcpy, CORBA::string_alloc, CORBA::string_free, ACE_OS_String::strlen, TAO_ENCAP_BYTE_ORDER, TC_completion_status, ACE_OutputCDR::write_octet, ACE_OutputCDR::write_string, and ACE_OutputCDR::write_ulong.

00931 {
00932   // This function must only be called ONCE, and with a global lock
00933   // held!  The <CORBA::ORB_init> method is responsible for ensuring
00934   // this.
00935   static const char *minor = "minor";
00936   static const char *completed = "completed";
00937 
00938   // Create a CDR stream ... juggle the alignment here a bit, we know
00939   // it's good enough for the typecode.
00940 
00941 #if defined(ACE_MVS)
00942   // @@ We need to use a translator to make sure that all TypeCodes
00943   // are stored in ISO8859 form, the problem is that this hack does
00944   // not scale as more native sets have to be supported
00945 
00946   ACE_IBM1047_ISO8859 translator;
00947   TAO_OutputCDR stream (buffer, buflen,
00948                         ACE_CDR_BYTE_ORDER,
00949                         TAO_Exceptions::global_allocator_,
00950                         TAO_Exceptions::global_allocator_,
00951                         TAO_Exceptions::global_allocator_,
00952                         ACE_DEFAULT_CDR_MEMCPY_TRADEOFF,
00953                         &translator);
00954 #else
00955   TAO_OutputCDR stream (buffer, buflen,
00956                         ACE_CDR_BYTE_ORDER,
00957                         TAO_Exceptions::global_allocator_,
00958                         TAO_Exceptions::global_allocator_,
00959                         TAO_Exceptions::global_allocator_,
00960                         ACE_DEFAULT_CDR_MEMCPY_TRADEOFF);
00961 #endif /* ACE_MVS */
00962 
00963   // into CDR stream, stuff (in order):
00964   //    - byte order flag [4 bytes]
00965   //    - exception ID [27 + N bytes]
00966   //    - exception name [4 + N bytes ]
00967   //    - number of members (2) [4 bytes ]
00968   //    - foreach member, { name string, typecode } [~40 bytes]
00969 
00970   const char prefix[] = "IDL:omg.org/CORBA/";
00971   const char suffix[] = ":1.0";
00972   char * full_id =
00973     CORBA::string_alloc (sizeof prefix
00974                          + ACE_static_cast(CORBA::ULong,
00975                                            ACE_OS_String::strlen (name))
00976                          + sizeof suffix);
00977 
00978   ACE_OS_String::strcpy (full_id, prefix);
00979   ACE_OS_String::strcat (full_id, name);
00980   ACE_OS_String::strcat (full_id, suffix);
00981 
00982   CORBA::Boolean result = stream.write_octet (TAO_ENCAP_BYTE_ORDER) == 0
00983     || stream.write_string (full_id) == 0
00984     || stream.write_string (name) == 0
00985     || stream.write_ulong (2L) != 1
00986     || stream.write_string (minor) == 0;
00987 
00988   result = result || !(stream << CORBA::_tc_ulong);
00989 
00990   CORBA::string_free (full_id);  // No longer need the string
00991 
00992   result = result || stream.write_string (completed) == 0;
00993   result = result || !(stream << TC_completion_status);
00994 
00995   if (result)
00996     ACE_THROW (CORBA::INITIALIZE ());
00997 
00998   // @@ It is possible to throw an exception at this point?
00999   //    What if the exception typecode has not been initialized yet?
01000 
01001   // OK, we stuffed the buffer we were given (or grew a bigger one;
01002   // hope to avoid that during initialization).  Now build and return
01003   // a TypeCode, saving it away in the list of ones that the ORB will
01004   // always accept as part of any operation response!
01005 
01006   ACE_NEW_THROW_EX (tcp,
01007                     CORBA::TypeCode (CORBA::tk_except,
01008                                      stream.length (),
01009                                      stream.buffer (),
01010                                      1,
01011                                      sizeof (CORBA_SystemException)),
01012                     CORBA_INITIALIZE ());
01013   ACE_CHECK;
01014 
01015   ACE_ASSERT (tcp->length_ <= buflen);
01016   return;
01017 }

void TAO_Exceptions::make_unknown_user_typecode CORBA::TypeCode_ptr &tcp    ACE_ENV_ARG_DECL_WITH_DEFAULTS [static]
 

Make the TypeCode for the CORBA::UnknownUserException standard exception.

Definition at line 873 of file Exception.cpp.

References ACE_CDR_BYTE_ORDER, ACE_DEFAULT_CDR_MEMCPY_TRADEOFF, ACE_ENV_ARG_DECL, ACE_NEW_THROW_EX, ACE_THROW, ACE_OutputCDR::buffer, global_allocator_, ACE_OutputCDR::length, TAO_ENCAP_BYTE_ORDER, ACE_OutputCDR::write_octet, ACE_OutputCDR::write_string, and ACE_OutputCDR::write_ulong.

Referenced by init.

00875 {
00876   // Create the TypeCode for the CORBA_UnknownUserException.
00877 
00878 #if defined(ACE_MVS)
00879   // @@ We need to use a translator to make sure that all TypeCodes
00880   // are stored in ISO8859 form, the problem is that this hack does
00881   // not scale as more native sets have to be supported
00882 
00883   ACE_IBM1047_ISO8859 translator;
00884   TAO_OutputCDR stream (0,
00885                         ACE_CDR_BYTE_ORDER,
00886                         TAO_Exceptions::global_allocator_,
00887                         TAO_Exceptions::global_allocator_,
00888                         TAO_Exceptions::global_allocator_,
00889                         ACE_DEFAULT_CDR_MEMCPY_TRADEOFF,
00890                         &translator);
00891 #else
00892   TAO_OutputCDR stream (0,
00893                         ACE_CDR_BYTE_ORDER,
00894                         TAO_Exceptions::global_allocator_,
00895                         TAO_Exceptions::global_allocator_,
00896                         TAO_Exceptions::global_allocator_,
00897                         ACE_DEFAULT_CDR_MEMCPY_TRADEOFF);
00898 #endif /* ACE_MVS */
00899 
00900   const char *interface_id =
00901     "IDL:omg.org/CORBA/UnknownUserException:1.0";
00902   const char *name = "UnknownUserException";
00903   const char *field_name = "exception";
00904 
00905   CORBA::Boolean result = stream.write_octet (TAO_ENCAP_BYTE_ORDER) == 0
00906     || stream.write_string (interface_id) == 0
00907     || stream.write_string (name) == 0
00908     || stream.write_ulong (1L) == 0
00909     || stream.write_string (field_name) == 0;
00910   if (result)
00911     ACE_THROW (CORBA_INITIALIZE ());
00912 
00913   if (!(stream << CORBA::_tc_any))
00914     ACE_THROW (CORBA_INITIALIZE ());
00915 
00916   ACE_NEW_THROW_EX (tcp,
00917                     CORBA::TypeCode (CORBA::tk_except,
00918                                      stream.length (),
00919                                      stream.buffer (),
00920                                      1,
00921                                      sizeof (CORBA_UserException)),
00922                     CORBA_INITIALIZE ());
00923 }


Member Data Documentation

ACE_Allocator * TAO_Exceptions::global_allocator_ [static]
 

This global allocator is used to initialize system exception typecodes. Since at the time, the ORB is mostly still not available. Using a separate allocator prevents CDR routines from accessing the optimized allocators from the ORB.

Definition at line 33 of file Exception.cpp.

Referenced by fini, init, make_standard_typecode, and make_unknown_user_typecode.

int TAO_Exceptions::initialized_ = 0 [static, private]
 

Flag that denotes that the TAO's CORBA exceptions have been initialized.

Definition at line 37 of file Exception.cpp.

Referenced by init.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:14:41 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002