You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by ce...@apache.org on 2004/11/01 05:25:58 UTC
cvs commit: xml-xmlbeans/v2/src/xmlcomp/org/apache/xmlbeans/impl/tool Diff.java SchemaCompiler.java StreamInstanceValidator.java
cezar 2004/10/31 20:25:58
Modified: v2 build.xml
v2/src/typeimpl/org/apache/xmlbeans/impl/schema
SchemaTypeLoaderImpl.java SchemaTypeSystemImpl.java
StscImporter.java
v2/src/xmlcomp/org/apache/xmlbeans/impl/tool Diff.java
SchemaCompiler.java StreamInstanceValidator.java
Log:
First cut for pakaging schema metadata.
checkintest: passes
Revision Changes Path
1.89 +1 -1 xml-xmlbeans/v2/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/build.xml,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -r1.88 -r1.89
--- build.xml 29 Oct 2004 06:50:39 -0000 1.88
+++ build.xml 1 Nov 2004 04:25:58 -0000 1.89
@@ -583,7 +583,7 @@
<delete dir="build/src/xsdschema"/>
<java classname="${bootstrap_schema_compiler}" classpathref="bootstrap.run.path" fork="true" failonerror="true">
<jvmarg value="-ea"/>
- <arg line="${repackage_arg} -name sXMLSCHEMA -cp ${xsdschema.compile.path} -srconly -d build/classes/xsdschema -noann -src build/src/xsdschema src/xsdschema/schema"/>
+ <arg line="${repackage_arg} -name sXMLSCHEMA -srconly -d build/classes/xsdschema -noann -src build/src/xsdschema src/xsdschema/schema"/>
</java>
</target>
1.6 +14 -12 xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
Index: SchemaTypeLoaderImpl.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- SchemaTypeLoaderImpl.java 13 Sep 2004 05:37:28 -0000 1.5
+++ SchemaTypeLoaderImpl.java 1 Nov 2004 04:25:58 -0000 1.6
@@ -54,6 +54,8 @@
private Map _documentCache;
private Map _classnameCache;
+ public static String LOAD_METADATA_PACKAGE = SchemaTypeSystemImpl.METADATA_PACKAGE;
+
// The following maintains a cache of SchemaTypeLoaders per ClassLoader per Thread.
// I use soft references to allow the garbage collector to reclain the type loaders
// and/pr class loaders at will.
@@ -318,7 +320,7 @@
if (_searchPath[i].isNamespaceDefined(namespace))
return true;
- SchemaTypeSystem sts = typeSystemForComponent("schema/namespace/", new QName(namespace, "xmlns"));
+ SchemaTypeSystem sts = typeSystemForComponent("schema" + LOAD_METADATA_PACKAGE + "/namespace/", new QName(namespace, "xmlns"));
return (sts != null);
}
@@ -332,7 +334,7 @@
break;
if (result == null)
{
- SchemaTypeSystem ts = typeSystemForComponent("schema/type/", name);
+ SchemaTypeSystem ts = typeSystemForComponent("schema" + LOAD_METADATA_PACKAGE + "/type/", name);
if (ts != null)
{
result = ts.findTypeRef(name);
@@ -356,7 +358,7 @@
break;
if (result == null)
{
- SchemaTypeSystem ts = typeSystemForClassname("schema/javaname/", classname);
+ SchemaTypeSystem ts = typeSystemForClassname("schema" + LOAD_METADATA_PACKAGE + "/javaname/", classname);
if (ts != null)
{
result = ts.typeForClassname(classname);
@@ -378,7 +380,7 @@
break;
if (result == null)
{
- SchemaTypeSystem ts = typeSystemForComponent("schema/element/", name);
+ SchemaTypeSystem ts = typeSystemForComponent("schema" + LOAD_METADATA_PACKAGE + "/element/", name);
if (ts != null)
{
result = ts.findDocumentTypeRef(name);
@@ -400,7 +402,7 @@
break;
if (result == null)
{
- SchemaTypeSystem ts = typeSystemForComponent("schema/attribute/", name);
+ SchemaTypeSystem ts = typeSystemForComponent("schema" + LOAD_METADATA_PACKAGE + "/attribute/", name);
if (ts != null)
{
result = ts.findAttributeTypeRef(name);
@@ -422,7 +424,7 @@
break;
if (result == null)
{
- SchemaTypeSystem ts = typeSystemForComponent("schema/element/", name);
+ SchemaTypeSystem ts = typeSystemForComponent("schema" + LOAD_METADATA_PACKAGE + "/element/", name);
if (ts != null)
{
result = ts.findElementRef(name);
@@ -444,7 +446,7 @@
break;
if (result == null)
{
- SchemaTypeSystem ts = typeSystemForComponent("schema/attribute/", name);
+ SchemaTypeSystem ts = typeSystemForComponent("schema" + LOAD_METADATA_PACKAGE + "/attribute/", name);
if (ts != null)
{
result = ts.findAttributeRef(name);
@@ -466,7 +468,7 @@
break;
if (result == null)
{
- SchemaTypeSystem ts = typeSystemForComponent("schema/modelgroup/", name);
+ SchemaTypeSystem ts = typeSystemForComponent("schema" + LOAD_METADATA_PACKAGE + "/modelgroup/", name);
if (ts != null)
{
result = ts.findModelGroupRef(name);
@@ -488,7 +490,7 @@
break;
if (result == null)
{
- SchemaTypeSystem ts = typeSystemForComponent("schema/attributegroup/", name);
+ SchemaTypeSystem ts = typeSystemForComponent("schema" + LOAD_METADATA_PACKAGE + "/attributegroup/", name);
if (ts != null)
{
result = ts.findAttributeGroupRef(name);
@@ -510,7 +512,7 @@
break;
if (result == null)
{
- SchemaTypeSystem ts = typeSystemForComponent("schema/identityconstraint/", name);
+ SchemaTypeSystem ts = typeSystemForComponent("schema" + LOAD_METADATA_PACKAGE + "/identityconstraint/", name);
if (ts != null)
{
result = ts.findIdentityConstraintRef(name);
@@ -530,10 +532,10 @@
sourceName = "/" + sourceName;
if (_resourceLoader != null)
- result = _resourceLoader.getResourceAsStream("schema/src" + sourceName);
+ result = _resourceLoader.getResourceAsStream("schema" + LOAD_METADATA_PACKAGE + "/src" + sourceName);
if (result == null && _classLoader != null)
- return _classLoader.getResourceAsStream("schema/src" + sourceName);
+ return _classLoader.getResourceAsStream("schema" + LOAD_METADATA_PACKAGE + "/src" + sourceName);
return result;
}
1.13 +28 -13 xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
Index: SchemaTypeSystemImpl.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- SchemaTypeSystemImpl.java 9 Aug 2004 20:25:39 -0000 1.12
+++ SchemaTypeSystemImpl.java 1 Nov 2004 04:25:58 -0000 1.13
@@ -131,6 +131,21 @@
static final int FLAG_ABSTRACT = 0x40000;
static final int FLAG_ATTRIBUTE_TYPE = 0x80000;
+// /**
+// * 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 will be "" for the original and something like com_mycompany_private_xmlbeans for a private distribution of XMLBeans.
+// */
+// public static String METADATA_PACKAGE = (
+// // next line should use String addition to avoid replacemant be Repackager: "org." + "apache." + "xmlbeans"
+// ("org." + "apache." + "xmlbeans").equals(SchemaTypeSystem.class.getPackage().getName()) ?
+// // This is the original org apache xmlbeans package, to maintain backwards compatibility resource pathes must remain the same
+// "" :
+// // This is the private package XMLBeans, all the metadata will end up in a specific/private resource path
+// // It is by design that
+// SchemaTypeSystem.class.getPackage().getName().replaceAll("\\.", "_")
+// );
+ // not yet enabled
+ public static String METADATA_PACKAGE = "";
private static String nameToPathString(String nameForSystem)
{
@@ -342,17 +357,17 @@
void savePointers()
{
- savePointersForComponents(globalElements(), "schema/element/");
- savePointersForComponents(globalAttributes(), "schema/attribute/");
- savePointersForComponents(modelGroups(), "schema/modelgroup/");
- savePointersForComponents(attributeGroups(), "schema/attributegroup/");
- savePointersForComponents(globalTypes(), "schema/type/");
- savePointersForComponents(identityConstraints(), "schema/identityconstraint/");
- savePointersForNamespaces(_namespaces, "schema/namespace/");
- savePointersForClassnames(_typeRefsByClassname.keySet(), "schema/javaname/");
- savePointersForComponents(redefinedModelGroups(), "schema/redefinedmodelgroup/");
- savePointersForComponents(redefinedAttributeGroups(), "schema/redefinedattributegroup/");
- savePointersForComponents(redefinedGlobalTypes(), "schema/redefinedtype/");
+ savePointersForComponents(globalElements(), "schema" + METADATA_PACKAGE + "/element/");
+ savePointersForComponents(globalAttributes(), "schema" + METADATA_PACKAGE + "/attribute/");
+ savePointersForComponents(modelGroups(), "schema" + METADATA_PACKAGE + "/modelgroup/");
+ savePointersForComponents(attributeGroups(), "schema" + METADATA_PACKAGE + "/attributegroup/");
+ savePointersForComponents(globalTypes(), "schema" + METADATA_PACKAGE + "/type/");
+ savePointersForComponents(identityConstraints(), "schema" + METADATA_PACKAGE + "/identityconstraint/");
+ savePointersForNamespaces(_namespaces, "schema" + METADATA_PACKAGE + "/namespace/");
+ savePointersForClassnames(_typeRefsByClassname.keySet(), "schema" + METADATA_PACKAGE + "/javaname/");
+ savePointersForComponents(redefinedModelGroups(), "schema" + METADATA_PACKAGE + "/redefinedmodelgroup/");
+ savePointersForComponents(redefinedAttributeGroups(), "schema" + METADATA_PACKAGE + "/redefinedattributegroup/");
+ savePointersForComponents(redefinedGlobalTypes(), "schema" + METADATA_PACKAGE + "/redefinedtype/");
}
void savePointersForComponents(SchemaComponent[] components, String dir)
@@ -751,7 +766,7 @@
nameForSystem = "s" + new String(HexBin.encode(bytes));
}
- _name = "schema.system." + nameForSystem;
+ _name = "schema" + METADATA_PACKAGE + ".system." + nameForSystem;
_basePackage = nameToPathString(_name);
_classloader = null;
@@ -3410,7 +3425,7 @@
if (!sourceName.startsWith("/"))
sourceName = "/" + sourceName;
- return _resourceLoader.getResourceAsStream("schema/src" + sourceName);
+ return _resourceLoader.getResourceAsStream("schema" + METADATA_PACKAGE + "/src" + sourceName);
}
SchemaContainer[] containers()
1.11 +1 -1 xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/StscImporter.java
Index: StscImporter.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/StscImporter.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- StscImporter.java 24 Sep 2004 06:50:07 -0000 1.10
+++ StscImporter.java 1 Nov 2004 04:25:58 -0000 1.11
@@ -842,7 +842,7 @@
InputStream in = null;
URL url = new URL(urlLoc);
- // Copy the file from filepath to schema/src/<schemaFile>
+ // Copy the file from filepath to schema[METADATA_PACKAGE]/src/<schemaFile>
in = url.openStream();
FileOutputStream out = new FileOutputStream(targetFile);
1.3 +7 -5 xml-xmlbeans/v2/src/xmlcomp/org/apache/xmlbeans/impl/tool/Diff.java
Index: Diff.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlcomp/org/apache/xmlbeans/impl/tool/Diff.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Diff.java 6 Aug 2004 02:28:31 -0000 1.2
+++ Diff.java 1 Nov 2004 04:25:58 -0000 1.3
@@ -15,6 +15,8 @@
package org.apache.xmlbeans.impl.tool;
+import org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl;
+
import java.io.*;
import java.util.List;
import java.util.Arrays;
@@ -96,14 +98,14 @@
{
ZipEntry ze = (ZipEntry) entries1.nextElement();
String name = ze.getName();
- if (name.startsWith("schema/system/s") && name.endsWith(".xsb"))
+ if (name.startsWith("schema" + SchemaTypeSystemImpl.METADATA_PACKAGE + "/system/s") && name.endsWith(".xsb"))
list1.add(ze);
}
for (; entries2.hasMoreElements(); )
{
ZipEntry ze = (ZipEntry) entries2.nextElement();
String name = ze.getName();
- if (name.startsWith("schema/system/s") && name.endsWith(".xsb"))
+ if (name.startsWith("schema" + SchemaTypeSystemImpl.METADATA_PACKAGE + "/system/s") && name.endsWith(".xsb"))
list2.add(ze);
}
ZipEntry[] files1 = (ZipEntry[]) list1.toArray(new ZipEntry[list1.size()]);
@@ -166,10 +168,10 @@
/**
* Navigate three directories deep to get to the type system.
- * Assume the schema/system/* structure
+ * Assume the schema[METADATA_PACKAGE]/system/* structure
*/
- File temp1 = new File(dir1, "schema/system");
- File temp2 = new File(dir2, "schema/system");
+ File temp1 = new File(dir1, "schema" + SchemaTypeSystemImpl.METADATA_PACKAGE + "/system");
+ File temp2 = new File(dir2, "schema" + SchemaTypeSystemImpl.METADATA_PACKAGE + "/system");
if (temp1.exists() && temp2.exists())
{
File[] files1 = temp1.listFiles();
1.17 +17 -1 xml-xmlbeans/v2/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java
Index: SchemaCompiler.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- SchemaCompiler.java 28 Oct 2004 04:08:58 -0000 1.16
+++ SchemaCompiler.java 1 Nov 2004 04:25:58 -0000 1.17
@@ -20,6 +20,7 @@
import org.apache.xmlbeans.impl.schema.ResourceLoader;
import org.apache.xmlbeans.impl.schema.StscState;
import org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl;
+import org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl;
import org.apache.xmlbeans.impl.common.XmlErrorPrinter;
import org.apache.xmlbeans.impl.common.XmlErrorWatcher;
import org.apache.xmlbeans.XmlErrorCodes;
@@ -47,6 +48,7 @@
import org.w3.x2001.xmlSchema.SchemaDocument;
import org.xml.sax.EntityResolver;
+import repackage.Repackager;
public class SchemaCompiler
{
@@ -951,7 +953,21 @@
boolean noAnn = params.isNoAnn();
boolean incrSrcGen = params.isIncrementalSrcGen();
Collection outerErrorListener = params.getErrorListener();
+
String repackage = params.getRepackage();
+
+ if (repackage!=null)
+ {
+ SchemaTypeLoaderImpl.LOAD_METADATA_PACKAGE = SchemaTypeSystemImpl.METADATA_PACKAGE;
+
+ // not yet enabled
+ //String stsPackage = SchemaTypeSystem.class.getPackage().getName();
+ //Repackager repackager = new Repackager( repackage );
+
+ //SchemaTypeSystemImpl.METADATA_PACKAGE = repackager.repackage(new StringBuffer(stsPackage)).toString().replace('.','_');
+ SchemaTypeSystemImpl.METADATA_PACKAGE = "";
+ }
+
SchemaCodePrinter codePrinter = params.getSchemaCodePrinter();
List extensions = params.getExtensions();
Set mdefNamespaces = params.getMdefNamespaces();
@@ -976,7 +992,7 @@
boolean result = true;
- File schemasDir = IOUtil.createDir(classesDir, "schema/src");
+ File schemasDir = IOUtil.createDir(classesDir, "schema" + SchemaTypeSystemImpl.METADATA_PACKAGE + "/src");
// build the in-memory type system
XmlErrorWatcher errorListener = new XmlErrorWatcher(outerErrorListener);
1.5 +6 -2 xml-xmlbeans/v2/src/xmlcomp/org/apache/xmlbeans/impl/tool/StreamInstanceValidator.java
Index: StreamInstanceValidator.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlcomp/org/apache/xmlbeans/impl/tool/StreamInstanceValidator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- StreamInstanceValidator.java 30 Sep 2004 21:35:14 -0000 1.4
+++ StreamInstanceValidator.java 1 Nov 2004 04:25:58 -0000 1.5
@@ -152,6 +152,7 @@
for (int i = 0; i < instanceFiles.length; i++) {
final File file = instanceFiles[i];
final String path = file.getPath();
+ long time = 0;
errors.clear();
@@ -165,11 +166,14 @@
rdr.next();
}
+ time = System.currentTimeMillis();
vsr.init(rdr, true, null, sLoader, options, errors);
while (vsr.hasNext()) {
vsr.next();
}
+
+ time = (System.currentTimeMillis() - time);
vsr.close();
fis.close();
}
@@ -189,9 +193,9 @@
if (errors.isEmpty()) {
- System.out.println(file + " valid.");
+ System.out.println(file + " valid. (" + time + " ms)");
} else {
- System.out.println(file + " NOT valid:");
+ System.out.println(file + " NOT valid (" + time + " ms):");
for (Iterator it = errors.iterator(); it.hasNext();) {
XmlError err = (XmlError)it.next();
System.out.println(stringFromError(err, path));
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org