You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ne...@apache.org on 2003/01/17 20:43:02 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/impl/xs/models CMBuilder.java CMNodeFactory.java

neilg       2003/01/17 11:43:02

  Modified:    java/src/org/apache/xerces/impl/xs XMLSchemaLoader.java
                        XMLSchemaValidator.java
               java/src/org/apache/xerces/impl/xs/models CMBuilder.java
                        CMNodeFactory.java
  Log:
  CMNodeFactory should not be a singleton, since this could cause thread-safety issues.
  
  Revision  Changes    Path
  1.15      +4 -4      xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java
  
  Index: XMLSchemaLoader.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- XMLSchemaLoader.java	16 Jan 2003 23:03:08 -0000	1.14
  +++ XMLSchemaLoader.java	17 Jan 2003 19:43:01 -0000	1.15
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2000-2002 The Apache Software Foundation.
  + * Copyright (c) 2000-2003 The Apache Software Foundation.
    * All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -249,8 +249,8 @@
               sHandler = new SubstitutionGroupHandler(fGrammarBucket);
           }
           fSubGroupHandler = sHandler;
  -        //get the factory instance.. this class is singleton
  -        CMNodeFactory nodeFactory = CMNodeFactory.newInstance() ;
  +        //get an instance of the CMNodeFactory */
  +        CMNodeFactory nodeFactory = new CMNodeFactory() ;
           //REVISIT: shouldn't the SecurityManager be allowed to set, if an application tries to load standalone schema - nb.
           if(builder == null) {
               builder = new CMBuilder(nodeFactory);
  
  
  
  1.131     +3 -3      xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
  
  Index: XMLSchemaValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java,v
  retrieving revision 1.130
  retrieving revision 1.131
  diff -u -r1.130 -r1.131
  --- XMLSchemaValidator.java	16 Jan 2003 23:03:08 -0000	1.130
  +++ XMLSchemaValidator.java	17 Jan 2003 19:43:01 -0000	1.131
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.
  + * Copyright (c) 1999-2003 The Apache Software Foundation.
    * All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -1077,7 +1077,7 @@
       //          so that we can QNameDV.getCompiledForm()
       final XSSimpleType fQNameDV = (XSSimpleType)SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(SchemaSymbols.ATTVAL_QNAME);
       
  -    final CMNodeFactory nodeFactory = CMNodeFactory.newInstance();
  +    final CMNodeFactory nodeFactory = new CMNodeFactory();
       /** used to build content models */
       // REVISIT: create decl pool, and pass it to each traversers
       final CMBuilder fCMBuilder = new CMBuilder(nodeFactory);
  
  
  
  1.17      +2 -11     xml-xerces/java/src/org/apache/xerces/impl/xs/models/CMBuilder.java
  
  Index: CMBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/models/CMBuilder.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- CMBuilder.java	17 Jan 2003 10:12:33 -0000	1.16
  +++ CMBuilder.java	17 Jan 2003 19:43:02 -0000	1.17
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001, 2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -94,15 +94,6 @@
           fDeclPool = null;
           fNodeFactory = nodeFactory ;
       }
  -
  -    public CMBuilder(XSDeclarationPool pool) {
  -        fDeclPool = pool;
  -        //xxx is this constructor used ? but there would be nothing wrong if factory is created.. but we dont have security manager set.
  -        if(fNodeFactory == null)
  -        {
  -            fNodeFactory = CMNodeFactory.newInstance();
  -        }
  -    }//CMBuilder
   
       public void setDeclPool(XSDeclarationPool declPool) {
           fDeclPool = declPool;
  
  
  
  1.3       +13 -18    xml-xerces/java/src/org/apache/xerces/impl/xs/models/CMNodeFactory.java
  
  Index: CMNodeFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/models/CMNodeFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CMNodeFactory.java	17 Jan 2003 10:12:33 -0000	1.2
  +++ CMNodeFactory.java	17 Jan 2003 19:43:02 -0000	1.3
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -85,7 +85,7 @@
       private int nodeCount = 0;
       
       //No. of nodes allowed.
  -    private int maxNodelimit ;
  +    private int maxNodeLimit ;
   
       
       /**
  @@ -94,20 +94,12 @@
        */
       private XMLErrorReporter fErrorReporter;
   
  -    // stores defaults for different security holes (maxOccurlimit in current context) if it has
  +    // stores defaults for different security holes (maxOccurLimit in current context) if it has
       // been set on the configuration.
       private SecurityManager fSecurityManager = null;
       
  -    //static instance of CMNodeFactory..
  -    private static CMNodeFactory fNodeFactory ;
  -    
  -    /** instance of CMNodeFactory can't be created outside this class*/
  -    private CMNodeFactory() {
  -    }
  -    
  -    /** Get the instance of CMNodeFactory, further call to this method will give same instance, its singleton class */
  -    public static CMNodeFactory newInstance(){
  -        return fNodeFactory != null ? fNodeFactory : new CMNodeFactory() ;
  +    /** default constructor */
  +    public CMNodeFactory() {
       }
       
       public void reset(XMLComponentManager componentManager){
  @@ -116,7 +108,7 @@
               fSecurityManager = (SecurityManager)componentManager.getProperty(SECURITY_MANAGER);
               //we are setting the limit of number of nodes to 3times the maxOccur value..
               if(fSecurityManager != null){
  -                maxNodelimit = fSecurityManager.getMaxOccurNodeLimit() * MULTIPLICITY ;
  +                maxNodeLimit = fSecurityManager.getMaxOccurNodeLimit() * MULTIPLICITY ;
               }
           }
           catch (XMLConfigurationException e) {
  @@ -141,12 +133,15 @@
       }
       
       public void nodeCountCheck(){
  -        if( fSecurityManager != null && nodeCount++ > maxNodelimit){
  +        if( fSecurityManager != null && nodeCount++ > maxNodeLimit){
               if(DEBUG){
                   System.out.println("nodeCount = " + nodeCount ) ;
  -                System.out.println("nodeLimit = " + maxNodelimit ) ;
  +                System.out.println("nodeLimit = " + maxNodeLimit ) ;
               }
  -            fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN, "maxOccurLimit", new Object[]{ new Integer(maxNodelimit) }, XMLErrorReporter.SEVERITY_FATAL_ERROR);
  +            fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN, "maxOccurLimit", new Object[]{ new Integer(maxNodeLimit) }, XMLErrorReporter.SEVERITY_FATAL_ERROR);
  +            // similarly to entity manager behaviour, take into accont
  +            // behaviour if continue-after-fatal-error is set.
  +            nodeCount = 0;
           }
           
       }//nodeCountCheck()
  @@ -178,7 +173,7 @@
               String property = propertyId.substring(Constants.XERCES_PROPERTY_PREFIX.length());
               if (property.equals(Constants.SECURITY_MANAGER_PROPERTY)) {
                   fSecurityManager = (SecurityManager)value;                
  -                maxNodelimit = (fSecurityManager != null) ? fSecurityManager.getMaxOccurNodeLimit() * MULTIPLICITY : 0 ;
  +                maxNodeLimit = (fSecurityManager != null) ? fSecurityManager.getMaxOccurNodeLimit() * MULTIPLICITY : 0 ;
                   return;
               }
               if (property.equals(Constants.ERROR_REPORTER_PROPERTY)) {
  
  
  

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