Author: kiwiwings
Date: Mon Mar 18 21:45:43 2019
New Revision: 1855791
URL: http://svn.apache.org/viewvc?rev=1855791&view=rev
Log:
(XMLBEANS-536) - move generated sources/classes from schemaorg_apache_xmlbeans
to org.apache.xmlbeans
Removed:
xmlbeans/branches/xmlbeans-536/test/src/schemas/
Modified:
xmlbeans/branches/xmlbeans-536/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
xmlbeans/branches/xmlbeans-536/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
xmlbeans/branches/xmlbeans-536/src/xmlcomp/org/apache/xmlbeans/impl/tool/Diff.java
xmlbeans/branches/xmlbeans-536/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java
xmlbeans/branches/xmlbeans-536/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java
xmlbeans/branches/xmlbeans-536/test/src/compile/scomp/som/common/SomTestBase.java
xmlbeans/branches/xmlbeans-536/test/src/misc/detailed/JiraRegressionSchemaCompilerTest.java
Modified:
xmlbeans/branches/xmlbeans-536/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
URL:
http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java?rev=1855791&r1=1855790&r2=1855791&view=diff
==============================================================================
---
xmlbeans/branches/xmlbeans-536/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
(original)
+++
xmlbeans/branches/xmlbeans-536/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
Mon Mar 18 21:45:43 2019
@@ -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;
@@ -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",
"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.0.3
*/
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/branches/xmlbeans-536/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
URL:
http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java?rev=1855791&r1=1855790&r2=1855791&view=diff
==============================================================================
---
xmlbeans/branches/xmlbeans-536/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
(original)
+++
xmlbeans/branches/xmlbeans-536/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
Mon Mar 18 21:45:43 2019
@@ -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("^(.+)(\\.[^.]+){3}$");
+
+ /**
* 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
@@ -158,7 +165,7 @@ public class SchemaTypeSystemImpl extend
SchemaTypeSystem.class.getName().substring(0,
SchemaTypeSystem.class.getName().lastIndexOf(".")) :
stsPackage.getName();
- METADATA_PACKAGE_GEN = stsPackageName.replaceAll("\\.", "_");
+ METADATA_PACKAGE_GEN = stsPackageName.replace('.', '/');
}
private static String nameToPathString(String nameForSystem)
@@ -171,6 +178,31 @@ public class SchemaTypeSystemImpl extend
return nameForSystem;
}
+ 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();
@@ -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;
}
@@ -3818,8 +3850,9 @@ public class SchemaTypeSystemImpl extend
*
* @since XmlBeans 3.0.3
*/
- protected String getMetadataPath() {
- return "schema" + METADATA_PACKAGE_GEN;
+ public String getMetadataPath() {
+ Matcher m = packPat.matcher(getClass().getName());
+ m.find();
+ return m.group(1).replace('.','/');
}
-
}
Modified:
xmlbeans/branches/xmlbeans-536/src/xmlcomp/org/apache/xmlbeans/impl/tool/Diff.java
URL:
http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/xmlcomp/org/apache/xmlbeans/impl/tool/Diff.java?rev=1855791&r1=1855790&r2=1855791&view=diff
==============================================================================
---
xmlbeans/branches/xmlbeans-536/src/xmlcomp/org/apache/xmlbeans/impl/tool/Diff.java
(original)
+++
xmlbeans/branches/xmlbeans-536/src/xmlcomp/org/apache/xmlbeans/impl/tool/Diff.java
Mon Mar 18 21:45:43 2019
@@ -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/branches/xmlbeans-536/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java
URL:
http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java?rev=1855791&r1=1855790&r2=1855791&view=diff
==============================================================================
---
xmlbeans/branches/xmlbeans-536/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java
(original)
+++
xmlbeans/branches/xmlbeans-536/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java
Mon Mar 18 21:45:43 2019
@@ -1057,7 +1057,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/branches/xmlbeans-536/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java
URL:
http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java?rev=1855791&r1=1855790&r2=1855791&view=diff
==============================================================================
---
xmlbeans/branches/xmlbeans-536/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java
(original)
+++
xmlbeans/branches/xmlbeans-536/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java
Mon Mar 18 21:45:43 2019
@@ -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/system/apiCompile/atypedb57type.xsb");
+
expBinType.add("org/apache/xmlbeans/system/apiCompile/elname429edoctype.xsb");
+
expBinType.add("org/apache/xmlbeans/system/apiCompile/elnameelement.xsb");
+ expBinType.add("org/apache/xmlbeans/system/apiCompile/index.xsb");
+
expBinType.add("org/apache/xmlbeans/element/http_3A_2F_2Fbaz/elName.xsb");
+ expBinType.add("org/apache/xmlbeans/type/http_3A_2F_2Fbaz/aType.xsb");
+
expBinType.add("org/apache/xmlbeans/namespace/http_3A_2F_2Fbaz/xmlns.xsb");
+ expBinType.add("org/apache/xmlbeans/javaname/baz/ElNameDocument.xsb");
+ expBinType.add("org/apache/xmlbeans/javaname/baz/AType.xsb");
+
expBinType.add("org/apache/xmlbeans/system/apiCompile/TypeSystemHolder.class");
expSrcType.add("baz.AType");
expSrcType.add("baz.impl.ATypeImpl");
Modified:
xmlbeans/branches/xmlbeans-536/test/src/compile/scomp/som/common/SomTestBase.java
URL:
http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/test/src/compile/scomp/som/common/SomTestBase.java?rev=1855791&r1=1855790&r2=1855791&view=diff
==============================================================================
---
xmlbeans/branches/xmlbeans-536/test/src/compile/scomp/som/common/SomTestBase.java
(original)
+++
xmlbeans/branches/xmlbeans-536/test/src/compile/scomp/som/common/SomTestBase.java
Mon Mar 18 21:45:43 2019
@@ -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.system.")[1];
String outDirNameWithPath = somOutputRootDir + P + runid + P +
outDirName;
// call the save
Modified:
xmlbeans/branches/xmlbeans-536/test/src/misc/detailed/JiraRegressionSchemaCompilerTest.java
URL:
http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/test/src/misc/detailed/JiraRegressionSchemaCompilerTest.java?rev=1855791&r1=1855790&r2=1855791&view=diff
==============================================================================
---
xmlbeans/branches/xmlbeans-536/test/src/misc/detailed/JiraRegressionSchemaCompilerTest.java
(original)
+++
xmlbeans/branches/xmlbeans-536/test/src/misc/detailed/JiraRegressionSchemaCompilerTest.java
Mon Mar 18 21:45:43 2019
@@ -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: [email protected]
For additional commands, e-mail: [email protected]