xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject cvs commit: xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema SchemaAnnotationImpl.java SchemaTypeCodePrinter.java SchemaTypeSystemImpl.java
Date Thu, 11 Nov 2004 04:02:21 GMT
radup       2004/11/10 20:02:21

  Modified:    v2/src/typeimpl/org/apache/xmlbeans/impl/schema
                        SchemaAnnotationImpl.java
                        SchemaTypeCodePrinter.java
                        SchemaTypeSystemImpl.java
  Log:
  Performance improvements loading xsb files.
  
  Revision  Changes    Path
  1.4       +52 -6     xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAnnotationImpl.java
  
  Index: SchemaAnnotationImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAnnotationImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SchemaAnnotationImpl.java	6 Aug 2004 02:28:30 -0000	1.3
  +++ SchemaAnnotationImpl.java	11 Nov 2004 04:02:21 -0000	1.4
  @@ -22,6 +22,7 @@
   import org.apache.xmlbeans.SchemaAnnotation;
   import org.apache.xmlbeans.SchemaTypeSystem;
   import org.apache.xmlbeans.XmlCursor;
  +import org.apache.xmlbeans.XmlException;
   import org.apache.xmlbeans.XmlObject;
   import org.w3.x2001.xmlSchema.AppinfoDocument;
   import org.w3.x2001.xmlSchema.Annotated;
  @@ -32,15 +33,61 @@
   public class SchemaAnnotationImpl implements SchemaAnnotation
   {
       private SchemaContainer _container;
  +    private String[] _appInfoAsXml;
       private AppinfoDocument.Appinfo[] _appInfo;
  +    private String[] _documentationAsXml;
       private DocumentationDocument.Documentation[] _documentation;
       private Attribute[] _attributes;
   
       public XmlObject[] getApplicationInformation()
  -    {   return _appInfo; }
  +    {
  +        if (_appInfo == null)
  +        {
  +            int n = _appInfoAsXml.length;
  +            _appInfo = new AppinfoDocument.Appinfo[n];
  +            for (int i = 0; i < n; i++)
  +            {
  +                String appInfo = _appInfoAsXml[i];
  +                try
  +                {
  +                    _appInfo[i] = AppinfoDocument.Factory.
  +                        parse(appInfo).getAppinfo();
  +                }
  +                catch(XmlException e)
  +                {
  +                    // problem in the classfile
  +                    _appInfo[i] = AppinfoDocument.Factory.
  +                        newInstance().getAppinfo();
  +                }
  +            }
  +        }
  +        return _appInfo;
  +    }
   
       public XmlObject[] getUserInformation()
  -    {   return _documentation; }
  +    {
  +        if (_documentation == null)
  +        {
  +            int n = _documentationAsXml.length;
  +            _documentation = new DocumentationDocument.Documentation[n];
  +            for (int i = 0; i <  n; i++)
  +            {
  +                String doc = _documentationAsXml[i];
  +                try 
  +                {
  +                    _documentation[i] = DocumentationDocument.Factory.
  +                        parse(doc).getDocumentation();
  +                }
  +                catch (XmlException e)
  +                {
  +                    // problem in the classfile
  +                    _documentation[i] = DocumentationDocument.Factory.
  +                        newInstance().getDocumentation();
  +                }
  +            }
  +        }
  +        return _documentation;
  +    }
   
       public Attribute[] getAttributes()
       {   return _attributes; }
  @@ -125,13 +172,12 @@
       }
   
       /*package*/ SchemaAnnotationImpl(SchemaContainer c,
  -        AppinfoDocument.Appinfo[] aap,
  -        DocumentationDocument.Documentation[] adoc,
  +        String[] aapStrings, String[] adocStrings,
           Attribute[] aat)
       {
           _container = c;
  -        _appInfo = aap;
  -        _documentation = adoc;
  +        _appInfoAsXml = aapStrings;
  +        _documentationAsXml = adocStrings;
           _attributes = aat;
       }
   
  
  
  
  1.13      +4 -1      xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java
  
  Index: SchemaTypeCodePrinter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- SchemaTypeCodePrinter.java	9 Oct 2004 17:30:16 -0000	1.12
  +++ SchemaTypeCodePrinter.java	11 Nov 2004 04:02:21 -0000	1.13
  @@ -279,7 +279,10 @@
           indent();
           emit("private " + shortName + "() { }");
           emit("public static final org.apache.xmlbeans.SchemaTypeSystem typeSystem = loadTypeSystem();");
  -        emit("static { typeSystem.resolve(); }");
  +        // Commenting out this line has the effect of not loading all components in a
  +        // typesystem upfront, but just as they are needed, which may improve
  +        // performance significantly
  +//         emit("static { typeSystem.resolve(); }");
           emit("private static final org.apache.xmlbeans.SchemaTypeSystem loadTypeSystem()");
           emit("{");
           indent();
  
  
  
  1.14      +6 -26     xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
  
  Index: SchemaTypeSystemImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- SchemaTypeSystemImpl.java	1 Nov 2004 04:25:58 -0000	1.13
  +++ SchemaTypeSystemImpl.java	11 Nov 2004 04:02:21 -0000	1.14
  @@ -1749,42 +1749,22 @@
   
               // Read documentation items
               n = readInt();
  -            DocumentationDocument.Documentation[] documentationItems =
  -                new DocumentationDocument.Documentation[n];
  +            String[] docStrings = new String[n];
               for (int i = 0; i <  n; i++)
               {
  -                String doc = readString();
  -                try 
  -                {
  -                    documentationItems[i] = DocumentationDocument.Factory.
  -                        parse(doc).getDocumentation();
  -                }
  -                catch (XmlException e)
  -                {
  -                    throw new RuntimeException( e.getMessage(), e );
  -                }
  +                docStrings[i] = readString();
               }
   
               // Read application info items
               n = readInt();
  -            AppinfoDocument.Appinfo[] appInfoItems =
  -                new AppinfoDocument.Appinfo[n];
  +            String[] appInfoStrings = new String[n];
               for (int i = 0; i < n; i++)
               {
  -                String appInfo = readString();
  -                try
  -                {
  -                    appInfoItems[i] = AppinfoDocument.Factory.
  -                        parse(appInfo).getAppinfo();
  -                }
  -                catch(XmlException e)
  -                {
  -                    throw new RuntimeException( e.getMessage(), e );
  -                }
  +                appInfoStrings[i] = readString();
               }
   
  -            return new SchemaAnnotationImpl(c, appInfoItems,
  -                documentationItems, attributes);
  +            return new SchemaAnnotationImpl(c, appInfoStrings,
  +                docStrings, attributes);
           }
   
           void writeAnnotations(SchemaAnnotation[] anns)
  
  
  

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


Mime
View raw message