You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sa...@apache.org on 2009/09/01 23:02:53 UTC

svn commit: r810237 - in /xerces/java/trunk/src/org/apache/xerces/impl: dv/xs/XSSimpleTypeDecl.java xs/XMLSchemaLoader.java

Author: sandygao
Date: Tue Sep  1 21:02:53 2009
New Revision: 810237

URL: http://svn.apache.org/viewvc?rev=810237&view=rev
Log:
During schema loading, the declaration pool was designed to reuse objects for schema components. Seems it's now used more often than it should be. We should only reuse these objects when they are not exposed or cached. ... Also when reusing simple type objects, we need to clear the "anonymous" bit.

Modified:
    xerces/java/trunk/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java

Modified: xerces/java/trunk/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java?rev=810237&r1=810236&r2=810237&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java Tue Sep  1 21:02:53 2009
@@ -475,6 +475,7 @@
         //decline to do anything if the object is immutable.
         if(fIsImmutable) return null;
         fBase = base;
+        fAnonymous = false;
         fTypeName = name;
         fTargetNamespace = uri;
         fFinalSet = finalSet;
@@ -529,6 +530,7 @@
         //decline to do anything if the object is immutable.
         if(fIsImmutable) return null;
         fBase = fAnySimpleType;
+        fAnonymous = false;
         fTypeName = name;
         fTargetNamespace = uri;
         fFinalSet = finalSet;
@@ -556,6 +558,7 @@
         //decline to do anything if the object is immutable.
         if(fIsImmutable) return null;
         fBase = fAnySimpleType;
+        fAnonymous = false;
         fTypeName = name;
         fTargetNamespace = uri;
         fFinalSet = finalSet;

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java?rev=810237&r1=810236&r2=810237&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java Tue Sep  1 21:02:53 2009
@@ -338,7 +338,6 @@
         }
         fCMBuilder = builder;
         fSchemaHandler = new XSDHandler(fGrammarBucket);
-        fDeclPool = new XSDeclarationPool();
         fJAXPCache = new WeakHashMap();
         
         fSettingsChanged = true;
@@ -965,6 +964,9 @@
             fJAXPProcessed = false;
             // reinitialize grammar bucket
             initGrammarBucket();
+            if (fDeclPool != null) {
+                fDeclPool.reset();
+            }
             return;           
         } 
         
@@ -976,13 +978,6 @@
         // get the error reporter
         fErrorReporter = (XMLErrorReporter)componentManager.getProperty(ERROR_REPORTER);
         
-        boolean psvi = true;
-        try {
-            psvi = componentManager.getFeature(AUGMENT_PSVI);
-        } catch (XMLConfigurationException e) {
-            psvi = false;
-        }
-        
         // Determine schema dv factory to use
         SchemaDVFactory dvFactory = null;
         try {
@@ -994,19 +989,6 @@
         }
         fSchemaHandler.setDVFactory(dvFactory);
 
-        if (!psvi) {
-            fDeclPool.reset();
-            fCMBuilder.setDeclPool(fDeclPool);
-            fSchemaHandler.setDeclPool(fDeclPool);
-            if (dvFactory instanceof SchemaDVFactoryImpl) {
-                fDeclPool.setDVFactory((SchemaDVFactoryImpl)dvFactory);
-                ((SchemaDVFactoryImpl)dvFactory).setDeclPool(fDeclPool);
-            }
-        } else {
-            fCMBuilder.setDeclPool(null);
-            fSchemaHandler.setDeclPool(null);
-        }
-        
         // get schema location properties
         try {
             fExternalSchemas = (String) componentManager.getProperty(SCHEMA_LOCATION);
@@ -1033,6 +1015,37 @@
             fGrammarPool = null;
         }
         initGrammarBucket();
+
+        boolean psvi = true;
+        try {
+            psvi = componentManager.getFeature(AUGMENT_PSVI);
+        } catch (XMLConfigurationException e) {
+            psvi = false;
+        }
+        
+        // Only use the decl pool when there is no chance that the schema
+        // components will be exposed or cached.
+        if (!psvi && fGrammarPool == null) {
+            if (fDeclPool != null) {
+                fDeclPool.reset();
+            }
+            else {
+                fDeclPool = new XSDeclarationPool();
+            }
+            fCMBuilder.setDeclPool(fDeclPool);
+            fSchemaHandler.setDeclPool(fDeclPool);
+            if (dvFactory instanceof SchemaDVFactoryImpl) {
+                fDeclPool.setDVFactory((SchemaDVFactoryImpl)dvFactory);
+                ((SchemaDVFactoryImpl)dvFactory).setDeclPool(fDeclPool);
+            }
+        } else {
+            fCMBuilder.setDeclPool(null);
+            fSchemaHandler.setDeclPool(null);
+            if (dvFactory instanceof SchemaDVFactoryImpl) {
+                ((SchemaDVFactoryImpl)dvFactory).setDeclPool(null);
+            }
+        }
+        
         // get continue-after-fatal-error feature
         try {
             boolean fatalError = componentManager.getFeature(CONTINUE_AFTER_FATAL_ERROR);



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