poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1879015 - in /xmlbeans: site/src/documentation/content/xdocs/ trunk/ trunk/resources/maven/ trunk/resources/typeimpl/org/apache/xmlbeans/impl/schema/ trunk/src/typeholder/org/apache/xmlbeans/impl/schema/ trunk/src/typeimpl/org/apache/xmlbe...
Date Fri, 19 Jun 2020 22:26:17 GMT
Author: kiwiwings
Date: Fri Jun 19 22:26:17 2020
New Revision: 1879015

URL: http://svn.apache.org/viewvc?rev=1879015&view=rev
Log:
(XMLBEANS-536) - change metadata path from schemaorg_apache_xmlbeans to org.apache.xmlbeans.metadata

Added:
    xmlbeans/trunk/resources/maven/
      - copied from r1856977, xmlbeans/branches/xmlbeans-536/resources/maven/
Removed:
    xmlbeans/trunk/resources/typeimpl/org/apache/xmlbeans/impl/schema/
    xmlbeans/trunk/test/src/schemas/
    xmlbeans/trunk/test/tools/src/tools/util/TestRunUtil.java
Modified:
    xmlbeans/site/src/documentation/content/xdocs/status.xml
    xmlbeans/trunk/   (props changed)
    xmlbeans/trunk/build.xml
    xmlbeans/trunk/src/typeholder/org/apache/xmlbeans/impl/schema/TypeSystemHolder.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/Diff.java
    xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java
    xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/XMLBean.java
    xmlbeans/trunk/test/src/compile/scomp/checkin/CompilationTests.java
    xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java
    xmlbeans/trunk/test/src/compile/scomp/som/common/SomTestBase.java
    xmlbeans/trunk/test/src/misc/detailed/JiraRegressionSchemaCompilerTest.java

Modified: xmlbeans/site/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/xmlbeans/site/src/documentation/content/xdocs/status.xml?rev=1879015&r1=1879014&r2=1879015&view=diff
==============================================================================
--- xmlbeans/site/src/documentation/content/xdocs/status.xml (original)
+++ xmlbeans/site/src/documentation/content/xdocs/status.xml Fri Jun 19 22:26:17 2020
@@ -49,6 +49,7 @@
     <release version="4.0.0" date="2020-06-??">
         <actions>
             <action dev="PD" type="update" context="code" fixes-bug="XMLBEANS-539">Support
for newer versions of Saxon as an XPath engine</action>
+            <action dev="PD" type="update" context="code" fixes-bug="XMLBEANS-536">Increase
Java 9+ compatibility</action>
         </actions>
     </release>
 

Propchange: xmlbeans/trunk/
------------------------------------------------------------------------------
    svn:mergeinfo = /xmlbeans/branches/xmlbeans-536:1855717-1856977

Modified: xmlbeans/trunk/build.xml
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/build.xml?rev=1879015&r1=1879014&r2=1879015&view=diff
==============================================================================
--- xmlbeans/trunk/build.xml (original)
+++ xmlbeans/trunk/build.xml Fri Jun 19 22:26:17 2020
@@ -13,7 +13,9 @@
     See the License for the specific language governing permissions and
     limitations under the License.
 -->
-<project name="XMLBeans" default="process-resources" basedir="." xmlns:unless="ant:unless">
+<project name="XMLBeans" default="process-resources" basedir="."
+     xmlns:mvn="antlib:org.apache.maven.artifact.ant"
+     xmlns:if="ant:if" xmlns:unless="ant:unless">
 
     <property name="build.compiler" value="javac1.8"/>
     <property name="ant.build.javac.source" value="1.8"/>
@@ -86,7 +88,7 @@
     <path id="xmlbeans-test">
         <pathelement location="build/classes"/>
         <pathelement location="build/generated-resources"/>
-        <dirset dir="resources" includes="*"/>
+        <dirset dir="resources" includes="*" excludes="maven"/>
         <pathelement location="${saxon.jar}"/>
         <pathelement location="test/lib/w3c_domts.jar"/>
         <pathelement location="${junit.jar}"/>
@@ -186,7 +188,7 @@
             <mkdir dir="${srcDir}"/>
             <mkdir dir="${rscDir}"/>
 
-            <uptodate property="up2date" targetfile="${rscDir}/schemaorg_apache_xmlbeans/system/@{schemaName}/TypeSystemHolder.class">
+            <uptodate property="up2date" targetfile="${rscDir}/org/apache/xmlbeans/system/@{schemaName}/TypeSystemHolder.class">
                 <srcresources>
                     <filelist dir="${basedir}" files="@{src}"/>
                 </srcresources>
@@ -196,6 +198,29 @@
                 <jvmarg value="-ea"/>
                 <arg line="-name @{schemaName} -srconly -noann -d ${rscDir} -src ${srcDir}
@{src}"/>
             </java>
+
+        </sequential>
+    </macrodef>
+
+    <macrodef name="replaceHolder">
+        <attribute name="srcDir"/>
+        <attribute name="rscDir"/>
+        <attribute name="schemaName"/>
+        <sequential>
+            <!-- if replaceHolder: copy TypeSystemHolder and replace package name, then
compile -->
+            <mkdir dir="@{srcDir}/org/apache/xmlbeans/metadata/system/@{schemaName}"/>
+            <copy file="src/typeholder/org/apache/xmlbeans/impl/schema/TypeSystemHolder.java"
todir="@{srcDir}/org/apache/xmlbeans/metadata/system/@{schemaName}">
+                <filterchain>
+                    <replacestring from="package org.apache.xmlbeans.impl.schema" to="package
org.apache.xmlbeans.metadata.system.@{schemaName}"/>
+                </filterchain>
+            </copy>
+
+            <javac destdir="@{rscDir}" debug="true" debuglevel="lines,vars,source" includeantruntime="true">
+                <src path="@{srcDir}/org/apache/xmlbeans/metadata/system/@{schemaName}"/>
+                <classpath>
+                    <pathelement location="${old.xmlbeans.jar}"/>
+                </classpath>
+            </javac>
         </sequential>
     </macrodef>
 
@@ -203,18 +228,15 @@
         <attribute name="classpathref"/>
         <attribute name="dest"/>
         <sequential>
-            <schemaComp schemaName="sXMLLANG" src="src/xmlschema/schema" dest="@{dest}"
classpathref="@{classpathref}" />
-            <schemaComp schemaName="sXMLSCHEMA" src="src/xsdschema/schema" dest="@{dest}"
classpathref="@{classpathref}" />
-            <schemaComp schemaName="sXMLCONFIG" src="src/configschema/schema" dest="@{dest}"
classpathref="@{classpathref}" />
-            <schemaComp schemaName="sXMLTOOLS" src="src/toolschema" dest="@{dest}" classpathref="@{classpathref}"
/>
+            <schemaComp schemaName="sXMLLANG" src="src/xmlschema/schema" dest="@{dest}"
classpathref="@{classpathref}"/>
+            <schemaComp schemaName="sXMLSCHEMA" src="src/xsdschema/schema" dest="@{dest}"
classpathref="@{classpathref}"/>
+            <schemaComp schemaName="sXMLCONFIG" src="src/configschema/schema" dest="@{dest}"
classpathref="@{classpathref}"/>
+            <schemaComp schemaName="sXMLTOOLS" src="src/toolschema" dest="@{dest}" classpathref="@{classpathref}"/>
         </sequential>
     </macrodef>
 
 
     <target name="process-resources" depends="-fetch-jars" description="Generate sources
and resources based on schema files">
-        <mkdir dir="build/classes"/>
-        <mkdir dir="build/generated-sources"/>
-
         <!-- Note that this is tricky because it bootstraps xmlbeans on itself. -->
         <!-- The basic strategy is to rely on the oldxbeans.jar checked into lib -->
 
@@ -224,21 +246,41 @@
 
         <schemaCompProd classpathref="oldxbean" dest="build/bootstrap"/>
 
+        <move file="build/bootstrap/generated-resources/schemaorg_apache_xmlbeans" tofile="build/bootstrap/generated-resources/org/apache/xmlbeans/metadata"/>
+
+        <replaceHolder srcDir="build/bootstrap/generated-sources" rscDir="build/bootstrap/generated-resources"
schemaName="sXMLLANG"/>
+        <replaceHolder srcDir="build/bootstrap/generated-sources" rscDir="build/bootstrap/generated-resources"
schemaName="sXMLSCHEMA"/>
+        <replaceHolder srcDir="build/bootstrap/generated-sources" rscDir="build/bootstrap/generated-resources"
schemaName="sXMLCONFIG"/>
+        <replaceHolder srcDir="build/bootstrap/generated-sources" rscDir="build/bootstrap/generated-resources"
schemaName="sXMLTOOLS"/>
+
+        <replace dir="build/bootstrap/generated-sources" token="schemaorg_apache_xmlbeans"
value="org.apache.xmlbeans.metadata" includes="**/*.java"/>
+
+        <mkdir dir="build/classes"/>
+        <mkdir dir="build/generated-sources"/>
         <javac destdir="build/classes" debug="true" debuglevel="lines,vars,source" includeantruntime="true">
             <src refid="sources"/>
             <src path="build/bootstrap/generated-sources"/>
+            <src path="src/typeholder"/>
             <classpath>
                 <path refid="oldxbean"/>
                 <pathelement location="${saxon.jar}"/>
                 <pathelement location="${javaparser.core.jar}"/>
             </classpath>
         </javac>
+        <mkdir dir="build/generated-resources/org/apache/xmlbeans/impl/schema"/>
+
+        <!-- need to provide the template also in classes - generated-resources will be
ignored on bootstrapping -->
+        <move file="build/classes/org/apache/xmlbeans/impl/schema/TypeSystemHolder.class"
+              tofile="build/classes/org/apache/xmlbeans/impl/schema/TypeSystemHolder.template"/>
+
+        <copy file="build/classes/org/apache/xmlbeans/impl/schema/TypeSystemHolder.template"
+              todir="build/generated-resources/org/apache/xmlbeans/impl/schema"/>
 
         <!-- now generate new xmlbeans re-/sources and remove the traces of the oldxbean
generated re-/sources -->
         <path id="oldschemas">
             <pathelement location="build/classes"/>
             <pathelement location="build/bootstrap/generated-resources"/>
-            <dirset dir="resources" includes="*"/>
+            <dirset dir="resources" includes="*" excludes="maven"/>
         </path>
 
         <schemaCompProd classpathref="oldschemas" dest="build"/>
@@ -425,11 +467,11 @@
 
     <target name="package" depends="compile,javadocs" description="Builds our jars in
the build directory">
         <jar jarfile="build/xmlbeans-${version.base}.jar" update="false" index="true">
-            <fileset dir="build/classes"/>
+            <fileset dir="build/classes" excludes="org/apache/xmlbeans/impl/schema/TypeSystemHolder.template"/>
             <fileset dir="." includes="LICENSE.txt,NOTICE.txt"/>
             <fileset dir="build/generated-resources"/>
             <mappedresources>
-                <fileset dir="resources"/>
+                <fileset dir="resources" excludes="maven"/>
                 <cutdirsmapper dirs="1"/>
             </mappedresources>
             <manifest>
@@ -457,16 +499,24 @@
             </manifest>
         </jar>
 
-        <jar jarfile="build/xmlbeans-${version.base}-sources.jar" update="false" index="false">
+        <chainedmapper id="src-mapper">
+            <cutdirsmapper dirs="1"/>
+            <firstmatchmapper>
+                <globmapper from="schema/*" to="org/apache/xmlbeans/src/*"/>
+                <identitymapper />
+            </firstmatchmapper>
+        </chainedmapper>
+
+        <jar jarfile="build/xmlbeans-${version.base}-sources.jar" update="false" index="false"
duplicate="preserve">
             <fileset dir="." includes="LICENSE.txt,NOTICE.txt"/>
             <mappedresources>
                 <fileset dir="src" excludes="toolschema/**,shell/**"/>
-                <cutdirsmapper dirs="1"/>
+                <mapper refid="src-mapper"/>
             </mappedresources>
-            <zipfileset dir="src/toolschema" prefix="schema"/>
+            <zipfileset dir="src/toolschema" prefix="org/apache/xmlbeans/src" excludes="**/*.xsd"/>
             <mappedresources>
-                <fileset dir="build" includes="generated-sources/**,generated-resources/**"/>
-                <cutdirsmapper dirs="1"/>
+                <fileset dir="build" includes="generated-sources/**,generated-resources/**"
excludes="**/*.xsb,**/*.class"/>
+                <mapper refid="src-mapper"/>
             </mappedresources>
 
             <manifest>
@@ -602,4 +652,30 @@
     <target name="jenkins"
             depends="test,package,rat-check"
             description="Combines all targets that are executed in CI runs"/>
-</project>
+
+
+    <available property="maven.ant.tasks.present" classname="org.apache.maven.artifact.ant.Pom"/>
+    <target name="maven.ant.tasks-check">
+        <fail unless="maven.ant.tasks.present">
+            Maven ant tasks not found.
+            Please make sure the maven-ant-tasks jar is in ANT_HOME/lib, or made
+            available to Ant using other mechanisms like -lib or CLASSPATH.
+
+            You can download the Maven Ant Tasks from https://maven.apache.org/ant-tasks/download.html
+        </fail>
+    </target>
+
+    <target name="mvn-install" depends="maven.ant.tasks-check,package" description="Install
XmlBeans artifacts into the local repository. Equivalent of 'mvn install'">
+        <copy file="${basedir}/resources/maven/pom.xml" todir="${basedir}/build" filtering="true">
+            <filterset>
+                <filter token="VERSION" value="${version.base}"/>
+            </filterset>
+        </copy>
+
+        <mvn:install file="${basedir}/build/xmlbeans-${version.base}.jar">
+            <pom file="${basedir}/build/pom.xml"/>
+            <attach file="${basedir}/build/xmlbeans-${version.base}-sources.jar" type="jar"
classifier="sources"/>
+            <attach file="${basedir}/build/xmlbeans-${version.base}-javadoc.jar" type="jar"
classifier="javadoc"/>
+        </mvn:install>
+    </target>
+</project>
\ No newline at end of file

Modified: xmlbeans/trunk/src/typeholder/org/apache/xmlbeans/impl/schema/TypeSystemHolder.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/typeholder/org/apache/xmlbeans/impl/schema/TypeSystemHolder.java?rev=1879015&r1=1879014&r2=1879015&view=diff
==============================================================================
--- xmlbeans/trunk/src/typeholder/org/apache/xmlbeans/impl/schema/TypeSystemHolder.java (original)
+++ xmlbeans/trunk/src/typeholder/org/apache/xmlbeans/impl/schema/TypeSystemHolder.java Fri
Jun 19 22:26:17 2020
@@ -16,6 +16,7 @@
 package org.apache.xmlbeans.impl.schema;
 
 import org.apache.xmlbeans.SchemaTypeSystem;
+import org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl;
 
 /**
  * This class is the hook which causes the SchemaTypeSystem to be loaded when
@@ -35,45 +36,15 @@ import org.apache.xmlbeans.SchemaTypeSys
 // !!! If you modify this class, you will have to run bootstrap.
 // !!! If this scares you, turn back now !!!
 //
-public class TypeSystemHolder
-{
-    private TypeSystemHolder() { }
+public final class TypeSystemHolder extends SchemaTypeSystemImpl {
+    // TODO: provide parameter-less parent constructor
+    private TypeSystemHolder() { super(TypeSystemHolder.class); }
 
-    public static final SchemaTypeSystem typeSystem = loadTypeSystem();
+    // the type system
+    public static final TypeSystemHolder typeSystem = new TypeSystemHolder();
 
     // 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
     //static { typeSystem.resolve(); }
-
-    private static final SchemaTypeSystem loadTypeSystem()
-    {
-        try
-        {
-            // The fact that we are using TypeSystemHolder.class.getClassLoader()
-            // to load the SchemaTypeSystem class means that the TypeSystemHolder's
-            // classloader MUST be a descendant of the XmlBeans classloader, even
-            // though it can be different.
-            // In other words, each Schema type has only one copy per VM, not one
-            // copy per copy of XmlBeans in use, therefore this implies that
-            // there either must be one copy of XmlBeans in the VM or copies in
-            // different classloaders will each need a different copy of one
-            // Schema type, which seems a reasonable restriction, but needs to be
-            // understood nevertheless
-            return (SchemaTypeSystem)
-                Class.forName(
-                    "org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl",
-                    true, TypeSystemHolder.class.getClassLoader())
-                .getConstructor(new Class[] { Class.class })
-                .newInstance(new java.lang.Object[] { TypeSystemHolder.class });
-        }
-        catch (ClassNotFoundException e)
-        {
-            throw new RuntimeException("Cannot load org.apache.xmlbeans.impl.SchemaTypeSystemImpl:
make sure xbean.jar is on the classpath.", e);
-        }
-        catch (Exception e)
-        {
-            throw new RuntimeException("Could not instantiate SchemaTypeSystemImpl (" + e.toString()
+ "): is the version of xbean.jar correct?", e);
-        }
-    }
 }

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java?rev=1879015&r1=1879014&r2=1879015&view=diff
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
Fri Jun 19 22:26:17 2020
@@ -15,18 +15,12 @@
 
 package org.apache.xmlbeans.impl.schema;
 
-import org.apache.xmlbeans.SchemaTypeLoader;
-import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.SchemaGlobalElement;
-import org.apache.xmlbeans.SchemaGlobalAttribute;
-import org.apache.xmlbeans.SchemaModelGroup;
-import org.apache.xmlbeans.SchemaAttributeGroup;
-import org.apache.xmlbeans.SchemaTypeSystem;
-import org.apache.xmlbeans.SchemaIdentityConstraint;
-import org.apache.xmlbeans.ResourceLoader;
+import org.apache.xmlbeans.*;
 import org.apache.xmlbeans.impl.common.SystemCache;
 import org.apache.xmlbeans.impl.common.QNameHelper;
 import org.apache.xmlbeans.impl.common.XBeanDebug;
+import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;
+
 import javax.xml.namespace.QName;
 
 import java.io.InputStream;
@@ -44,7 +38,7 @@ import static org.apache.xmlbeans.impl.s
 public class SchemaTypeLoaderImpl extends SchemaTypeLoaderBase {
     private ResourceLoader _resourceLoader;
     private ClassLoader _classLoader;
-    private SchemaTypeLoader[] _searchPath;
+    private final SchemaTypeLoader[] _searchPath;
 
     private Map _classpathTypeSystems;
     private Map _classLoaderTypeSystems;
@@ -62,6 +56,12 @@ public class SchemaTypeLoaderImpl extend
     public static String METADATA_PACKAGE_LOAD = METADATA_PACKAGE_GEN;
     private static final Object CACHED_NOT_FOUND = new Object();
 
+    private static final String[] basePackage = { "org.apache.xmlbeans.metadata", "schemaorg_apache_xmlbeans"
};
+    private static final String[] baseSchemas = { "sXMLCONFIG", "sXMLLANG", "sXMLSCHEMA",
"sXMLTOOLS" };
+
+
+
+
     private static class SchemaTypeLoaderCache extends SystemCache
     {
         // The following maintains a cache of SchemaTypeLoaders per ClassLoader per Thread.
@@ -168,44 +168,30 @@ public class SchemaTypeLoaderImpl extend
      * @since XmlBeans 3.1.0
      */
     public static SchemaTypeLoader build(final SchemaTypeLoader[] searchPath, ResourceLoader
resourceLoader, ClassLoader classLoader, String metadataPath) {
-        final SchemaTypeLoader[] sp;
+        // assemble a flattened search path with no duplicates
+        SubLoaderList list = new SubLoaderList();
 
-        if (searchPath == null) {
-            // if the metadata directory is customized, fallback to the xmlbeans typesystems
-            final boolean isDefaultPath = (metadataPath == null || ("schema" + METADATA_PACKAGE_GEN).equals(metadataPath));
-            if (isDefaultPath) {
-                sp = null;
-            } else {
-                String[] baseHolder = {
-                    "schemaorg_apache_xmlbeans.system.sXMLCONFIG.TypeSystemHolder",
-                    "schemaorg_apache_xmlbeans.system.sXMLLANG.TypeSystemHolder",
-                    "schemaorg_apache_xmlbeans.system.sXMLSCHEMA.TypeSystemHolder",
-                    "schemaorg_apache_xmlbeans.system.sXMLTOOLS.TypeSystemHolder"
-                };
-
-                sp = new SchemaTypeLoader[baseHolder.length];
-                for (int i=0; i<baseHolder.length; i++) {
-                    try {
-                        Class cls = Class.forName(baseHolder[i]);
-                        sp[i] = (SchemaTypeLoader)cls.getDeclaredField("typeSystem").get(null);
-                    } catch (Exception e) {
-                        System.out.println("throw runtime: "+e.toString());
-                        throw new RuntimeException(e);
-                    }
+        list.add(searchPath);
+
+        ClassLoader cl = (classLoader == null) ? SchemaDocument.class.getClassLoader() :
 classLoader;
+
+        for (String prefix : basePackage) {
+            for (String holder : baseSchemas) {
+                String clName = prefix + ".system." + holder + ".TypeSystemHolder";
+                if (cl.getResource(clName.replace(".","/")+".class") == null) {
+                    // if the first class isn't found in the package, continue with the next
package
+                    break;
+                }
+                try {
+                    Class cls = Class.forName(clName, true, cl);
+                    list.add((SchemaTypeLoader)cls.getDeclaredField("typeSystem").get(null));
+                } catch (Exception e) {
+                    throw new XmlRuntimeException(e);
                 }
             }
-        } else {
-            // assemble a flattened search path with no duplicates
-            SubLoaderList list = new SubLoaderList();
-            list.add(searchPath);
-            sp = list.toArray();
         }
 
-        if (sp != null && sp.length == 1 && resourceLoader == null &&
classLoader == null) {
-            return sp[0];
-        }
-
-        return new SchemaTypeLoaderImpl(sp, resourceLoader, classLoader, metadataPath);
+        return new SchemaTypeLoaderImpl(list.toArray(), resourceLoader, classLoader, metadataPath);
     }
 
     /**
@@ -262,17 +248,26 @@ public class SchemaTypeLoaderImpl extend
      */
     private SchemaTypeLoaderImpl(SchemaTypeLoader[] searchPath, ResourceLoader resourceLoader,
ClassLoader classLoader, String metadataPath)
     {
-        if (searchPath == null)
-            _searchPath = EMPTY_SCHEMATYPELOADER_ARRAY;
-        else
-            _searchPath = searchPath;
+        _searchPath = (searchPath == null) ? EMPTY_SCHEMATYPELOADER_ARRAY : searchPath;
         _resourceLoader = resourceLoader;
         _classLoader = classLoader;
-        this._metadataPath = (metadataPath == null) ? "schema" + METADATA_PACKAGE_LOAD :
metadataPath;
+
+        if (metadataPath != null) {
+            this._metadataPath = metadataPath;
+        } else {
+            final String path26 = "schema" + METADATA_PACKAGE_LOAD.replace("/","_");
+            this._metadataPath = (isPath30(_classLoader)) ? METADATA_PACKAGE_LOAD : path26;
+        }
 
         initCaches();
     }
 
+    private static boolean isPath30(ClassLoader loader) {
+        final String path30 = METADATA_PACKAGE_LOAD + "/system";
+        final ClassLoader cl = (loader != null) ? loader : SchemaDocument.class.getClassLoader();
+        return cl.getResource(path30) != null;
+    }
+
     /**
      * Initializes the caches.
      */

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java?rev=1879015&r1=1879014&r2=1879015&view=diff
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
Fri Jun 19 22:26:17 2020
@@ -74,6 +74,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Random;
 import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
@@ -136,11 +138,16 @@ public class SchemaTypeSystemImpl extend
     static final int FLAG_ATTRIBUTE_TYPE  = 0x80000;
 
     /**
+     * regex to identify the type system holder package namespace
+     */
+    private static final Pattern packPat = Pattern.compile("^(.+)(\\.[^.]+){2}$");
+
+    /**
      * This is to support the feature of a separate/private XMLBeans
      * distribution that will not colide with the public org apache
      * xmlbeans one.
      * METADATA_PACKAGE_GEN will be "" for the original and something like
-     * com_mycompany_private_xmlbeans for a private distribution of XMLBeans.
+     * com.mycompany.private.xmlbeans for a private distribution of XMLBeans.
      *
      * There are two properties:
      *   METADATA_PACKAGE_GEN - used for generating metadata
@@ -149,17 +156,18 @@ public class SchemaTypeSystemImpl extend
      * repackage process scomp needs to load from old package and generate into
      * a new package.
      */
-    public static String METADATA_PACKAGE_GEN;
-    static
-    {
-        // fix for maven classloader
-        Package stsPackage = SchemaTypeSystem.class.getPackage();
-        String stsPackageName = (stsPackage==null) ?
-            SchemaTypeSystem.class.getName().substring(0, SchemaTypeSystem.class.getName().lastIndexOf("."))
:
-            stsPackage.getName();
-
-        METADATA_PACKAGE_GEN = stsPackageName.replaceAll("\\.", "_");
-    }
+    public static String METADATA_PACKAGE_GEN = "org/apache/xmlbeans/metadata";
+//    public static String METADATA_PACKAGE_GEN;
+//    static
+//    {
+//        // fix for maven classloader
+//        Package stsPackage = SchemaTypeSystem.class.getPackage();
+//        String stsPackageName = (stsPackage==null) ?
+//            SchemaTypeSystem.class.getName().substring(0, SchemaTypeSystem.class.getName().lastIndexOf("."))
:
+//            stsPackage.getName();
+//
+//        METADATA_PACKAGE_GEN = stsPackageName.replace('.', '/') + "/metadata";
+//    }
 
     private static String nameToPathString(String nameForSystem)
     {
@@ -171,8 +179,32 @@ public class SchemaTypeSystemImpl extend
         return nameForSystem;
     }
 
-    public SchemaTypeSystemImpl(Class indexclass)
-    {
+    protected SchemaTypeSystemImpl() {
+        String fullname = getClass().getName();
+        _name = fullname.substring(0, fullname.lastIndexOf('.'));
+        XBeanDebug.trace(XBeanDebug.TRACE_SCHEMA_LOADING, "Loading type system " + _name,
1);
+        _basePackage = nameToPathString(_name);
+        _classloader = getClass().getClassLoader();
+        _linker = this;
+        _resourceLoader = new ClassLoaderResourceLoader(_classloader);
+        try
+        {
+            initFromHeader();
+        }
+        catch (RuntimeException e)
+        {
+            XBeanDebug.logException(e);
+            throw e;
+        }
+        catch (Error e)
+        {
+            XBeanDebug.logException(e);
+            throw e;
+        }
+        XBeanDebug.trace(XBeanDebug.TRACE_SCHEMA_LOADING, "Finished loading type system "
+ _name, -1);
+    }
+
+    public SchemaTypeSystemImpl(Class indexclass) {
         String fullname = indexclass.getName();
         _name = fullname.substring(0, fullname.lastIndexOf('.'));
         XBeanDebug.trace(XBeanDebug.TRACE_SCHEMA_LOADING, "Loading type system " + _name,
1);
@@ -235,7 +267,7 @@ public class SchemaTypeSystemImpl extend
             Class c = Class.forName(name + "." + SchemaTypeCodePrinter.INDEX_CLASSNAME, true,
loader);
             return (SchemaTypeSystemImpl)c.getField("typeSystem").get(null);
         }
-        catch (Exception e)
+        catch (Throwable e)
         {
             return null;
         }
@@ -905,8 +937,7 @@ public class SchemaTypeSystemImpl extend
         }
     }
 
-    public SchemaTypeSystemImpl(String nameForSystem)
-    {
+    public SchemaTypeSystemImpl(String nameForSystem) {
         // if we have no name, select a random one
         if (nameForSystem == null)
         {
@@ -916,10 +947,9 @@ public class SchemaTypeSystemImpl extend
             nameForSystem = "s" + new String(HexBin.encode(bytes));
         }
 
-        _name = getMetadataPath().replace('/','.') + ".system." + nameForSystem;
+        _name = SchemaTypeSystemImpl.METADATA_PACKAGE_GEN.replace('/','.') + ".system." +
nameForSystem;
         _basePackage = nameToPathString(_name);
         _classloader = null;
-        //System.out.println("             _base: " + _basePackage);
     }
 
     public void loadFromBuilder(SchemaGlobalElement[] globalElements,
@@ -976,10 +1006,10 @@ public class SchemaTypeSystemImpl extend
 
     SchemaDependencies getDependencies()
     {   return _deps; }
-    
+
     // EXPERIMENTAL
     public boolean isIncomplete() { return _incomplete; }
-    
+
     // EXPERIMENTAL
     void setIncomplete(boolean incomplete) { _incomplete = incomplete; }
 
@@ -1243,9 +1273,9 @@ public class SchemaTypeSystemImpl extend
 
     }
 
-    private String _name;
+    private final String _name;
     private String _basePackage;
-    
+
     // EXPERIMENTAL: recovery from compilation errors and partial type systems
     private boolean _incomplete = false;
 
@@ -3818,8 +3848,9 @@ public class SchemaTypeSystemImpl extend
      *
      * @since XmlBeans 3.1.0
      */
-    protected String getMetadataPath() {
-        return "schema" + METADATA_PACKAGE_GEN;
+    public String getMetadataPath() {
+        Matcher m = packPat.matcher(_name);
+        m.find();
+        return m.group(1).replace('.','/');
     }
-
 }

Modified: xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/Diff.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/Diff.java?rev=1879015&r1=1879014&r2=1879015&view=diff
==============================================================================
--- xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/Diff.java (original)
+++ xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/Diff.java Fri Jun 19 22:26:17
2020
@@ -99,14 +99,14 @@ public class Diff
         {
             ZipEntry ze = (ZipEntry) entries1.nextElement();
             String name = ze.getName();
-            if (name.startsWith("schema" + SchemaTypeSystemImpl.METADATA_PACKAGE_GEN + "/system/s")
&& name.endsWith(".xsb"))
+            if (name.startsWith(SchemaTypeSystemImpl.METADATA_PACKAGE_GEN + "/system/s")
&& name.endsWith(".xsb"))
                 list1.add(ze);
         }
         for (; entries2.hasMoreElements(); )
         {
             ZipEntry ze = (ZipEntry) entries2.nextElement();
             String name = ze.getName();
-            if (name.startsWith("schema" + SchemaTypeSystemImpl.METADATA_PACKAGE_GEN + "/system/s")
&& name.endsWith(".xsb"))
+            if (name.startsWith(SchemaTypeSystemImpl.METADATA_PACKAGE_GEN + "/system/s")
&& name.endsWith(".xsb"))
                 list2.add(ze);
         }
         ZipEntry[] files1 = (ZipEntry[]) list1.toArray(new ZipEntry[list1.size()]);
@@ -171,8 +171,8 @@ public class Diff
          * Navigate three directories deep to get to the type system.
          * Assume the schema[METADATA_PACKAGE_LOAD]/system/* structure
          */
-        File temp1 = new File(dir1, "schema" + SchemaTypeSystemImpl.METADATA_PACKAGE_GEN
+ "/system");
-        File temp2 = new File(dir2, "schema" + SchemaTypeSystemImpl.METADATA_PACKAGE_GEN
+ "/system");
+        File temp1 = new File(dir1, SchemaTypeSystemImpl.METADATA_PACKAGE_GEN + "/system");
+        File temp2 = new File(dir2, SchemaTypeSystemImpl.METADATA_PACKAGE_GEN + "/system");
         if (temp1.exists() && temp2.exists())
         {
             File[] files1 = temp1.listFiles();

Modified: xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java?rev=1879015&r1=1879014&r2=1879015&view=diff
==============================================================================
--- xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java (original)
+++ xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java Fri Jun 19
22:26:17 2020
@@ -73,6 +73,7 @@ public class SchemaCompiler
         System.out.println("    -src [dir] - target directory for generated .java files");
         System.out.println("    -srconly - do not compile .java files or jar the output.");
         System.out.println("    -out [xmltypes.jar] - the name of the output jar");
+        System.out.println("    -name - the name of the schema type - defaults to autogenerated
name");
         System.out.println("    -dl - permit network downloads for imports and includes (default
is off)");
         System.out.println("    -noupa - do not enforce the unique particle attribution rule");
         System.out.println("    -nopvr - do not enforce the particle valid (restriction)
rule");
@@ -661,12 +662,12 @@ public class SchemaCompiler
         {
             return compiler;
         }
-        
+
         public void setCompiler(String compiler)
         {
             this.compiler = compiler;
         }
-        
+
         public String getJavaSource()
         {
             return javasource;
@@ -1024,12 +1025,13 @@ public class SchemaCompiler
         {
             SchemaTypeLoaderImpl.METADATA_PACKAGE_LOAD = SchemaTypeSystemImpl.METADATA_PACKAGE_GEN;
 
-            String stsPackage = SchemaTypeSystem.class.getPackage().getName();
             Repackager repackager = new Repackager( repackage );
 
-            SchemaTypeSystemImpl.METADATA_PACKAGE_GEN = repackager.repackage(new StringBuffer(stsPackage)).toString().replace('.','_');
+            StringBuffer sb = new StringBuffer(SchemaTypeLoaderImpl.METADATA_PACKAGE_LOAD);
+            sb = repackager.repackage(sb);
+            SchemaTypeSystemImpl.METADATA_PACKAGE_GEN = sb.toString();
 
-            System.out.println("\n\n\n" + stsPackage + ".SchemaCompiler  Metadata LOAD:"
+ SchemaTypeLoaderImpl.METADATA_PACKAGE_LOAD + " GEN:" + SchemaTypeSystemImpl.METADATA_PACKAGE_GEN);
+            System.out.println("SchemaCompiler  Metadata LOAD:" + SchemaTypeLoaderImpl.METADATA_PACKAGE_LOAD
+ " GEN:" + SchemaTypeSystemImpl.METADATA_PACKAGE_GEN);
         }
 
         SchemaCodePrinter codePrinter = params.getSchemaCodePrinter();
@@ -1057,7 +1059,7 @@ public class SchemaCompiler
 
         boolean result = true;
 
-        File schemasDir = IOUtil.createDir(classesDir, "schema" + SchemaTypeSystemImpl.METADATA_PACKAGE_GEN
+ "/src");
+        File schemasDir = IOUtil.createDir(classesDir, SchemaTypeSystemImpl.METADATA_PACKAGE_GEN
+ "/src");
 
         // build the in-memory type system
         XmlErrorWatcher errorListener = new XmlErrorWatcher(outerErrorListener);

Modified: xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/XMLBean.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/XMLBean.java?rev=1879015&r1=1879014&r2=1879015&view=diff
==============================================================================
--- xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/XMLBean.java (original)
+++ xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/XMLBean.java Fri Jun 19 22:26:17
2020
@@ -84,7 +84,8 @@ public class XMLBean extends MatchingTas
                         memoryInitialSize,
                         memoryMaximumSize,
                         catalog,
-                        javasource;
+                        javasource,
+                        repackage;
 
     private List        extensions = new ArrayList();
 
@@ -238,6 +239,7 @@ public class XMLBean extends MatchingTas
             params.setNoVDoc(novdoc);
             params.setNoExt(noext);
             params.setJavaSource(javasource);
+            params.setRepackage(repackage);
             success = SchemaCompiler.compile(params);
 
             if (success && !srconly) {
@@ -305,7 +307,7 @@ public class XMLBean extends MatchingTas
             //interrupted means cancel
             if (e instanceof InterruptedException || failonerror)
                 throw new BuildException(e);
-            
+
             log("Exception while building schemas: " + e.getMessage(), Project.MSG_ERR);
             StringWriter sw = new StringWriter();
             e.printStackTrace(new PrintWriter(sw));
@@ -824,6 +826,14 @@ public class XMLBean extends MatchingTas
         this.catalog = catalog;
     }
 
+    public String getRepackage() {
+        return repackage;
+    }
+
+    public void setRepackage(String repackage) {
+        this.repackage = repackage;
+    }
+
     private static URI uriFromFile(File f)
     {
         if (f == null)

Modified: xmlbeans/trunk/test/src/compile/scomp/checkin/CompilationTests.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/compile/scomp/checkin/CompilationTests.java?rev=1879015&r1=1879014&r2=1879015&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/compile/scomp/checkin/CompilationTests.java (original)
+++ xmlbeans/trunk/test/src/compile/scomp/checkin/CompilationTests.java Fri Jun 19 22:26:17
2020
@@ -26,19 +26,21 @@ import org.apache.xmlbeans.impl.xb.xsdsc
 import org.junit.Assert;
 import org.junit.Ignore;
 import org.junit.Test;
-import tools.util.TestRunUtil;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
 
 import java.io.File;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.net.URL;
+import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
 
 
 public class CompilationTests {
@@ -195,14 +197,13 @@ public class CompilationTests {
     }
 
     @Test
-    @Ignore
     public void testSimple() throws Throwable {
         deltree(xbeanOutput("compile/scomp/simple"));
         // First, compile schema
 
         // First, compile schema
-        File inputfile1 = xbeanCase("../../simple/person.xsd");
-        File inputfile2 = xbeanCase("../../simple/simplec.xsd");
+        File inputfile1 = xbeanCase("../../simple/person/person.xsd");
+        File inputfile2 = xbeanCase("../../simple/person/simplec.xsd");
 
         File srcdir = xbeanOutput("simple/simpletypes/src");
 
@@ -217,16 +218,18 @@ public class CompilationTests {
         assertTrue("Build failed", SchemaCompiler.compile(params));
 
         // Then, compile java classes
-        File javasrc = xbeanCase("simple/javasrc");
+        File javasrc = new File("test/src/scomp/simple");
         File javaclasses = xbeanOutput("compile/scomp/simple/javaclasses");
         javaclasses.mkdirs();
-        List<File> testcp = Arrays.asList(CodeGenUtil.systemClasspath());
+        List<File> testcp = new ArrayList<File>(Arrays.asList(CodeGenUtil.systemClasspath()));
         testcp.add(outputjar);
         CodeGenUtil.externalCompile(Arrays.asList(javasrc), javaclasses, testcp.toArray(new
File[0]), true);
 
         // Then run the test
-        testcp.add(javaclasses);
-        TestRunUtil.run("SimplePersonTest", new File[]{outputjar, javaclasses});
+        URLClassLoader childcl = new URLClassLoader(new URL[]{outputjar.toURI().toURL()},
CompilationTests.class.getClassLoader());
+        Class<?> cl = childcl.loadClass("scomp.simple.SimplePersonTest");
+        Result result = JUnitCore.runClasses(cl);
+        assertEquals(0, result.getFailureCount());
     }
 
     @Test
@@ -269,7 +272,6 @@ public class CompilationTests {
     }
 
     @Test
-    @Ignore
     public void testPricequote() throws Throwable {
         deltree(xbeanOutput("compile/scomp/pricequote"));
         // First, compile schema
@@ -278,7 +280,7 @@ public class CompilationTests {
         File outputjar = xbeanOutput("compile/scomp/pricequote/pricequote.jar");
         SchemaCompiler.Parameters params = new SchemaCompiler.Parameters();
         params.setXsdFiles(new File[]{
-            xbeanCase("compile/scomp/pricequote/PriceQuote.xsd")});
+            xbeanCase("pricequote/PriceQuote.xsd")});
         params.setSrcDir(srcdir);
         params.setClassesDir(classesdir);
         params.setOutputJar(outputjar);
@@ -363,7 +365,6 @@ public class CompilationTests {
     };
 
     @Test
-    @Ignore
     public void testFinal() throws Throwable {
         SchemaDocument[] schemas = new SchemaDocument[invalidSchemas.length];
 

Modified: xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java?rev=1879015&r1=1879014&r2=1879015&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java (original)
+++ xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java Fri Jun 19
22:26:17 2020
@@ -37,16 +37,16 @@ public class XmlBeansCompCheckinTests ex
     final Vector expSrcType = new Vector();
 
     public XmlBeansCompCheckinTests() {
-        expBinType.add("schemaorg_apache_xmlbeans/system/apiCompile/atypedb57type.xsb");
-        expBinType.add("schemaorg_apache_xmlbeans/system/apiCompile/elname429edoctype.xsb");
-        expBinType.add("schemaorg_apache_xmlbeans/system/apiCompile/elnameelement.xsb");
-        expBinType.add("schemaorg_apache_xmlbeans/system/apiCompile/index.xsb");
-        expBinType.add("schemaorg_apache_xmlbeans/element/http_3A_2F_2Fbaz/elName.xsb");
-        expBinType.add("schemaorg_apache_xmlbeans/type/http_3A_2F_2Fbaz/aType.xsb");
-        expBinType.add("schemaorg_apache_xmlbeans/namespace/http_3A_2F_2Fbaz/xmlns.xsb");
-        expBinType.add("schemaorg_apache_xmlbeans/javaname/baz/ElNameDocument.xsb");
-        expBinType.add("schemaorg_apache_xmlbeans/javaname/baz/AType.xsb");
-        expBinType.add("schemaorg_apache_xmlbeans/system/apiCompile/TypeSystemHolder.class");
+        expBinType.add("org/apache/xmlbeans/metadata/system/apiCompile/atypedb57type.xsb");
+        expBinType.add("org/apache/xmlbeans/metadata/system/apiCompile/elname429edoctype.xsb");
+        expBinType.add("org/apache/xmlbeans/metadata/system/apiCompile/elnameelement.xsb");
+        expBinType.add("org/apache/xmlbeans/metadata/system/apiCompile/index.xsb");
+        expBinType.add("org/apache/xmlbeans/metadata/element/http_3A_2F_2Fbaz/elName.xsb");
+        expBinType.add("org/apache/xmlbeans/metadata/type/http_3A_2F_2Fbaz/aType.xsb");
+        expBinType.add("org/apache/xmlbeans/metadata/namespace/http_3A_2F_2Fbaz/xmlns.xsb");
+        expBinType.add("org/apache/xmlbeans/metadata/javaname/baz/ElNameDocument.xsb");
+        expBinType.add("org/apache/xmlbeans/metadata/javaname/baz/AType.xsb");
+        expBinType.add("org/apache/xmlbeans/metadata/system/apiCompile/TypeSystemHolder.class");
 
         expSrcType.add("baz.AType");
         expSrcType.add("baz.impl.ATypeImpl");

Modified: xmlbeans/trunk/test/src/compile/scomp/som/common/SomTestBase.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/compile/scomp/som/common/SomTestBase.java?rev=1879015&r1=1879014&r2=1879015&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/compile/scomp/som/common/SomTestBase.java (original)
+++ xmlbeans/trunk/test/src/compile/scomp/som/common/SomTestBase.java Fri Jun 19 22:26:17
2020
@@ -303,7 +303,7 @@ public class SomTestBase extends Compile
 
     public boolean checkPSOMSave(SchemaTypeSystem tgtSTS)
     {
-        String outDirName = tgtSTS.getName().split("schemaorg_apache_xmlbeans.system.")[1];
+        String outDirName = tgtSTS.getName().split("org.apache.xmlbeans.metadata.system.")[1];
         String outDirNameWithPath = somOutputRootDir + P + runid + P + outDirName;
 
         // call the save

Modified: xmlbeans/trunk/test/src/misc/detailed/JiraRegressionSchemaCompilerTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/misc/detailed/JiraRegressionSchemaCompilerTest.java?rev=1879015&r1=1879014&r2=1879015&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/misc/detailed/JiraRegressionSchemaCompilerTest.java (original)
+++ xmlbeans/trunk/test/src/misc/detailed/JiraRegressionSchemaCompilerTest.java Fri Jun 19
22:26:17 2020
@@ -39,6 +39,7 @@ public class JiraRegressionSchemaCompile
         params.setErrorListener(errors);
         params.setSrcDir(new File(schemaCompOutputDirPath + outputDirName + P + "src"));
         params.setClassesDir(new File(schemaCompOutputDirPath + outputDirName + P + "classes"));
+        params.setQuiet(true);
         SchemaCompiler.compile(params);
         return errors;
     }



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


Mime
View raw message