You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by pe...@apache.org on 2003/03/09 17:40:47 UTC

cvs commit: xml-xerces/c/src/xercesc/util XMLException.cpp PlatformUtils.hpp PlatformUtils.cpp Makefile.in

peiyongz    2003/03/09 08:40:47

  Modified:    c/src/xercesc/util XMLException.cpp PlatformUtils.hpp
                        PlatformUtils.cpp Makefile.in
  Log:
  PanicHandler
  
  Revision  Changes    Path
  1.5       +2 -2      xml-xerces/c/src/xercesc/util/XMLException.cpp
  
  Index: XMLException.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLException.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XMLException.cpp	7 Mar 2003 18:11:55 -0000	1.4
  +++ XMLException.cpp	9 Mar 2003 16:40:47 -0000	1.5
  @@ -144,7 +144,7 @@
       {
           sMsgLoader = XMLPlatformUtils::loadMsgSet(XMLUni::fgExceptDomain);
           if (!sMsgLoader)
  -            XMLPlatformUtils::panic(XMLPlatformUtils::Panic_CantLoadMsgDomain);
  +            XMLPlatformUtils::panic(PanicHandler::Panic_CantLoadMsgDomain);
   
           //
           // Register this XMLMsgLoader for cleanup at Termination.
  
  
  
  1.11      +31 -25    xml-xerces/c/src/xercesc/util/PlatformUtils.hpp
  
  Index: PlatformUtils.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/PlatformUtils.hpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- PlatformUtils.hpp	7 Mar 2003 18:11:54 -0000	1.10
  +++ PlatformUtils.hpp	9 Mar 2003 16:40:47 -0000	1.11
  @@ -64,6 +64,7 @@
   
   #include <xercesc/util/XercesDefs.hpp>
   #include <xercesc/util/XMLException.hpp>
  +#include <xercesc/util/PanicHandler.hpp>
   
   XERCES_CPP_NAMESPACE_BEGIN
   
  @@ -71,7 +72,6 @@
   class XMLNetAccessor;
   class XMLTransService;
   
  -
   //
   //  For internal use only
   //
  @@ -103,21 +103,6 @@
   class XMLUTIL_EXPORT XMLPlatformUtils
   {
   public :
  -    /** @name Public Types */
  -    //@{
  -    enum PanicReasons
  -    {
  -        Panic_NoTransService
  -        , Panic_NoDefTranscoder
  -        , Panic_CantFindLib
  -        , Panic_UnknownMsgDomain
  -        , Panic_CantLoadMsgDomain
  -        , Panic_SynchronizationErr
  -        , Panic_SystemInit
  -
  -        , PanicReasons_Count
  -    };
  -    //@}
   
       /** @name Public Static Data */
       //@{
  @@ -148,6 +133,18 @@
         */
       static XMLTransService*     fgTransService;
   
  +    /** The Panic Handler
  +      *
  +      *   This is the application provided panic handler. 
  +      */
  +    static PanicHandler*        fgUserPanicHandler;
  +    
  +    /** The Panic Handler
  +      *
  +      *   This is the default panic handler. 
  +      */    
  +    static PanicHandler*        fgDefaultPanicHandler;
  +    
       //@}
   
   
  @@ -175,9 +172,14 @@
         *          the discussion above with regard to locale, applies to this nlsHome
         *          as well.
         *
  +      * panicHandler: application's panic handler, application owns this handler.
  +      *               Application shall make sure that the plugged panic handler persists 
  +      *               through the call to XMLPlatformUtils::terminate().       
  +      *
         */
  -    static void Initialize(const char* const locale = XMLUni::fgXercescDefaultLocale
  -                         , const char* const nlsHome = 0);
  +    static void Initialize(const char*         const locale = XMLUni::fgXercescDefaultLocale
  +                         , const char*         const nlsHome = 0
  +                         ,       PanicHandler* const panicHandler = 0);
   
       /** Perform per-process parser termination
         *
  @@ -193,17 +195,21 @@
         * to get transcoding up or get message loading working, we call
         * this method.</p>
         *
  -      * Each platform can implement it however they want. This method is
  -      * expected to display something meaningful and end the process. The
  -      * enum indicates why its being called, to allow the per-platform code
  -      * to display or log something more specific if desired.</p>
  -      *
  +      * Each platform can implement it however they want. This method will
  +      * delegate the panic handling to a user specified panic handler or
  +      * in the absence of it, the default panic handler.
  +      *
  +      * In case the default panic handler does not support a particular
  +      * platform, the platform specific panic hanlding shall be implemented
  +      * here </p>.
  +      * 
         * @param reason The enumeration that defines the cause of the failure
         */
       static void panic
       (
  -        const   PanicReasons    reason
  +        const   PanicHandler::PanicReasons    reason
       );
  +    
       //@}
   
       /** @name File Methods */
  
  
  
  1.8       +32 -7     xml-xerces/c/src/xercesc/util/PlatformUtils.cpp
  
  Index: PlatformUtils.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/PlatformUtils.cpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PlatformUtils.cpp	17 Feb 2003 19:54:47 -0000	1.7
  +++ PlatformUtils.cpp	9 Mar 2003 16:40:47 -0000	1.8
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.8  2003/03/09 16:40:47  peiyongz
  + * PanicHandler
  + *
    * Revision 1.7  2003/02/17 19:54:47  peiyongz
    * Allow set user specified error message file location in PlatformUtils::Initialize().
    *
  @@ -158,6 +161,8 @@
   #include <xercesc/internal/XMLReader.hpp>
   #include <xercesc/util/RuntimeException.hpp>
   #include <xercesc/util/XMLRegisterCleanup.hpp>
  +#include <xercesc/util/DefaultPanicHandler.hpp>
  +
   #include <limits.h>
   
   XERCES_CPP_NAMESPACE_BEGIN
  @@ -185,7 +190,7 @@
   //		static data cleanup list
   // ---------------------------------------------------------------------------
   XMLRegisterCleanup*	gXMLCleanupList = 0;
  -XMLMutex*			gXMLCleanupListMutex = 0;
  +XMLMutex*               gXMLCleanupListMutex = 0;
   
   
   // ---------------------------------------------------------------------------
  @@ -193,14 +198,15 @@
   // ---------------------------------------------------------------------------
   XMLNetAccessor*     XMLPlatformUtils::fgNetAccessor = 0;
   XMLTransService*    XMLPlatformUtils::fgTransService = 0;
  -
  -
  +PanicHandler*       XMLPlatformUtils::fgUserPanicHandler = 0;
  +PanicHandler*       XMLPlatformUtils::fgDefaultPanicHandler = 0;
   
   // ---------------------------------------------------------------------------
   //  XMLPlatformUtils: Init/term methods
   // ---------------------------------------------------------------------------
  -void XMLPlatformUtils::Initialize(const char* const locale 
  -                                , const char* const nlsHome)
  +void XMLPlatformUtils::Initialize(const char*         const locale 
  +                                , const char*         const nlsHome
  +                                ,       PanicHandler* const panicHandler)
   {
       //
       //  Effects of overflow:
  @@ -225,6 +231,19 @@
       if (gInitFlag > 1)
         return;
   
  +    /***
  +     * Panic Handler:
  +     *
  +     ***/
  +    if (!panicHandler)
  +    {
  +        fgDefaultPanicHandler = new DefaultPanicHandler();
  +    }
  +    else
  +    {
  +        fgUserPanicHandler = panicHandler;
  +    }
  +    
       //
       //  Call the platform init method, which is implemented in each of the
       //  per-platform implementation cpp files. This one does the very low
  @@ -253,7 +272,7 @@
       fgTransService = makeTransService();
   
       if (!fgTransService)
  -        panic(Panic_NoTransService);
  +        panic(PanicHandler::Panic_NoTransService);
   
       // Initialize the transcoder service
       fgTransService->initTransService();
  @@ -265,7 +284,7 @@
       //
       XMLLCPTranscoder* defXCode = XMLPlatformUtils::fgTransService->makeNewLCPTranscoder();
       if (!defXCode)
  -        panic(Panic_NoDefTranscoder);
  +        panic(PanicHandler::Panic_NoDefTranscoder);
       XMLString::initString(defXCode);
   
       //
  @@ -283,6 +302,7 @@
        ***/
       XMLMsgLoader::setLocale(locale);
       XMLMsgLoader::setNLSHome(nlsHome);
  +
   }
   
   
  @@ -346,6 +366,11 @@
        ***/
       XMLMsgLoader::setLocale(0);
       XMLMsgLoader::setNLSHome(0);
  +
  +    if (fgDefaultPanicHandler)
  +    {
  +        delete fgDefaultPanicHandler;
  +    }
   
       // And say we are no longer initialized
       gInitFlag = 0;
  
  
  
  1.28      +7 -0      xml-xerces/c/src/xercesc/util/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/Makefile.in,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- Makefile.in	20 Feb 2003 18:06:55 -0000	1.27
  +++ Makefile.in	9 Mar 2003 16:40:47 -0000	1.28
  @@ -55,6 +55,9 @@
   #
   #
   # $Log$
  +# Revision 1.28  2003/03/09 16:40:47  peiyongz
  +# PanicHandler
  +#
   # Revision 1.27  2003/02/20 18:06:55  peiyongz
   # Bug#7077: build error message shared library for ICUMsgLoader
   #
  @@ -431,6 +434,7 @@
       BitOps.hpp \
       BitSet.hpp \
       CountedPointer.hpp \
  +    DefaultPanicHandler.hpp \
       EmptyStackException.hpp \
       EncodingValidator.hpp \
       FlagJanitor.hpp \
  @@ -452,6 +456,7 @@
       NoSuchElementException.hpp \
       NullPointerException.hpp \
       NumberFormatException.hpp \
  +    PanicHandler.hpp \
       ParseException.hpp \
       PlatformUtils.hpp \
       QName.hpp \
  @@ -541,6 +546,7 @@
       BinInputStream.$(TO) \
       BinMemInputStream.$(TO) \
       BitSet.$(TO) \
  +    DefaultPanicHandler.$(TO) \
       EncodingValidator.$(TO) \
       HashPtr.$(TO) \
       HashXMLCh.$(TO) \
  @@ -548,6 +554,7 @@
       HexBin.$(TO) \
       KVStringPair.$(TO) \
       Mutexes.$(TO) \
  +    PanicHandler.$(TO) \    
       PlatformUtils.$(TO) \
       QName.$(TO) \
       StringPool.$(TO) \
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org