cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [1/5] cayenne git commit: CAY-2340 Save additional metadata as separate files optional support for XInclude in XML reader
Date Thu, 03 Aug 2017 07:59:52 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 78b0a653b -> caaeb99bf


CAY-2340 Save additional metadata as separate files
   optional support for XInclude in XML reader


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/f16810a2
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/f16810a2
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/f16810a2

Branch: refs/heads/master
Commit: f16810a20a3afbb7b4b3230f6c81890d62efe0c2
Parents: c1ec144
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Wed Aug 2 16:09:10 2017 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Wed Aug 2 16:23:56 2017 +0300

----------------------------------------------------------------------
 .../reverse/configuration/ToolsModule.java      |  3 ++
 .../dbimport/ManyToManyCandidateEntityTest.java |  3 ++
 ...patibilityDataChannelDescriptorLoaderIT.java |  3 ++
 .../project/DataChannelProjectLoaderTest.java   |  3 ++
 .../project/DataChannelProjectSaverTest.java    |  4 ++
 .../configuration/server/ServerModule.java      |  3 ++
 .../xml/XMLDataChannelDescriptorLoader.java     |  7 ++-
 .../configuration/xml/XMLDataMapLoader.java     |  7 ++-
 .../configuration/xml/XMLReaderProvider.java    | 53 ++++++++++++++++++++
 .../xml/XMLDataChannelDescriptorLoaderTest.java |  3 +-
 .../configuration/xml/XMLDataMapLoaderTest.java |  2 +
 .../cayenne/unit/di/server/SchemaBuilder.java   |  7 +--
 .../unit/di/server/ServerCaseModule.java        |  4 ++
 .../modeler/init/CayenneModelerModule.java      |  3 ++
 14 files changed, 97 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/f16810a2/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/configuration/ToolsModule.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/configuration/ToolsModule.java
b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/configuration/ToolsModule.java
index bd6ae66..8e3673d 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/configuration/ToolsModule.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/configuration/ToolsModule.java
@@ -35,6 +35,7 @@ import org.apache.cayenne.configuration.xml.DataChannelMetaData;
 import org.apache.cayenne.configuration.xml.DefaultDataChannelMetaData;
 import org.apache.cayenne.configuration.xml.HandlerFactory;
 import org.apache.cayenne.configuration.xml.XMLDataMapLoader;
+import org.apache.cayenne.configuration.xml.XMLReaderProvider;
 import org.apache.cayenne.dba.db2.DB2Sniffer;
 import org.apache.cayenne.dba.derby.DerbySniffer;
 import org.apache.cayenne.dba.firebird.FirebirdSniffer;
@@ -63,6 +64,7 @@ import org.apache.cayenne.project.extension.ExtensionAwareHandlerFactory;
 import org.apache.cayenne.resource.ClassLoaderResourceLocator;
 import org.apache.cayenne.resource.ResourceLocator;
 import org.slf4j.Logger;
+import org.xml.sax.XMLReader;
 
 /**
  * A DI module to bootstrap DI container for Cayenne Ant tasks and Maven
@@ -117,6 +119,7 @@ public class ToolsModule implements Module {
         binder.bind(DataMapLoader.class).to(XMLDataMapLoader.class);
         binder.bind(HandlerFactory.class).to(ExtensionAwareHandlerFactory.class);
         binder.bind(DataChannelMetaData.class).to(DefaultDataChannelMetaData.class);
+        binder.bind(XMLReader.class).toProviderInstance(new XMLReaderProvider(true)).withoutScope();
 
         ProjectModule.contributeExtensions(binder);
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/f16810a2/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbimport/ManyToManyCandidateEntityTest.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbimport/ManyToManyCandidateEntityTest.java
b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbimport/ManyToManyCandidateEntityTest.java
index 3d064e5..574ebed 100644
--- a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbimport/ManyToManyCandidateEntityTest.java
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbimport/ManyToManyCandidateEntityTest.java
@@ -30,6 +30,7 @@ import org.apache.cayenne.configuration.xml.HandlerFactory;
 import org.apache.cayenne.configuration.xml.NoopDataChannelMetaData;
 import org.apache.cayenne.configuration.xml.XMLDataChannelDescriptorLoader;
 import org.apache.cayenne.configuration.xml.XMLDataMapLoader;
+import org.apache.cayenne.configuration.xml.XMLReaderProvider;
 import org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator;
 import org.apache.cayenne.dbsync.naming.NoStemStemmer;
 import org.apache.cayenne.di.AdhocObjectFactory;
@@ -46,6 +47,7 @@ import org.apache.cayenne.map.Relationship;
 import org.apache.cayenne.resource.URLResource;
 import org.junit.Before;
 import org.junit.Test;
+import org.xml.sax.XMLReader;
 
 import java.net.URL;
 import java.util.ArrayList;
@@ -69,6 +71,7 @@ public class ManyToManyCandidateEntityTest {
                 binder.bind(ConfigurationNameMapper.class).to(DefaultConfigurationNameMapper.class);
                 binder.bind(HandlerFactory.class).to(DefaultHandlerFactory.class);
                 binder.bind(DataChannelMetaData.class).to(NoopDataChannelMetaData.class);
+                binder.bind(XMLReader.class).toProviderInstance(new XMLReaderProvider(false)).withoutScope();
             }
         };
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/f16810a2/cayenne-project-compatibility/src/test/java/org/apache/cayenne/configuration/xml/CompatibilityDataChannelDescriptorLoaderIT.java
----------------------------------------------------------------------
diff --git a/cayenne-project-compatibility/src/test/java/org/apache/cayenne/configuration/xml/CompatibilityDataChannelDescriptorLoaderIT.java
b/cayenne-project-compatibility/src/test/java/org/apache/cayenne/configuration/xml/CompatibilityDataChannelDescriptorLoaderIT.java
index acc31d7c..79c1d54 100644
--- a/cayenne-project-compatibility/src/test/java/org/apache/cayenne/configuration/xml/CompatibilityDataChannelDescriptorLoaderIT.java
+++ b/cayenne-project-compatibility/src/test/java/org/apache/cayenne/configuration/xml/CompatibilityDataChannelDescriptorLoaderIT.java
@@ -49,6 +49,7 @@ import org.apache.cayenne.project.upgrade.handlers.UpgradeHandler_V9;
 import org.apache.cayenne.resource.Resource;
 import org.apache.cayenne.resource.URLResource;
 import org.junit.Test;
+import org.xml.sax.XMLReader;
 
 import static org.junit.Assert.*;
 import static org.mockito.Mockito.mock;
@@ -80,6 +81,8 @@ public class CompatibilityDataChannelDescriptorLoaderIT {
                         .add(UpgradeHandler_V10.class);
 
                 binder.bind(ProjectSaver.class).toInstance(mock(ProjectSaver.class));
+
+                binder.bind(XMLReader.class).toProviderInstance(new XMLReaderProvider(false)).withoutScope();
             }
         });
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/f16810a2/cayenne-project/src/test/java/org/apache/cayenne/project/DataChannelProjectLoaderTest.java
----------------------------------------------------------------------
diff --git a/cayenne-project/src/test/java/org/apache/cayenne/project/DataChannelProjectLoaderTest.java
b/cayenne-project/src/test/java/org/apache/cayenne/project/DataChannelProjectLoaderTest.java
index 9e136f8..1274732 100644
--- a/cayenne-project/src/test/java/org/apache/cayenne/project/DataChannelProjectLoaderTest.java
+++ b/cayenne-project/src/test/java/org/apache/cayenne/project/DataChannelProjectLoaderTest.java
@@ -29,6 +29,7 @@ import org.apache.cayenne.configuration.xml.HandlerFactory;
 import org.apache.cayenne.configuration.xml.NoopDataChannelMetaData;
 import org.apache.cayenne.configuration.xml.XMLDataChannelDescriptorLoader;
 import org.apache.cayenne.configuration.xml.XMLDataMapLoader;
+import org.apache.cayenne.configuration.xml.XMLReaderProvider;
 import org.apache.cayenne.di.AdhocObjectFactory;
 import org.apache.cayenne.di.Binder;
 import org.apache.cayenne.di.ClassLoaderManager;
@@ -40,6 +41,7 @@ import org.apache.cayenne.di.spi.DefaultClassLoaderManager;
 import org.apache.cayenne.resource.Resource;
 import org.apache.cayenne.resource.URLResource;
 import org.junit.Test;
+import org.xml.sax.XMLReader;
 
 import java.net.URL;
 
@@ -66,6 +68,7 @@ public class DataChannelProjectLoaderTest {
                 binder.bind(ConfigurationNameMapper.class).to(DefaultConfigurationNameMapper.class);
                 binder.bind(HandlerFactory.class).to(DefaultHandlerFactory.class);
                 binder.bind(DataChannelMetaData.class).to(NoopDataChannelMetaData.class);
+                binder.bind(XMLReader.class).toProviderInstance(new XMLReaderProvider(false)).withoutScope();
             }
         };
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/f16810a2/cayenne-project/src/test/java/org/apache/cayenne/project/DataChannelProjectSaverTest.java
----------------------------------------------------------------------
diff --git a/cayenne-project/src/test/java/org/apache/cayenne/project/DataChannelProjectSaverTest.java
b/cayenne-project/src/test/java/org/apache/cayenne/project/DataChannelProjectSaverTest.java
index 5e55221..0908d0d 100644
--- a/cayenne-project/src/test/java/org/apache/cayenne/project/DataChannelProjectSaverTest.java
+++ b/cayenne-project/src/test/java/org/apache/cayenne/project/DataChannelProjectSaverTest.java
@@ -29,6 +29,7 @@ import org.apache.cayenne.configuration.xml.HandlerFactory;
 import org.apache.cayenne.configuration.xml.NoopDataChannelMetaData;
 import org.apache.cayenne.configuration.xml.XMLDataChannelDescriptorLoader;
 import org.apache.cayenne.configuration.xml.XMLDataMapLoader;
+import org.apache.cayenne.configuration.xml.XMLReaderProvider;
 import org.apache.cayenne.di.AdhocObjectFactory;
 import org.apache.cayenne.di.Binder;
 import org.apache.cayenne.di.ClassLoaderManager;
@@ -42,6 +43,7 @@ import org.apache.cayenne.project.unit.Project2Case;
 import org.apache.cayenne.resource.Resource;
 import org.apache.cayenne.resource.URLResource;
 import org.junit.Test;
+import org.xml.sax.XMLReader;
 
 import java.io.File;
 import java.io.PrintWriter;
@@ -72,6 +74,7 @@ public class DataChannelProjectSaverTest extends Project2Case {
                 binder.bind(ConfigurationNameMapper.class).to(DefaultConfigurationNameMapper.class);
                 binder.bind(HandlerFactory.class).to(DefaultHandlerFactory.class);
                 binder.bind(DataChannelMetaData.class).to(NoopDataChannelMetaData.class);
+                binder.bind(XMLReader.class).toProviderInstance(new XMLReaderProvider(false)).withoutScope();
             }
         };
 
@@ -126,6 +129,7 @@ public class DataChannelProjectSaverTest extends Project2Case {
                 binder.bind(ConfigurationNameMapper.class).to(DefaultConfigurationNameMapper.class);
                 binder.bind(HandlerFactory.class).to(DefaultHandlerFactory.class);
                 binder.bind(DataChannelMetaData.class).to(NoopDataChannelMetaData.class);
+                binder.bind(XMLReader.class).toProviderInstance(new XMLReaderProvider(false)).withoutScope();
             }
         };
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/f16810a2/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java
b/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java
index c86371d..8bf1d6a 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java
@@ -77,6 +77,7 @@ import org.apache.cayenne.configuration.xml.HandlerFactory;
 import org.apache.cayenne.configuration.xml.NoopDataChannelMetaData;
 import org.apache.cayenne.configuration.xml.XMLDataChannelDescriptorLoader;
 import org.apache.cayenne.configuration.xml.XMLDataMapLoader;
+import org.apache.cayenne.configuration.xml.XMLReaderProvider;
 import org.apache.cayenne.dba.db2.DB2Sniffer;
 import org.apache.cayenne.dba.derby.DerbySniffer;
 import org.apache.cayenne.dba.firebird.FirebirdSniffer;
@@ -116,6 +117,7 @@ import org.apache.cayenne.tx.TransactionFactory;
 import org.apache.cayenne.tx.TransactionFilter;
 import org.apache.cayenne.tx.TransactionManager;
 import org.apache.cayenne.velocity.VelocitySQLTemplateProcessor;
+import org.xml.sax.XMLReader;
 
 import java.util.Calendar;
 import java.util.GregorianCalendar;
@@ -410,5 +412,6 @@ public class ServerModule implements Module {
 
         binder.bind(HandlerFactory.class).to(DefaultHandlerFactory.class);
         binder.bind(DataChannelMetaData.class).to(NoopDataChannelMetaData.class);
+        binder.bind(XMLReader.class).toProviderInstance(new XMLReaderProvider(false)).withoutScope();
     }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/f16810a2/cayenne-server/src/main/java/org/apache/cayenne/configuration/xml/XMLDataChannelDescriptorLoader.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/configuration/xml/XMLDataChannelDescriptorLoader.java
b/cayenne-server/src/main/java/org/apache/cayenne/configuration/xml/XMLDataChannelDescriptorLoader.java
index 0682bb2..2558b65 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/configuration/xml/XMLDataChannelDescriptorLoader.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/configuration/xml/XMLDataChannelDescriptorLoader.java
@@ -26,6 +26,7 @@ import org.apache.cayenne.configuration.DataChannelDescriptorLoader;
 import org.apache.cayenne.configuration.DataMapLoader;
 import org.apache.cayenne.di.AdhocObjectFactory;
 import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.di.Provider;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.resource.Resource;
 import org.apache.cayenne.util.Util;
@@ -98,6 +99,9 @@ public class XMLDataChannelDescriptorLoader implements DataChannelDescriptorLoad
 	}
 
 	@Inject
+	protected Provider<XMLReader> xmlReaderProvider;
+
+	@Inject
 	protected DataMapLoader dataMapLoader;
 
 	@Inject
@@ -125,8 +129,7 @@ public class XMLDataChannelDescriptorLoader implements DataChannelDescriptorLoad
 		descriptor.setName(nameMapper.configurationNodeName(DataChannelDescriptor.class, configurationResource));
 
 		try(InputStream in = configurationURL.openStream()) {
-			XMLReader parser = Util.createXmlReader();
-			parser.setFeature("http://apache.org/xml/features/xinclude", true);
+			XMLReader parser = xmlReaderProvider.get();
 			LoaderContext loaderContext = new LoaderContext(parser, handlerFactory);
 			loaderContext.addDataMapListener(new DataMapLoaderListener() {
 				@Override

http://git-wip-us.apache.org/repos/asf/cayenne/blob/f16810a2/cayenne-server/src/main/java/org/apache/cayenne/configuration/xml/XMLDataMapLoader.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/configuration/xml/XMLDataMapLoader.java
b/cayenne-server/src/main/java/org/apache/cayenne/configuration/xml/XMLDataMapLoader.java
index 37fe689..0e50471 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/configuration/xml/XMLDataMapLoader.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/configuration/xml/XMLDataMapLoader.java
@@ -21,6 +21,7 @@ package org.apache.cayenne.configuration.xml;
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.configuration.DataMapLoader;
 import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.di.Provider;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.resource.Resource;
 import org.apache.cayenne.util.Util;
@@ -40,12 +41,14 @@ public class XMLDataMapLoader implements DataMapLoader {
     @Inject
     protected HandlerFactory handlerFactory;
 
+    @Inject
+    protected Provider<XMLReader> xmlReaderProvider;
+
     DataMap map;
 
     public synchronized DataMap load(Resource configurationResource) throws CayenneRuntimeException
{
         try(InputStream in = configurationResource.getURL().openStream()) {
-            XMLReader parser = Util.createXmlReader();
-            parser.setFeature("http://apache.org/xml/features/xinclude", true);
+            XMLReader parser = xmlReaderProvider.get();
             LoaderContext loaderContext = new LoaderContext(parser, handlerFactory);
             loaderContext.addDataMapListener(new DataMapLoaderListener() {
                 @Override

http://git-wip-us.apache.org/repos/asf/cayenne/blob/f16810a2/cayenne-server/src/main/java/org/apache/cayenne/configuration/xml/XMLReaderProvider.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/configuration/xml/XMLReaderProvider.java
b/cayenne-server/src/main/java/org/apache/cayenne/configuration/xml/XMLReaderProvider.java
new file mode 100644
index 0000000..267bb87
--- /dev/null
+++ b/cayenne-server/src/main/java/org/apache/cayenne/configuration/xml/XMLReaderProvider.java
@@ -0,0 +1,53 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.configuration.xml;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.cayenne.di.DIRuntimeException;
+import org.apache.cayenne.di.Provider;
+import org.apache.cayenne.util.Util;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+/**
+ * @since 4.1
+ */
+public class XMLReaderProvider implements Provider<XMLReader> {
+
+    private final boolean supportInclude;
+
+    public XMLReaderProvider(boolean supportInclude) {
+        this.supportInclude = supportInclude;
+    }
+
+    @Override
+    public XMLReader get() throws DIRuntimeException {
+        try {
+            XMLReader reader = Util.createXmlReader();
+            if(supportInclude) {
+                reader.setFeature("http://apache.org/xml/features/xinclude", true);
+            }
+            return reader;
+        } catch (SAXException | ParserConfigurationException ex) {
+            throw new DIRuntimeException("Unable to create XMLReader", ex);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/f16810a2/cayenne-server/src/test/java/org/apache/cayenne/configuration/xml/XMLDataChannelDescriptorLoaderTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/configuration/xml/XMLDataChannelDescriptorLoaderTest.java
b/cayenne-server/src/test/java/org/apache/cayenne/configuration/xml/XMLDataChannelDescriptorLoaderTest.java
index fab4129..020c015 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/configuration/xml/XMLDataChannelDescriptorLoaderTest.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/configuration/xml/XMLDataChannelDescriptorLoaderTest.java
@@ -37,6 +37,7 @@ import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.resource.URLResource;
 import org.junit.Before;
 import org.junit.Test;
+import org.xml.sax.XMLReader;
 
 import java.net.URL;
 import java.util.Collection;
@@ -59,7 +60,7 @@ public class XMLDataChannelDescriptorLoaderTest {
                 binder.bind(ConfigurationNameMapper.class).to(DefaultConfigurationNameMapper.class);
                 binder.bind(HandlerFactory.class).to(DefaultHandlerFactory.class);
                 binder.bind(DataChannelMetaData.class).to(NoopDataChannelMetaData.class);
-
+                binder.bind(XMLReader.class).toProviderInstance(new XMLReaderProvider(false)).withoutScope();
             }
         };
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/f16810a2/cayenne-server/src/test/java/org/apache/cayenne/configuration/xml/XMLDataMapLoaderTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/configuration/xml/XMLDataMapLoaderTest.java
b/cayenne-server/src/test/java/org/apache/cayenne/configuration/xml/XMLDataMapLoaderTest.java
index e416774..a0cffd5 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/configuration/xml/XMLDataMapLoaderTest.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/configuration/xml/XMLDataMapLoaderTest.java
@@ -38,6 +38,7 @@ import org.apache.cayenne.map.SQLTemplateDescriptor;
 import org.apache.cayenne.resource.URLResource;
 import org.junit.Before;
 import org.junit.Test;
+import org.xml.sax.XMLReader;
 
 import static org.junit.Assert.*;
 
@@ -58,6 +59,7 @@ public class XMLDataMapLoaderTest {
                 binder.bind(ConfigurationNameMapper.class).to(DefaultConfigurationNameMapper.class);
                 binder.bind(HandlerFactory.class).to(DefaultHandlerFactory.class);
                 binder.bind(DataChannelMetaData.class).to(NoopDataChannelMetaData.class);
+                binder.bind(XMLReader.class).toProviderInstance(new XMLReaderProvider(false)).withoutScope();
             }
         };
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/f16810a2/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java
b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java
index a8d6ad0..5101bd5 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/SchemaBuilder.java
@@ -28,6 +28,7 @@ import org.apache.cayenne.access.translator.batch.DefaultBatchTranslatorFactory;
 import org.apache.cayenne.access.translator.select.DefaultSelectTranslatorFactory;
 import org.apache.cayenne.ashwood.AshwoodEntitySorter;
 import org.apache.cayenne.cache.MapQueryCache;
+import org.apache.cayenne.configuration.DataMapLoader;
 import org.apache.cayenne.configuration.xml.DefaultHandlerFactory;
 import org.apache.cayenne.configuration.xml.XMLDataMapLoader;
 import org.apache.cayenne.dba.DbAdapter;
@@ -93,6 +94,9 @@ public class SchemaBuilder {
 	private DataDomain domain;
 	private JdbcEventLogger jdbcEventLogger;
 
+	@Inject
+	DataMapLoader loader;
+
 	public SchemaBuilder(@Inject ServerCaseDataSourceFactory dataSourceFactory, @Inject UnitDbAdapter
unitDbAdapter,
 			@Inject DbAdapter dbAdapter, @Inject JdbcEventLogger jdbcEventLogger) {
 		this.dataSourceFactory = dataSourceFactory;
@@ -115,10 +119,7 @@ public class SchemaBuilder {
 
 		for (int i = 0; i < maps.length; i++) {
 			URL mapURL = getClass().getClassLoader().getResource(MAPS_REQUIRING_SCHEMA_SETUP[i]);
-			XMLDataMapLoader loader = new XMLDataMapLoader();
-			loader.setHandlerFactory(new DefaultHandlerFactory());
 			maps[i] = loader.load(new URLResource(mapURL));
-
 		}
 
 		this.domain = new DataDomain("temp");

http://git-wip-us.apache.org/repos/asf/cayenne/blob/f16810a2/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java
b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java
index 3386c1b..3fa74dc 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java
@@ -60,6 +60,7 @@ import org.apache.cayenne.configuration.xml.DefaultHandlerFactory;
 import org.apache.cayenne.configuration.xml.HandlerFactory;
 import org.apache.cayenne.configuration.xml.NoopDataChannelMetaData;
 import org.apache.cayenne.configuration.xml.XMLDataMapLoader;
+import org.apache.cayenne.configuration.xml.XMLReaderProvider;
 import org.apache.cayenne.conn.DataSourceInfo;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.JdbcAdapter;
@@ -110,6 +111,7 @@ import org.apache.cayenne.unit.UnitDbAdapter;
 import org.apache.cayenne.unit.di.DataChannelInterceptor;
 import org.apache.cayenne.unit.di.UnitTestLifecycleManager;
 import org.apache.cayenne.unit.util.SQLTemplateCustomizer;
+import org.xml.sax.XMLReader;
 
 import java.util.Calendar;
 import java.util.GregorianCalendar;
@@ -205,6 +207,8 @@ public class ServerCaseModule implements Module {
         binder.bind(HandlerFactory.class).to(DefaultHandlerFactory.class);
         binder.bind(DataChannelMetaData.class).to(NoopDataChannelMetaData.class);
 
+        binder.bind(XMLReader.class).toProviderInstance(new XMLReaderProvider(false)).withoutScope();
+
         // test-scoped objects
         binder.bind(EntityResolver.class).toProvider(ServerCaseEntityResolverProvider.class).in(testScope);
         binder.bind(DataNode.class).toProvider(ServerCaseDataNodeProvider.class).in(testScope);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/f16810a2/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/init/CayenneModelerModule.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/init/CayenneModelerModule.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/init/CayenneModelerModule.java
index 1062bf3..30ea25d 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/init/CayenneModelerModule.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/init/CayenneModelerModule.java
@@ -21,6 +21,7 @@ package org.apache.cayenne.modeler.init;
 import org.apache.cayenne.configuration.xml.DataChannelMetaData;
 import org.apache.cayenne.configuration.xml.DefaultDataChannelMetaData;
 import org.apache.cayenne.configuration.xml.HandlerFactory;
+import org.apache.cayenne.configuration.xml.XMLReaderProvider;
 import org.apache.cayenne.di.Binder;
 import org.apache.cayenne.di.Module;
 import org.apache.cayenne.modeler.Application;
@@ -34,6 +35,7 @@ import org.apache.cayenne.modeler.util.WidgetFactory;
 import org.apache.cayenne.project.ProjectModule;
 import org.apache.cayenne.project.extension.ExtensionAwareHandlerFactory;
 import org.apache.cayenne.project.extension.info.InfoExtension;
+import org.xml.sax.XMLReader;
 
 /**
  * A DI module for bootstrapping CayenneModeler services.
@@ -48,6 +50,7 @@ public class CayenneModelerModule implements Module {
         binder.bind(WidgetFactory.class).to(DefaultWidgetFactory.class);
         binder.bind(HandlerFactory.class).to(ExtensionAwareHandlerFactory.class);
         binder.bind(DataChannelMetaData.class).to(DefaultDataChannelMetaData.class);
+        binder.bind(XMLReader.class).toProviderInstance(new XMLReaderProvider(true)).withoutScope();
 
         ProjectModule.contributeExtensions(binder)
                 .add(InfoExtension.class)


Mime
View raw message