Modified: xerces/c/trunk/src/xercesc/validators/schema/ComplexTypeInfo.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/ComplexTypeInfo.cpp?rev=635560&r1=635559&r2=635560&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/ComplexTypeInfo.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/ComplexTypeInfo.cpp Mon Mar 10 
07:10:09 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,117 +32,74 @@
 #include <xercesc/validators/common/SimpleContentModel.hpp>
 #include <xercesc/validators/schema/XSDLocator.hpp>
 #include <xercesc/internal/XTemplateSerializer.hpp>
-#include <xercesc/util/XMLRegisterCleanup.hpp>
 #include <xercesc/util/XMLInitializer.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
 // ---------------------------------------------------------------------------
-//  Local static data
-// ---------------------------------------------------------------------------
-static bool               sAnyTypeMutexRegistered = false;
-static XMLMutex*          sAnyTypeMutex = 0;
-static XMLRegisterCleanup anyTypeCleanup;
-
-
-// ---------------------------------------------------------------------------
 //  ComplexTypeInfo: Static member data
 // ---------------------------------------------------------------------------
 ComplexTypeInfo* ComplexTypeInfo::fAnyType = 0;
 
+void XMLInitializer::initializeComplexTypeInfo()
+{
+  // create type name
+  XMLCh typeName[128];
+  XMLSize_t nsLen = XMLString::stringLen(SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
+
+  XMLString::copyString(typeName, SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
+  typeName[nsLen] = chComma;
+  XMLString::copyString(typeName + nsLen + 1, SchemaSymbols::fgATTVAL_ANYTYPE);
 
-// ---------------------------------------------------------------------------
-//  ComplexTypeInfo: Static meber methods
-// ---------------------------------------------------------------------------
-void ComplexTypeInfo::reinitAnyType() {
+  // Create and initialize 'anyType'
+  ComplexTypeInfo::fAnyType = new ComplexTypeInfo();
+
+  ContentSpecNode* term = new ContentSpecNode
+    (
+      new QName
+      (
+        XMLUni::fgZeroLenString
+        , XMLUni::fgZeroLenString
+        , 1
+      )
+      , false
+    );
+  term->setType(ContentSpecNode::Any_Lax);
+  term->setMinOccurs(0);
+  term->setMaxOccurs(SchemaSymbols::XSD_UNBOUNDED);
 
-    delete fAnyType;
-    fAnyType = 0;
+  ContentSpecNode* particle = new ContentSpecNode
+    (
+      ContentSpecNode::ModelGroupSequence
+      , term
+      , 0
+    );
 
-    // delete local static data
-    delete sAnyTypeMutex;
-    sAnyTypeMutex = 0;
-    sAnyTypeMutexRegistered = false;
+  SchemaAttDef* attWildCard = new SchemaAttDef
+    (
+      XMLUni::fgZeroLenString
+      , XMLUni::fgZeroLenString
+      , 1
+      , XMLAttDef::Any_Any
+      , XMLAttDef::ProcessContents_Lax
+    );
+
+  ComplexTypeInfo::fAnyType->setTypeName(typeName);
+  ComplexTypeInfo::fAnyType->setBaseComplexTypeInfo(ComplexTypeInfo::fAnyType);
+  ComplexTypeInfo::fAnyType->setDerivedBy(SchemaSymbols::XSD_RESTRICTION);
+  ComplexTypeInfo::fAnyType->setContentType(SchemaElementDecl::Mixed_Complex);
+  ComplexTypeInfo::fAnyType->setContentSpec(particle);
+  ComplexTypeInfo::fAnyType->setAttWildCard(attWildCard);
 }
 
-void XMLInitializer::initializeAnyType()
+void XMLInitializer::terminateComplexTypeInfo()
 {
-    ComplexTypeInfo::getAnyType(1);
+  delete ComplexTypeInfo::fAnyType;
+  ComplexTypeInfo::fAnyType = 0;
 }
 
 ComplexTypeInfo* ComplexTypeInfo::getAnyType(unsigned int emptyNSId)
 {
-    if (!sAnyTypeMutexRegistered)
-    {
-        if (!sAnyTypeMutex)
-        {
-            XMLMutexLock lock(XMLPlatformUtils::fgAtomicMutex);
-            if (!sAnyTypeMutex)
-                sAnyTypeMutex = new 
XMLMutex(XMLPlatformUtils::fgMemoryManager);
-        }
-
-        // Use a faux scope to synchronize while we do this
-        {
-            XMLMutexLock lock(sAnyTypeMutex);
-
-            // If we got here first, then register it and set the registered 
flag
-            if (!sAnyTypeMutexRegistered)
-            {
-                // create type name
-                XMLCh typeName[128];
-                XMLSize_t nsLen = 
XMLString::stringLen(SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
-
-                           XMLString::copyString(typeName, 
SchemaSymbols::fgURI_SCHEMAFORSCHEMA);
-                typeName[nsLen] = chComma;
-                XMLString::copyString(typeName + nsLen + 1, 
SchemaSymbols::fgATTVAL_ANYTYPE);
-
-                // Create and initialize 'anyType'
-                fAnyType = new ComplexTypeInfo();
-
-                ContentSpecNode* term = new ContentSpecNode
-                (
-                    new QName
-                    (
-                        XMLUni::fgZeroLenString
-                        , XMLUni::fgZeroLenString
-                        , emptyNSId
-                    )
-                    , false
-                );
-                term->setType(ContentSpecNode::Any_Lax);
-                term->setMinOccurs(0);
-                term->setMaxOccurs(SchemaSymbols::XSD_UNBOUNDED);
-
-                ContentSpecNode* particle = new ContentSpecNode
-                (
-                    ContentSpecNode::ModelGroupSequence
-                    , term
-                    , 0
-                );
-
-                SchemaAttDef* attWildCard = new SchemaAttDef
-                (
-                    XMLUni::fgZeroLenString
-                    , XMLUni::fgZeroLenString
-                    , emptyNSId
-                    , XMLAttDef::Any_Any
-                    , XMLAttDef::ProcessContents_Lax
-                );
-
-                fAnyType->setTypeName(typeName);
-                fAnyType->setBaseComplexTypeInfo(fAnyType);
-                fAnyType->setDerivedBy(SchemaSymbols::XSD_RESTRICTION);
-                fAnyType->setContentType(SchemaElementDecl::Mixed_Complex);
-                fAnyType->setContentSpec(particle);
-                fAnyType->setAttWildCard(attWildCard);
-
-                // register cleanup method
-                anyTypeCleanup.registerCleanup(ComplexTypeInfo::reinitAnyType);
-                sAnyTypeMutexRegistered = true;
-            }
-        }
-    }
-
     return fAnyType;
 }
 
@@ -171,9 +128,9 @@
     , fDatatypeValidator(0)
     , fBaseComplexTypeInfo(0)
     , fContentSpec(0)
-    , fAttWildCard(0)    
+    , fAttWildCard(0)
     , fAttList(0)
-    , fElements(0)    
+    , fElements(0)
     , fAttDefs(0)
     , fContentModel(0)
     , fFormattedModel(0)
@@ -199,7 +156,7 @@
     delete fAttWildCard;
     delete fAttDefs;
     delete fAttList;
-    delete fElements;    
+    delete fElements;
     delete fLocator;
 
     delete fContentModel;
@@ -773,9 +730,9 @@
 
 void ComplexTypeInfo::serialize(XSerializeEngine& serEng)
 {
-   
+
     if (serEng.isStoring())
-    {    
+    {
         serEng<<fAnonymous;
         serEng<<fAbstract;
         serEng<<fAdoptContentSpec;
@@ -802,7 +759,7 @@
         serEng<<fAttList;
 
         /***
-         * 
+         *
          * Serialize RefVectorOf<SchemaElementDecl>*    fElements;
          * Serialize RefHash2KeysTableOf<SchemaAttDef>* fAttDefs;
          ***/
@@ -810,12 +767,12 @@
         XTemplateSerializer::storeObject(fAttDefs, serEng);
 
          /***
-          *   Don't serialize 
+          *   Don't serialize
           *
           *   fContentModel;
           *   fFormattedModel;
-          *   fLocator;          
-          * 
+          *   fLocator;
+          *
           *   fContentSpecOrgURI:     start of the array
           *   fContentSpecOrgURISize: size of the array
           *   fUniqueURI:             the current last element in the array
@@ -850,7 +807,7 @@
         serEng>>fAttList;
 
         /***
-         * 
+         *
          * Deserialize RefVectorOf<SchemaElementDecl>*    fElements;
          * Deserialize RefHash2KeysTableOf<SchemaAttDef>* fAttDefs;
          ***/
@@ -859,18 +816,18 @@
         XTemplateSerializer::loadObject(&fAttDefs, 29, true, serEng);
 
          /***
-          *   Don't deserialize 
+          *   Don't deserialize
           *
           *   fFormattedModel;
-          *   fLocator;          
-          * 
+          *   fLocator;
+          *
           *   fContentSpecOrgURI:     start of the array
           *   fContentSpecOrgURISize: size of the array
           *   fUniqueURI:             the current last element in the array
           ***/
 
          fFormattedModel = 0;
-         fLocator = 0;         
+         fLocator = 0;
          fContentSpecOrgURI = 0;
          fContentSpecOrgURISize = 0;
          fUniqueURI = 0;

Modified: xerces/c/trunk/src/xercesc/validators/schema/ComplexTypeInfo.hpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/ComplexTypeInfo.hpp?rev=635560&r1=635559&r2=635560&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/ComplexTypeInfo.hpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/ComplexTypeInfo.hpp Mon Mar 10 
07:10:09 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -145,7 +145,7 @@
     /**
       * Return a singleton that represents 'anyType'
       *
-      * @param emptyNSId the uri id of the empty namespace 
+      * @param emptyNSId the uri id of the empty namespace
       */
     static ComplexTypeInfo* getAnyType(unsigned int emptyNSId);
 
@@ -205,7 +205,7 @@
     ContentSpecNode*                   fContentSpec;
     SchemaAttDef*                      fAttWildCard;
     SchemaAttDefList*                  fAttList;
-    RefVectorOf<SchemaElementDecl>*    fElements;    
+    RefVectorOf<SchemaElementDecl>*    fElements;
     RefHash2KeysTableOf<SchemaAttDef>* fAttDefs;
     XMLContentModel*                   fContentModel;
     XMLCh*                             fFormattedModel;
@@ -214,6 +214,8 @@
     MemoryManager*                     fMemoryManager;
 
     static ComplexTypeInfo*            fAnyType;
+
+    friend class XMLInitializer;
 };
 
 // ---------------------------------------------------------------------------
@@ -429,7 +431,7 @@
 
     fMemoryManager->deallocate(fTypeName);//delete [] fTypeName;
     fMemoryManager->deallocate(fTypeLocalName);//delete [] fTypeLocalName;
-    fMemoryManager->deallocate(fTypeUri);//delete [] fTypeUri;    
+    fMemoryManager->deallocate(fTypeUri);//delete [] fTypeUri;
 
     if (typeName)
     {
@@ -442,12 +444,12 @@
             (length - index + 1) * sizeof(XMLCh)
         ); //new XMLCh[length - index + 1];
         XMLString::subString(fTypeLocalName, fTypeName, index + 1, length, 
fMemoryManager);
-        
+
         fTypeUri = (XMLCh*) fMemoryManager->allocate
         (
             (index + 1) * sizeof(XMLCh)
         ); //new XMLCh[index + 1];
-        XMLString::subString(fTypeUri, fTypeName, 0, index, fMemoryManager);   
     
+        XMLString::subString(fTypeUri, fTypeName, 0, index, fMemoryManager);
     }
     else
     {

Modified: xerces/c/trunk/src/xercesc/validators/schema/GeneralAttributeCheck.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/GeneralAttributeCheck.cpp?rev=635560&r1=635559&r2=635560&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/GeneralAttributeCheck.cpp 
(original)
+++ xerces/c/trunk/src/xercesc/validators/schema/GeneralAttributeCheck.cpp Mon 
Mar 10 07:10:09 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,7 +29,6 @@
 #include <xercesc/util/XMLUniDefs.hpp>
 #include <xercesc/util/Janitor.hpp>
 #include <xercesc/util/PlatformUtils.hpp>
-#include <xercesc/util/XMLRegisterCleanup.hpp>
 #include <xercesc/util/XMLInitializer.hpp>
 #include <xercesc/util/OutOfMemoryException.hpp>
 
@@ -64,15 +63,6 @@
     chLatin_g, chLatin_l, chLatin_o, chLatin_b, chLatin_a, chLatin_l, chNull
 };
 
-
-// ---------------------------------------------------------------------------
-//  Static local data
-// ---------------------------------------------------------------------------
-static bool sGeneralAttCheckMutexRegistered = false;
-static XMLMutex* sGeneralAttCheckMutex = 0;
-static XMLRegisterCleanup sGeneralAttCheckCleanup;
-
-
 // ---------------------------------------------------------------------------
 //  Static member data initialization
 // ---------------------------------------------------------------------------
@@ -82,77 +72,38 @@
 DatatypeValidator*                GeneralAttributeCheck::fBooleanDV = 0;
 DatatypeValidator*                GeneralAttributeCheck::fAnyURIDV = 0;
 
-void XMLInitializer::initializeGeneralAttrCheckMap()
-{
-    GeneralAttributeCheck *obj = new GeneralAttributeCheck();
-    delete obj;
-}
-
-
-// ---------------------------------------------------------------------------
-//  GeneralAttributeCheck: Constructors and Destructor
-// ---------------------------------------------------------------------------
-GeneralAttributeCheck::GeneralAttributeCheck(MemoryManager* const manager)
-    : fMemoryManager(manager)
-    , fValidationContext(0)
-    , fIDValidator(manager)
+void XMLInitializer::initializeGeneralAttributeCheck()
 {
-    mapElements();
+    GeneralAttributeCheck::initialize ();
 }
 
-GeneralAttributeCheck::~GeneralAttributeCheck()
+void XMLInitializer::terminateGeneralAttributeCheck()
 {
-}
+    delete GeneralAttributeCheck::fFacetsMap;
+    delete GeneralAttributeCheck::fAttMap;
 
+    GeneralAttributeCheck::fAttMap = 0;
+    GeneralAttributeCheck::fFacetsMap = 0;
 
-// ---------------------------------------------------------------------------
-//  GeneralAttributeCheck: Setup methods
-// ---------------------------------------------------------------------------
-void GeneralAttributeCheck::setUpValidators() {
+    GeneralAttributeCheck::fNonNegIntDV = 0;
+    GeneralAttributeCheck::fBooleanDV = 0;
+    GeneralAttributeCheck::fAnyURIDV = 0;
+}
 
-    DatatypeValidatorFactory dvFactory(fMemoryManager);
+void GeneralAttributeCheck::initialize()
+{
+    // Set up validators.
+    //
+    DatatypeValidatorFactory dvFactory;
 
-    dvFactory.expandRegistryToFullSchemaSet();
     fNonNegIntDV = 
dvFactory.getDatatypeValidator(SchemaSymbols::fgDT_NONNEGATIVEINTEGER);
     fBooleanDV = dvFactory.getDatatypeValidator(SchemaSymbols::fgDT_BOOLEAN);
     fAnyURIDV = dvFactory.getDatatypeValidator(SchemaSymbols::fgDT_ANYURI);
 
-    // TO DO - add remaining valdiators
-}
-
-void GeneralAttributeCheck::mapElements()
-{
-    if (!sGeneralAttCheckMutexRegistered)
-    {
-        if (!sGeneralAttCheckMutex)
-        {
-            XMLMutexLock lock(XMLPlatformUtils::fgAtomicMutex);
-
-            if (!sGeneralAttCheckMutex)
-                sGeneralAttCheckMutex = new 
XMLMutex(XMLPlatformUtils::fgMemoryManager);
-        }
-
-        // Use a faux scope to synchronize while we do this
-        {
-            XMLMutexLock lock(sGeneralAttCheckMutex);
-
-            // If we got here first, then register it and set the registered 
flag
-            if (!sGeneralAttCheckMutexRegistered)
-            {
-                // initialize
-                setUpValidators();
-                mapAttributes();
-
-                // register for cleanup at Termination.
-                
sGeneralAttCheckCleanup.registerCleanup(GeneralAttributeCheck::reinitGeneralAttCheck);
-                sGeneralAttCheckMutexRegistered = true;
-            }
-        }
-    }
-}
-
-void GeneralAttributeCheck::mapAttributes() {
+    // TODO - add remaining valdiators
 
+    // Map attributes.
+    //
     fAttMap = new ValueHashTableOf<unsigned short>(A_Count);
 
     fAttMap->put((void*)SchemaSymbols::fgATT_ABSTRACT, A_Abstract);
@@ -191,6 +142,7 @@
     fAttMap->put((void*)SchemaSymbols::fgATT_XPATH, A_XPath);
 
     fFacetsMap = new ValueHashTableOf<unsigned short>(13);
+
     fFacetsMap->put((void*) SchemaSymbols::fgELT_MINEXCLUSIVE, E_MinExclusive);
     fFacetsMap->put((void*) SchemaSymbols::fgELT_MININCLUSIVE, E_MinInclusive);
     fFacetsMap->put((void*) SchemaSymbols::fgELT_MAXEXCLUSIVE, E_MaxExclusive);
@@ -205,22 +157,18 @@
     fFacetsMap->put((void*) SchemaSymbols::fgELT_PATTERN, E_Pattern);
 }
 
+// ---------------------------------------------------------------------------
+//  GeneralAttributeCheck: Constructors and Destructor
+// ---------------------------------------------------------------------------
+GeneralAttributeCheck::GeneralAttributeCheck(MemoryManager* const manager)
+    : fMemoryManager(manager)
+    , fValidationContext(0)
+    , fIDValidator(manager)
+{
+}
 
-// -----------------------------------------------------------------------
-//  Notification that lazy data has been deleted
-// -----------------------------------------------------------------------
-void
-GeneralAttributeCheck::reinitGeneralAttCheck() {
-
-    delete sGeneralAttCheckMutex;
-    sGeneralAttCheckMutex = 0;
-    sGeneralAttCheckMutexRegistered = false;
-
-    delete fAttMap;
-    delete fFacetsMap;
-       
-    fAttMap = fFacetsMap = 0;
-    fNonNegIntDV = fBooleanDV = fAnyURIDV = 0;
+GeneralAttributeCheck::~GeneralAttributeCheck()
+{
 }
 
 // ---------------------------------------------------------------------------

Modified: xerces/c/trunk/src/xercesc/validators/schema/GeneralAttributeCheck.hpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/GeneralAttributeCheck.hpp?rev=635560&r1=635559&r2=635560&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/GeneralAttributeCheck.hpp 
(original)
+++ xerces/c/trunk/src/xercesc/validators/schema/GeneralAttributeCheck.hpp Mon 
Mar 10 07:10:09 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -202,11 +202,6 @@
                          const bool isTopLevel = false,
                          ValueVectorOf<DOMNode*>* const nonXSAttList = 0);
 
-    // -----------------------------------------------------------------------
-    //  Notification that lazy data has been deleted
-    // -----------------------------------------------------------------------
-       static void reinitGeneralAttCheck();
-
 private:
     // -----------------------------------------------------------------------
     //  Unimplemented constructors and operators
@@ -215,13 +210,6 @@
     GeneralAttributeCheck& operator=(const GeneralAttributeCheck&);
 
     // -----------------------------------------------------------------------
-    //  Setup methods
-    // -----------------------------------------------------------------------
-    void setUpValidators();
-    void mapElements();
-    void mapAttributes();
-
-    // -----------------------------------------------------------------------
     //  Validation methods
     // -----------------------------------------------------------------------
     void validate(const DOMElement* const elem, const XMLCh* const attName, 
const XMLCh* const attValue,
@@ -250,6 +238,11 @@
     MemoryManager*                           fMemoryManager;
     ValidationContext*                       fValidationContext;
     IDDatatypeValidator                      fIDValidator;
+
+private:
+    static void initialize();
+
+    friend class XMLInitializer;
 };
 
 

Modified: xerces/c/trunk/src/xercesc/validators/schema/SchemaGrammar.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/SchemaGrammar.cpp?rev=635560&r1=635559&r2=635560&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/SchemaGrammar.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/SchemaGrammar.cpp Mon Mar 10 
07:10:09 2008
@@ -77,7 +77,6 @@
         fGroupElemDeclPool = new (fMemoryManager) 
RefHash3KeysIdPool<SchemaElementDecl>(109, false, 128, fMemoryManager);
         fNotationDeclPool = new (fMemoryManager) 
NameIdPool<XMLNotationDecl>(109, 128, fMemoryManager);
         fValidationContext = new (fMemoryManager) 
ValidationContextImpl(fMemoryManager);
-        fDatatypeRegistry.expandRegistryToFullSchemaSet();
 
         //REVISIT: use grammarPool to create
         fGramDesc = new (fMemoryManager) 
XMLSchemaDescriptionImpl(XMLUni::fgXMLNSURIName, fMemoryManager);

Modified: xerces/c/trunk/src/xercesc/validators/schema/XSDErrorReporter.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/XSDErrorReporter.cpp?rev=635560&r1=635559&r2=635560&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/XSDErrorReporter.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/XSDErrorReporter.cpp Mon Mar 
10 07:10:09 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,7 +24,6 @@
 #include <xercesc/framework/XMLValidityCodes.hpp>
 #include <xercesc/framework/XMLErrorReporter.hpp>
 #include <xercesc/util/XMLMsgLoader.hpp>
-#include <xercesc/util/XMLRegisterCleanup.hpp>
 #include <xercesc/util/XMLInitializer.hpp>
 #include <xercesc/validators/schema/XSDErrorReporter.hpp>
 #include <xercesc/validators/schema/XSDLocator.hpp>
@@ -36,99 +35,27 @@
 // ---------------------------------------------------------------------------
 static XMLMsgLoader*  gErrMsgLoader = 0;
 static XMLMsgLoader*  gValidMsgLoader = 0;
-static XMLMutex*      sErrRprtrMutex = 0;
-static XMLRegisterCleanup errRprtrMutexCleanup;
-static XMLRegisterCleanup cleanupErrMsgLoader;
-static XMLRegisterCleanup cleanupValidMsgLoader;
 
-// ---------------------------------------------------------------------------
-//  Local, static functions
-// ---------------------------------------------------------------------------
-static void reinitErrRprtrMutex()
-{
-    delete sErrRprtrMutex;
-    sErrRprtrMutex = 0;
-}
-
-static XMLMutex& getErrRprtrMutex()
-{
-    if (!sErrRprtrMutex)
-    {
-        XMLMutexLock lockInit(XMLPlatformUtils::fgAtomicMutex);
-
-        if (!sErrRprtrMutex)
-        {
-            sErrRprtrMutex = new XMLMutex(XMLPlatformUtils::fgMemoryManager);
-            errRprtrMutexCleanup.registerCleanup(reinitErrRprtrMutex);
-        }
-    }
-
-    return *sErrRprtrMutex;
-}
-
-static void reinitErrMsgLoader()
+void XMLInitializer::initializeXSDErrorReporter()
 {
-       delete gErrMsgLoader;
-       gErrMsgLoader = 0;
-}
-
-static void reinitValidMsgLoader()
-{
-       delete gValidMsgLoader;
-       gValidMsgLoader = 0;
-}
+    gErrMsgLoader = XMLPlatformUtils::loadMsgSet(XMLUni::fgXMLErrDomain);
 
-static XMLMsgLoader* getErrMsgLoader()
-{
     if (!gErrMsgLoader)
-    {
-        XMLMutexLock lock(&getErrRprtrMutex());
-
-        if (!gErrMsgLoader)
-        {
-            gErrMsgLoader = 
XMLPlatformUtils::loadMsgSet(XMLUni::fgXMLErrDomain);
-
-            if (!gErrMsgLoader)
-                XMLPlatformUtils::panic(PanicHandler::Panic_CantLoadMsgDomain);
-            else
-                cleanupErrMsgLoader.registerCleanup(reinitErrMsgLoader);
-        }
-    }
-
-    return gErrMsgLoader;
-}
+      XMLPlatformUtils::panic(PanicHandler::Panic_CantLoadMsgDomain);
 
+    gValidMsgLoader = XMLPlatformUtils::loadMsgSet(XMLUni::fgValidityDomain);
 
-static XMLMsgLoader* getValidMsgLoader()
-{
     if (!gValidMsgLoader)
-    {
-        XMLMutexLock lock(&getErrRprtrMutex());
-
-        if (!gValidMsgLoader)
-        {
-            gValidMsgLoader = 
XMLPlatformUtils::loadMsgSet(XMLUni::fgValidityDomain);
-
-            if (!gValidMsgLoader)
-                XMLPlatformUtils::panic(PanicHandler::Panic_CantLoadMsgDomain);
-            else
-                cleanupValidMsgLoader.registerCleanup(reinitValidMsgLoader);
-        }
-    }
-    return gValidMsgLoader;
+      XMLPlatformUtils::panic(PanicHandler::Panic_CantLoadMsgDomain);
 }
 
-void XMLInitializer::initializeXSDErrReporterMsgLoader()
+void XMLInitializer::terminateXSDErrorReporter()
 {
-    gErrMsgLoader = XMLPlatformUtils::loadMsgSet(XMLUni::fgXMLErrDomain);
-    if (gErrMsgLoader) {
-        cleanupErrMsgLoader.registerCleanup(reinitErrMsgLoader);
-    }
+    delete gErrMsgLoader;
+    gErrMsgLoader = 0;
 
-    gValidMsgLoader = XMLPlatformUtils::loadMsgSet(XMLUni::fgValidityDomain);
-    if (gValidMsgLoader) {
-        cleanupValidMsgLoader.registerCleanup(reinitValidMsgLoader);
-    }
+    delete gValidMsgLoader;
+    gValidMsgLoader = 0;
 }
 
 // ---------------------------------------------------------------------------
@@ -159,13 +86,13 @@
     //
     const XMLSize_t msgSize = 1023;
     XMLCh errText[msgSize + 1];
-    XMLMsgLoader* msgLoader = getErrMsgLoader();
+    XMLMsgLoader* msgLoader = gErrMsgLoader;
     XMLErrorReporter::ErrTypes errType = XMLErrs::errorType((XMLErrs::Codes) 
toEmit);
 
     if (XMLString::equals(msgDomain, XMLUni::fgValidityDomain)) {
 
         errType = XMLValid::errorType((XMLValid::Codes) toEmit);
-        msgLoader = getValidMsgLoader();
+        msgLoader = gValidMsgLoader;
     }
 
     if (!msgLoader->loadMsg(toEmit, errText, msgSize))
@@ -202,13 +129,13 @@
     //
     const XMLSize_t maxChars = 2047;
     XMLCh errText[maxChars + 1];
-    XMLMsgLoader* msgLoader = getErrMsgLoader();
+    XMLMsgLoader* msgLoader = gErrMsgLoader;
     XMLErrorReporter::ErrTypes errType = XMLErrs::errorType((XMLErrs::Codes) 
toEmit);
 
     if (XMLString::equals(msgDomain, XMLUni::fgValidityDomain)) {
 
         errType = XMLValid::errorType((XMLValid::Codes) toEmit);
-        msgLoader = getValidMsgLoader();
+        msgLoader = gValidMsgLoader;
     }
 
     if (!msgLoader->loadMsg(toEmit, errText, maxChars, text1, text2, text3, 
text4, manager))



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to