xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kkro...@apache.org
Subject svn commit: r149358 - in xmlbeans/trunk: ./ src/typeimpl/org/apache/xmlbeans/impl/schema/ src/xmlcomp/org/apache/xmlbeans/impl/tool/ src/xmlpublic/org/apache/xmlbeans/ test/src/compile/scomp/checkin/
Date Tue, 01 Feb 2005 01:58:21 GMT
Author: kkrouse
Date: Mon Jan 31 17:58:19 2005
New Revision: 149358

URL: http://svn.apache.org/viewcvs?view=rev&rev=149358
Log:
- throw IllegalStateException when saving a partial schema type system
- move ResourceLoader to public api, add a XmlBeans.typeLoaderForResource() method

Added:
    xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/ResourceLoader.java
      - copied, changed from r149349, xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/ResourceLoader.java
Removed:
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/ResourceLoader.java
Modified:
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/ClassLoaderResourceLoader.java
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/FileResourceLoader.java
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/PathResourceLoader.java
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
    xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/InstanceValidator.java
    xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java
    xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/StreamInstanceValidator.java
    xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/TypeHierarchyPrinter.java
    xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java
    xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java
    xmlbeans/trunk/testbuild.xml

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/ClassLoaderResourceLoader.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/ClassLoaderResourceLoader.java?view=diff&r1=149357&r2=149358
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/ClassLoaderResourceLoader.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/ClassLoaderResourceLoader.java
Mon Jan 31 17:58:19 2005
@@ -15,6 +15,8 @@
 
 package org.apache.xmlbeans.impl.schema;
 
+import org.apache.xmlbeans.ResourceLoader;
+
 import java.io.InputStream;
 
 public class ClassLoaderResourceLoader implements ResourceLoader

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/FileResourceLoader.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/FileResourceLoader.java?view=diff&r1=149357&r2=149358
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/FileResourceLoader.java (original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/FileResourceLoader.java Mon
Jan 31 17:58:19 2005
@@ -15,6 +15,8 @@
 
 package org.apache.xmlbeans.impl.schema;
 
+import org.apache.xmlbeans.ResourceLoader;
+
 import java.io.InputStream;
 import java.io.FileInputStream;
 import java.io.File;

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/PathResourceLoader.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/PathResourceLoader.java?view=diff&r1=149357&r2=149358
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/PathResourceLoader.java (original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/PathResourceLoader.java Mon
Jan 31 17:58:19 2005
@@ -15,6 +15,8 @@
 
 package org.apache.xmlbeans.impl.schema;
 
+import org.apache.xmlbeans.ResourceLoader;
+
 import java.io.InputStream;
 import java.io.File;
 import java.io.IOException;

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java?view=diff&r1=149357&r2=149358
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
Mon Jan 31 17:58:19 2005
@@ -23,6 +23,7 @@
 import org.apache.xmlbeans.SchemaAttributeGroup;
 import org.apache.xmlbeans.SchemaTypeSystem;
 import org.apache.xmlbeans.SchemaIdentityConstraint;
+import org.apache.xmlbeans.ResourceLoader;
 import org.apache.xmlbeans.impl.common.QNameHelper;
 import org.apache.xmlbeans.impl.common.XBeanDebug;
 import javax.xml.namespace.QName;

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java?view=diff&r1=149357&r2=149358
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
Mon Jan 31 17:58:19 2005
@@ -39,6 +39,7 @@
 import org.apache.xmlbeans.XmlAnySimpleType;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.ResourceLoader;
 import org.apache.xmlbeans.impl.common.NameUtil;
 import org.apache.xmlbeans.impl.common.QNameHelper;
 import org.apache.xmlbeans.impl.common.XBeanDebug;
@@ -1270,15 +1271,13 @@
 
     public void saveToDirectory(File classDir)
     {
-        if (_partial)
-            return;
         save(new FilerImpl(classDir, null, null, false, false));
     }
 
     public void save(Filer filer)
     {
         if (_partial)
-            return;
+            throw new IllegalStateException("Partial SchemaTypeSystems cannot be saved.");
         
         if (filer == null)
             throw new IllegalArgumentException("filer must not be null");
@@ -1318,7 +1317,7 @@
     public void saveGlobalElements(SchemaGlobalElement[] elts)
     {
         if (_partial)
-            return;
+            throw new IllegalStateException("Partial SchemaTypeSystems cannot be saved.");
         for (int i = 0; i < elts.length; i++)
         {
             saveGlobalElement(elts[i]);
@@ -1328,7 +1327,7 @@
     public void saveGlobalAttributes(SchemaGlobalAttribute[] attrs)
     {
         if (_partial)
-            return;
+            throw new IllegalStateException("Partial SchemaTypeSystems cannot be saved.");
         for (int i = 0; i < attrs.length; i++)
         {
             saveGlobalAttribute(attrs[i]);
@@ -1338,7 +1337,7 @@
     public void saveModelGroups(SchemaModelGroup[] groups)
     {
         if (_partial)
-            return;
+            throw new IllegalStateException("Partial SchemaTypeSystems cannot be saved.");
         for (int i = 0; i < groups.length; i++)
         {
             saveModelGroup(groups[i]);
@@ -1348,7 +1347,7 @@
     public void saveAttributeGroups(SchemaAttributeGroup[] groups)
     {
         if (_partial)
-            return;
+            throw new IllegalStateException("Partial SchemaTypeSystems cannot be saved.");
         for (int i = 0; i < groups.length; i++)
         {
             saveAttributeGroup(groups[i]);
@@ -1358,7 +1357,7 @@
     public void saveIdentityConstraints(SchemaIdentityConstraint[] idcs)
     {
         if (_partial)
-            return;
+            throw new IllegalStateException("Partial SchemaTypeSystems cannot be saved.");
         for (int i = 0; i < idcs.length; i++)
         {
             saveIdentityConstraint(idcs[i]);
@@ -1368,7 +1367,7 @@
     public void saveGlobalElement(SchemaGlobalElement elt)
     {
         if (_partial)
-            return;
+            throw new IllegalStateException("Partial SchemaTypeSystems cannot be saved.");
         String handle = _localHandles.handleForElement(elt);
         XsbReader saver = new XsbReader(handle);
         saver.writeParticleData((SchemaParticle)elt);
@@ -1382,7 +1381,7 @@
     public void saveGlobalAttribute(SchemaGlobalAttribute attr)
     {
         if (_partial)
-            return;
+            throw new IllegalStateException("Partial SchemaTypeSystems cannot be saved.");
         String handle = _localHandles.handleForAttribute(attr);
         XsbReader saver = new XsbReader(handle);
         saver.writeAttributeData(attr);
@@ -1396,7 +1395,7 @@
     public void saveModelGroup(SchemaModelGroup grp)
     {
         if (_partial)
-            return;
+            throw new IllegalStateException("Partial SchemaTypeSystems cannot be saved.");
         String handle = _localHandles.handleForModelGroup(grp);
         XsbReader saver = new XsbReader(handle);
         saver.writeModelGroupData(grp);
@@ -1408,7 +1407,7 @@
     public void saveAttributeGroup(SchemaAttributeGroup grp)
     {
         if (_partial)
-            return;
+            throw new IllegalStateException("Partial SchemaTypeSystems cannot be saved.");
         String handle = _localHandles.handleForAttributeGroup(grp);
         XsbReader saver = new XsbReader(handle);
         saver.writeAttributeGroupData(grp);
@@ -1420,7 +1419,7 @@
     public void saveIdentityConstraint(SchemaIdentityConstraint idc)
     {
         if (_partial)
-            return;
+            throw new IllegalStateException("Partial SchemaTypeSystems cannot be saved.");
         String handle = _localHandles.handleForIdentityConstraint(idc);
         XsbReader saver = new XsbReader(handle);
         saver.writeIdConstraintData(idc);

Modified: xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/InstanceValidator.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/InstanceValidator.java?view=diff&r1=149357&r2=149358
==============================================================================
--- xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/InstanceValidator.java (original)
+++ xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/InstanceValidator.java Mon Jan
31 17:58:19 2005
@@ -35,7 +35,7 @@
     public static void printUsage()
     {
         System.out.println("Validates a schema defintion and instances within the schema.");
-        System.out.println("Usage: validate [switches] schema.xsd instance.xml");
+        System.out.println("Usage: validate [switches] schema.jar schema.xsd instance.xml");
         System.out.println("Switches:");
         System.out.println("    -dl    enable network downloads for imports and includes");
         System.out.println("    -nopvr disable particle valid (restriction) rule");
@@ -102,6 +102,7 @@
         
         File[] schemaFiles = cl.filesEndingWith(".xsd");
         File[] instanceFiles = cl.filesEndingWith(".xml");
+        File[] jarFiles = cl.filesEndingWith(".jar");
         
         List sdocs = new ArrayList();
         
@@ -122,7 +123,7 @@
 
         XmlObject[] schemas = (XmlObject[])sdocs.toArray(new XmlObject[0]);
 
-        SchemaTypeLoader sLoader;
+        SchemaTypeLoader sLoader = null;
         Collection compErrors = new ArrayList();
         XmlOptions schemaOptions = new XmlOptions();
         schemaOptions.setErrorListener(compErrors);
@@ -135,9 +136,13 @@
         if (partial)
             schemaOptions.put("COMPILE_PARTIAL_TYPESYSTEM");
         
+        if (jarFiles != null && jarFiles.length > 0)
+            sLoader = XmlBeans.typeLoaderForResource(XmlBeans.resourceLoaderForPath(jarFiles));
+        
         try
         {
-            sLoader = XmlBeans.loadXsd(schemas, schemaOptions);
+            if (schemas != null && schemas.length > 0)
+                sLoader = XmlBeans.compileXsd(schemas, sLoader, schemaOptions);
         }
         catch (Exception e)
         {

Modified: xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java?view=diff&r1=149357&r2=149358
==============================================================================
--- xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java (original)
+++ xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java Mon Jan 31
17:58:19 2005
@@ -24,12 +24,12 @@
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.ResourceLoader;
 import org.apache.xmlbeans.impl.common.IOUtil;
 import org.apache.xmlbeans.impl.common.ResolverUtil;
 import org.apache.xmlbeans.impl.common.XmlErrorPrinter;
 import org.apache.xmlbeans.impl.common.XmlErrorWatcher;
 import org.apache.xmlbeans.impl.schema.PathResourceLoader;
-import org.apache.xmlbeans.impl.schema.ResourceLoader;
 import org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl;
 import org.apache.xmlbeans.impl.schema.SchemaTypeSystemCompiler;
 import org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl;

Modified: xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/StreamInstanceValidator.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/StreamInstanceValidator.java?view=diff&r1=149357&r2=149358
==============================================================================
--- xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/StreamInstanceValidator.java
(original)
+++ xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/StreamInstanceValidator.java
Mon Jan 31 17:58:19 2005
@@ -106,6 +106,7 @@
 
         File[] schemaFiles = cl.filesEndingWith(".xsd");
         File[] instanceFiles = cl.filesEndingWith(".xml");
+        File[] jarFiles = cl.filesEndingWith(".jar");
 
         List sdocs = new ArrayList();
 
@@ -123,7 +124,7 @@
 
         XmlObject[] schemas = (XmlObject[])sdocs.toArray(new XmlObject[0]);
 
-        SchemaTypeLoader sLoader;
+        SchemaTypeLoader sLoader = null;
         Collection compErrors = new ArrayList();
         XmlOptions schemaOptions = new XmlOptions();
         schemaOptions.setErrorListener(compErrors);
@@ -134,8 +135,12 @@
         if (noupa)
             schemaOptions.setCompileNoUpaRule();
 
+        if (jarFiles != null && jarFiles.length > 0)
+            sLoader = XmlBeans.typeLoaderForResource(XmlBeans.resourceLoaderForPath(jarFiles));
+        
         try {
-            sLoader = XmlBeans.loadXsd(schemas, schemaOptions);
+            if (schemas != null && schemas.length > 0)
+                sLoader = XmlBeans.compileXsd(schemas, sLoader, schemaOptions);
         }
         catch (Exception e) {
             if (compErrors.isEmpty() || !(e instanceof XmlException)) {

Modified: xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/TypeHierarchyPrinter.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/TypeHierarchyPrinter.java?view=diff&r1=149357&r2=149358
==============================================================================
--- xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/TypeHierarchyPrinter.java (original)
+++ xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/TypeHierarchyPrinter.java Mon
Jan 31 17:58:19 2005
@@ -21,6 +21,7 @@
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.SchemaTypeSystem;
 import org.apache.xmlbeans.SchemaType;
+import org.apache.xmlbeans.SchemaTypeLoader;
 import org.apache.xmlbeans.impl.common.QNameHelper;
 
 import java.util.Collections;
@@ -101,7 +102,8 @@
         boolean noupa = (cl.getOpt("noupa") != null);
         boolean partial = (cl.getOpt("partial") != null);
         
-        File[] schemaFiles = cl.getFiles();
+        File[] schemaFiles = cl.filesEndingWith(".xsd");
+        File[] jarFiles = cl.filesEndingWith(".jar");
         
         // step 1: load all the files
         List sdocs = new ArrayList();
@@ -123,6 +125,7 @@
         XmlObject[] schemas = (XmlObject[])sdocs.toArray(new XmlObject[0]);
         
         // step 2: compile all the schemas
+        SchemaTypeLoader linkTo = null;
         SchemaTypeSystem typeSystem;
         Collection compErrors = new ArrayList();
         XmlOptions schemaOptions = new XmlOptions();
@@ -135,9 +138,12 @@
         if (partial)
             schemaOptions.put("COMPILE_PARTIAL_TYPESYSTEM");
         
+        if (jarFiles != null && jarFiles.length > 0)
+            linkTo = XmlBeans.typeLoaderForResource(XmlBeans.resourceLoaderForPath(jarFiles));
+        
         try
         {
-            typeSystem = XmlBeans.compileXsd(schemas, XmlBeans.getBuiltinTypeSystem(), schemaOptions);
+            typeSystem = XmlBeans.compileXsd(schemas, linkTo, schemaOptions);
         }
         catch (XmlException e)
         {

Copied: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/ResourceLoader.java (from r149349,
xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/ResourceLoader.java)
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/ResourceLoader.java?view=diff&rev=149358&p1=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/ResourceLoader.java&r1=149349&p2=xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/ResourceLoader.java&r2=149358
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/ResourceLoader.java (original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/ResourceLoader.java Mon Jan 31 17:58:19
2005
@@ -13,7 +13,7 @@
  *  limitations under the License.
  */
 
-package org.apache.xmlbeans.impl.schema;
+package org.apache.xmlbeans;
 
 import java.io.InputStream;
 

Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java?view=diff&r1=149357&r2=149358
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java (original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java Mon Jan 31 17:58:19 2005
@@ -19,6 +19,8 @@
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.lang.reflect.Constructor;
+import java.io.File;
 
 import javax.xml.stream.XMLStreamReader;
 
@@ -122,6 +124,7 @@
     private static final Method _nodeToXmlObjectMethod = buildNodeToXmlObjectMethod();
     private static final Method _nodeToXmlStreamMethod = buildNodeToXmlStreamMethod();
     private static final Method _streamToNodeMethod = buildStreamToNodeMethod();
+    private static final Constructor _pathResourceLoaderConstructor = buildPathResourceLoaderConstructor();
 
     private static RuntimeException causedException ( RuntimeException e, Throwable cause
)
     {
@@ -138,6 +141,24 @@
         return new XmlException( e.getMessage(), e );
     }
 
+    private static final Constructor buildConstructor ( String className, Class[] args )
+    {
+        try
+        {
+            return
+                Class.forName(
+                    className, false, XmlBeans.class.getClassLoader() ).
+                getConstructor( args );
+        }
+        catch ( Exception e )
+        {
+            throw causedException(
+                new IllegalStateException(
+                    "Cannot load constructor for " + className +
+                ": verify that xbean.jar is on the classpath" ), e );
+        }
+    }
+    
     private static final Method buildMethod ( String className, String methodName, Class[]
args )
     {
         try
@@ -184,27 +205,10 @@
 
     private static final Method buildTypeLoaderBuilderMethod ( )
     {
-        Class resourceLoaderClass;
-        
-        try
-        {
-            resourceLoaderClass =
-                Class.forName(
-                    "org.apache.xmlbeans.impl.schema.ResourceLoader",
-                    false, XmlBeans.class.getClassLoader() );
-        }
-        catch ( Exception e )
-        {
-            throw causedException(
-                new IllegalStateException(
-                    "Cannot load " + "ResourceLoader" +
-                        ": verify that xbean.jar is on the classpath" ), e );
-        }
-        
         return
             buildMethod(
                 "org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl", "build",
-                new Class[] { SchemaTypeLoader[].class, resourceLoaderClass, ClassLoader.class
} );
+                new Class[] { SchemaTypeLoader[].class, ResourceLoader.class, ClassLoader.class
} );
     }
 
     private static final Method buildCompilationMethod()
@@ -237,6 +241,14 @@
                 "org.apache.xmlbeans.impl.newstore2.Locale", "streamToNode",
                 new Class[] { XMLStreamReader.class } );
     }
+    
+    private static final Constructor buildPathResourceLoaderConstructor()
+    {
+        return
+            buildConstructor(
+                "org.apache.xmlbeans.impl.schema.PathResourceLoader",
+                new Class[] { File[].class } );
+    }
 
     /**
      * Compiles an XPath, returning a String equal to that which was passed,
@@ -510,7 +522,7 @@
      */
     public static SchemaTypeSystem compileXsd(XmlObject[] schemas, SchemaTypeLoader typepath,
XmlOptions options) throws XmlException
     {
-        return compileXmlBeans(null, null, schemas, null, typepath, null, options);
+        return compileXmlBeans(null, null, schemas, null, typepath!=null ? typepath : getContextTypeLoader(),
null, options);
     }
 
     /**
@@ -558,7 +570,7 @@
      */
     public static SchemaTypeSystem compileXsd(SchemaTypeSystem system, XmlObject[] schemas,
SchemaTypeLoader typepath, XmlOptions options) throws XmlException
     {
-        return compileXmlBeans(null, system, schemas, null, typepath, null, options);
+        return compileXmlBeans(null, system, schemas, null, typepath != null ? typepath :
getContextTypeLoader(), null, options);
     }
 
     /**
@@ -682,7 +694,53 @@
             throw causedException( new IllegalStateException(e.getMessage()), e );
         }
     }
+    
+    /**
+     * Returns a SchemaTypeLoader that searches for compiled schema types
+     * in the given ResourceLoader.
+     * 
+     * @see XmlBeans#resourceLoaderForPath(File[])
+     */
+    public static SchemaTypeLoader typeLoaderForResource(ResourceLoader resourceLoader)
+    {
+        try
+        {
+            return (SchemaTypeLoader)_typeLoaderBuilderMethod.invoke(null, new Object[] {null,
resourceLoader, null});
+        }
+        catch (IllegalAccessException e)
+        {
+            throw causedException(new IllegalStateException("No access to SchemaTypeLoaderImpl:
verify that version of xbean.jar is correct"), e);
+        }
+        catch (InvocationTargetException e)
+        {
+            throw causedException(new IllegalStateException(e.getMessage()), e);
+        }
+    }
 
+    /**
+     * Returns a new ResourceLoader for a search path where each component of
+     * the path is either a directory or a compiled xbean jar.
+     */
+    public static ResourceLoader resourceLoaderForPath(File[] path)
+    {
+        try
+        {
+            return (ResourceLoader)_pathResourceLoaderConstructor.newInstance(new Object[]
{path});
+        }
+        catch (IllegalAccessException e)
+        {
+            throw causedException(new IllegalStateException("No access to SchemaTypeLoaderImpl:
verify that version of xbean.jar is correct"), e);
+        }
+        catch (InstantiationException e)
+        {
+            throw causedException(new IllegalStateException(e.getMessage()), e);
+        }
+        catch (InvocationTargetException e)
+        {
+            throw causedException(new IllegalStateException(e.getMessage()), e);
+        }
+    }
+    
     /**
      * Returns the SchemaType from a corresponding XmlObject subclass,
      * or null if none.

Modified: xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java?view=diff&r1=149357&r2=149358
==============================================================================
--- xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java (original)
+++ xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java Mon Jan 31
17:58:19 2005
@@ -1,6 +1,7 @@
 package compile.scomp.checkin;
 
 import org.apache.xmlbeans.*;
+import org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl;
 import compile.scomp.common.mockobj.TestFiler;
 import compile.scomp.common.CompileCommon;
 import compile.scomp.common.CompileTestBase;
@@ -145,15 +146,18 @@
                     System.err.println(i.next());
             throw e;
         }
+        
+        Assert.assertTrue("Expected partial schema type system", ((SchemaTypeSystemImpl)sts).isPartial());
 
 
         //call some stupid methods on STS
         printSTS(sts);
 
         // Check using saveToDirectory on Partial SOM
+        File tempDir = null;
         try {
             //setUp outputDirectory
-            File tempDir = new File(CompileCommon.outputroot, "psom_save");
+            tempDir = new File(CompileCommon.outputroot, "psom_save");
             tempDir.mkdirs();
             tempDir.deleteOnExit();
             Assert.assertTrue("Output Directory Init needed to be empty",
@@ -161,46 +165,51 @@
 
             //This should not Work
             sts.saveToDirectory(tempDir);
-            tempDir.exists();
-            //make sure nothing was written
-            Assert.assertTrue("Partial SOM output dir needed to be empty",
-                    tempDir.listFiles().length == 0);
-
-        } catch (Exception e) {
-            throw e;
+            Assert.fail("Expected IllegalStateException");
+        } catch (IllegalStateException e) {
+            // ok
+            System.out.println("sts.saveToDirectory() threw IllegalStateException as expected");
         }
+        
+        //make sure nothing was written
+        Assert.assertTrue("Partial SOM output dir needed to be empty",
+            tempDir.listFiles().length == 0);
 
         // Check using save(Filer) on Partial SOM
+        TestFiler tf = null;
         try {
             //setUp outputDirectory
-            TestFiler tf = new TestFiler();
+            tf = new TestFiler();
             Assert.assertTrue("Filer Source should have been size 0",
                     tf.getBinFileVec().size() == 0);
 
             //This should not Work
             sts.save(tf);
-            //make sure nothing was written
-            Assert.assertTrue("Filer -Bin- Partial SOM " +
-                    "output dir needed to be empty",
-                    tf.getBinFileVec().size() == 0);
-            Assert.assertTrue("Filer -SRC- Partial SOM " +
-                    "output dir needed to be empty",
-                    tf.getSrcFileVec().size() == 0);
-
-            Assert.assertFalse("Filer Create Source File " +
-                    "method should not have been invoked",
-                    tf.isCreateSourceFile());
-
-            Assert.assertFalse("Filer Create Binary File " +
-                    "method should not have been invoked",
-                    tf.isCreateBinaryFile());
-        } catch (Exception e) {
-            throw e;
+            Assert.fail("Expected IllegalStateException");
+        } catch (IllegalStateException e) {
+            // ok
+            System.out.println("sts.save() threw IllegalStateException as expected");
         }
+        
+        //make sure nothing was written
+        Assert.assertTrue("Filer -Bin- Partial SOM " +
+            "output dir needed to be empty",
+            tf.getBinFileVec().size() == 0);
+        Assert.assertTrue("Filer -SRC- Partial SOM " +
+            "output dir needed to be empty",
+            tf.getSrcFileVec().size() == 0);
+        
+        Assert.assertFalse("Filer Create Source File " +
+            "method should not have been invoked",
+            tf.isCreateSourceFile());
+        
+        Assert.assertFalse("Filer Create Binary File " +
+            "method should not have been invoked",
+            tf.isCreateBinaryFile());
 
         // Check using filer in partial SOM compilation
         try {
-            TestFiler tf = new TestFiler();
+            tf = new TestFiler();
 
             Assert.assertTrue("Filer Source should have been size 0",
                     tf.getBinFileVec().size() == 0);

Modified: xmlbeans/trunk/testbuild.xml
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/testbuild.xml?view=diff&r1=149357&r2=149358
==============================================================================
--- xmlbeans/trunk/testbuild.xml (original)
+++ xmlbeans/trunk/testbuild.xml Mon Jan 31 17:58:19 2005
@@ -848,6 +848,7 @@
             includes="${excludes}"
             classpathref="test.run.classpath"
             optimize="on"
+            debug="on"
             source="1.4"
             verbose="false"
             failonerror="true"/>



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


Mime
View raw message