cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [15/16] cayenne git commit: CAY-2335: New XML loading/saving mechanics with support of plugable handlers - new XML loader for DataMap
Date Tue, 25 Jul 2017 12:25:30 GMT
CAY-2335: New XML loading/saving mechanics with support of plugable handlers
  - new XML loader for DataMap


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

Branch: refs/heads/master
Commit: 70ca3567cf6c53536e9f7b3a9f795964058b2c29
Parents: aab05f3
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Tue Jul 25 12:59:45 2017 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Tue Jul 25 12:59:45 2017 +0300

----------------------------------------------------------------------
 .../cayenne/tools/CayenneGeneratorTask.java     |  8 +++++-
 .../org/apache/cayenne/tools/CayenneTask.java   | 11 ++++----
 .../apache/cayenne/tools/DbGeneratorTask.java   |  2 +-
 .../tools/CayenneGeneratorMapLoaderAction.java  | 26 ++++++++++++------
 .../cayenne/gen/ClassGenerationActionTest.java  |  7 +++--
 .../reverse/configuration/ToolsModule.java      | 12 +++++++-
 .../java/org/apache/cayenne/tools/CgenTask.java |  9 +++++-
 .../apache/cayenne/tools/DbGenerateTask.java    | 13 +++++----
 .../cayenne/tools/CayenneGeneratorMojo.java     | 12 +++++++-
 .../apache/cayenne/tools/DbGeneratorMojo.java   | 11 ++++----
 .../cayenne/wocompat/EOModelProcessorTest.java  | 29 ++++++++------------
 11 files changed, 90 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/70ca3567/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
b/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
index d57b350..d468cc9 100644
--- a/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
+++ b/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
@@ -20,6 +20,9 @@ package org.apache.cayenne.tools;
 
 import foundrylogic.vpp.VPPConfig;
 import org.apache.cayenne.dbsync.filter.NamePatternMatcher;
+import org.apache.cayenne.dbsync.reverse.configuration.ToolsModule;
+import org.apache.cayenne.di.DIBootstrap;
+import org.apache.cayenne.di.Injector;
 import org.apache.cayenne.gen.ArtifactsGenerationMode;
 import org.apache.cayenne.gen.ClassGenerationAction;
 import org.apache.cayenne.gen.ClientClassGenerationAction;
@@ -27,6 +30,7 @@ import org.apache.cayenne.map.DataMap;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.types.Path;
 import org.apache.velocity.VelocityContext;
+import org.slf4j.LoggerFactory;
 
 import java.io.File;
 
@@ -102,8 +106,10 @@ public class CayenneGeneratorTask extends CayenneTask {
     public void execute() throws BuildException {
         validateAttributes();
 
+        Injector injector = DIBootstrap.createInjector(new ToolsModule(LoggerFactory.getLogger(CayenneGeneratorTask.class)));
+
         AntLogger logger = new AntLogger(this);
-        CayenneGeneratorMapLoaderAction loadAction = new CayenneGeneratorMapLoaderAction();
+        CayenneGeneratorMapLoaderAction loadAction = new CayenneGeneratorMapLoaderAction(injector);
 
         loadAction.setMainDataMapFile(map);
         loadAction.setAdditionalDataMapFiles(additionalMaps);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/70ca3567/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneTask.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneTask.java b/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneTask.java
index 2bff0e3..33efff4 100644
--- a/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneTask.java
+++ b/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneTask.java
@@ -20,19 +20,20 @@
 package org.apache.cayenne.tools;
 
 import java.io.File;
+import java.net.URL;
 
 import javax.sql.DataSource;
 
+import org.apache.cayenne.configuration.DataMapLoader;
 import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.configuration.server.DbAdapterFactory;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.di.Injector;
 import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.MapLoader;
+import org.apache.cayenne.resource.URLResource;
 import org.apache.tools.ant.Task;
 import org.apache.tools.ant.types.Path;
 import org.apache.tools.ant.types.Reference;
-import org.xml.sax.InputSource;
 
 /**
  * Base task for all Cayenne ant tasks, providing support for common
@@ -142,9 +143,9 @@ public abstract class CayenneTask extends Task {
     }
 
     /** Loads and returns DataMap based on <code>map</code> attribute. */
-    protected DataMap loadDataMap() throws Exception {
-        InputSource in = new InputSource(map.getCanonicalPath());
-        return new MapLoader().loadDataMap(in);
+    protected DataMap loadDataMap(Injector injector) throws Exception {
+        DataMapLoader loader = injector.getInstance(DataMapLoader.class);
+        return loader.load(new URLResource(new URL(map.getCanonicalPath())));
     }
 
     protected DbAdapter getAdapter(Injector injector, DataSource dataSource)

http://git-wip-us.apache.org/repos/asf/cayenne/blob/70ca3567/cayenne-ant/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java b/cayenne-ant/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java
index 0e537f7..e781f6f 100644
--- a/cayenne-ant/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java
+++ b/cayenne-ant/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java
@@ -75,7 +75,7 @@ public class DbGeneratorTask extends CayenneTask {
 			Thread.currentThread().setContextClassLoader(DbGeneratorTask.class.getClassLoader());
 
 			// Load the data map and run the db generator.
-			DataMap dataMap = loadDataMap();
+			DataMap dataMap = loadDataMap(injector);
 
 			// load driver taking custom CLASSPATH into account...
 			DriverDataSource dataSource = new DriverDataSource((Driver) Class.forName(driver).newInstance(),
url,

http://git-wip-us.apache.org/repos/asf/cayenne/blob/70ca3567/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMapLoaderAction.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMapLoaderAction.java
b/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMapLoaderAction.java
index 1a0a098..0e98e77 100644
--- a/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMapLoaderAction.java
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMapLoaderAction.java
@@ -21,10 +21,11 @@ package org.apache.cayenne.tools;
 import java.io.File;
 import java.net.MalformedURLException;
 
+import org.apache.cayenne.configuration.DataMapLoader;
+import org.apache.cayenne.di.Injector;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.MapLoader;
-import org.xml.sax.InputSource;
+import org.apache.cayenne.resource.URLResource;
 
 /**
  * Loads a DataMap and a shared entity namespace.
@@ -37,11 +38,17 @@ class CayenneGeneratorMapLoaderAction {
     private File[] additionalDataMapFiles;
     private DataMap mainDataMap;
 
+    private transient Injector injector;
+
+    CayenneGeneratorMapLoaderAction(Injector injector) {
+        this.injector = injector;
+    }
+
     DataMap getMainDataMap() throws MalformedURLException {
         if (mainDataMap == null) {
-            MapLoader mapLoader = new MapLoader();
+            DataMapLoader loader = createLoader();
 
-            DataMap mainDataMap = loadDataMap(mapLoader, mainDataMapFile);
+            DataMap mainDataMap = loadDataMap(loader, mainDataMapFile);
 
             if (additionalDataMapFiles != null) {
 
@@ -51,7 +58,7 @@ class CayenneGeneratorMapLoaderAction {
 
                 for (File additionalDataMapFile : additionalDataMapFiles) {
 
-                    DataMap dataMap = loadDataMap(mapLoader, additionalDataMapFile);
+                    DataMap dataMap = loadDataMap(loader, additionalDataMapFile);
                     entityResolver.addDataMap(dataMap);
                     dataMap.setNamespace(entityResolver);
                 }
@@ -63,9 +70,12 @@ class CayenneGeneratorMapLoaderAction {
         return mainDataMap;
     }
 
-    protected DataMap loadDataMap(MapLoader mapLoader, File dataMapFile) throws MalformedURLException
{
-        InputSource in = new InputSource(dataMapFile.toURI().toURL().toString());
-        return mapLoader.loadDataMap(in);
+    DataMapLoader createLoader() {
+        return injector.getInstance(DataMapLoader.class);
+    }
+
+    protected DataMap loadDataMap(DataMapLoader mapLoader, File dataMapFile) throws MalformedURLException
{
+        return mapLoader.load(new URLResource(dataMapFile.toURI().toURL()));
     }
 
     void setMainDataMapFile(File mainDataMapFile) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/70ca3567/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClassGenerationActionTest.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClassGenerationActionTest.java
b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClassGenerationActionTest.java
index c6e1885..2f911e4 100644
--- a/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClassGenerationActionTest.java
+++ b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/ClassGenerationActionTest.java
@@ -46,8 +46,8 @@ public class ClassGenerationActionTest {
 
 	@Before
 	public void setUp() throws Exception {
-		this.writers = new ArrayList<StringWriter>(3);
-		this.action = new ClassGenerationAction() {
+		writers = new ArrayList<>(3);
+		action = new ClassGenerationAction() {
 
 			@Override
 			protected Writer openWriter(TemplateType templateType) throws Exception {
@@ -56,6 +56,7 @@ public class ClassGenerationActionTest {
 				return writer;
 			}
 		};
+
 	}
 
 	@After
@@ -247,7 +248,7 @@ public class ClassGenerationActionTest {
 
 		action.execute(artifact);
 
-		List<String> strings = new ArrayList<String>(writers.size());
+		List<String> strings = new ArrayList<>(writers.size());
 		for (StringWriter writer : writers) {
 			strings.add(writer.toString());
 		}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/70ca3567/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 0c8cb2c..dc057dc 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
@@ -24,12 +24,17 @@ import org.apache.cayenne.access.translator.batch.DefaultBatchTranslatorFactory;
 import org.apache.cayenne.access.types.DefaultValueObjectTypeRegistry;
 import org.apache.cayenne.access.types.ValueObjectTypeRegistry;
 import org.apache.cayenne.configuration.Constants;
+import org.apache.cayenne.configuration.DataMapLoader;
 import org.apache.cayenne.configuration.DefaultRuntimeProperties;
 import org.apache.cayenne.configuration.RuntimeProperties;
 import org.apache.cayenne.configuration.server.DataSourceFactory;
 import org.apache.cayenne.configuration.server.DbAdapterFactory;
 import org.apache.cayenne.configuration.server.DefaultDbAdapterFactory;
 import org.apache.cayenne.configuration.server.ServerModule;
+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.dba.db2.DB2Sniffer;
 import org.apache.cayenne.dba.derby.DerbySniffer;
 import org.apache.cayenne.dba.firebird.FirebirdSniffer;
@@ -53,6 +58,7 @@ import org.apache.cayenne.di.spi.DefaultAdhocObjectFactory;
 import org.apache.cayenne.di.spi.DefaultClassLoaderManager;
 import org.apache.cayenne.log.Slf4jJdbcEventLogger;
 import org.apache.cayenne.log.JdbcEventLogger;
+import org.apache.cayenne.project.extension.ExtensionAwareHandlerFactory;
 import org.apache.cayenne.resource.ClassLoaderResourceLocator;
 import org.apache.cayenne.resource.ResourceLocator;
 import org.slf4j.Logger;
@@ -82,11 +88,11 @@ public class ToolsModule implements Module {
 
         // configure empty global stack properties
         ServerModule.contributeProperties(binder);
-
         ServerModule.contributeDefaultTypes(binder);
         ServerModule.contributeUserTypes(binder);
         ServerModule.contributeTypeFactories(binder);
         ServerModule.contributeValueObjectTypes(binder);
+
         binder.bind(ValueObjectTypeRegistry.class).to(DefaultValueObjectTypeRegistry.class);
 
         binder.bind(ClassLoaderManager.class).to(DefaultClassLoaderManager.class);
@@ -106,6 +112,10 @@ public class ToolsModule implements Module {
 
         binder.bind(DbAdapterFactory.class).to(DefaultDbAdapterFactory.class);
         binder.bind(DataSourceFactory.class).to(DriverDataSourceFactory.class);
+
+        binder.bind(DataMapLoader.class).to(XMLDataMapLoader.class);
+        binder.bind(HandlerFactory.class).to(ExtensionAwareHandlerFactory.class);
+        binder.bind(DataChannelMetaData.class).to(DefaultDataChannelMetaData.class);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/70ca3567/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/CgenTask.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/CgenTask.java b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/CgenTask.java
index 6b4f4c4..ee39a1c 100644
--- a/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/CgenTask.java
+++ b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/CgenTask.java
@@ -25,6 +25,9 @@ import java.util.Set;
 
 import groovy.lang.Reference;
 import org.apache.cayenne.dbsync.filter.NamePatternMatcher;
+import org.apache.cayenne.dbsync.reverse.configuration.ToolsModule;
+import org.apache.cayenne.di.DIBootstrap;
+import org.apache.cayenne.di.Injector;
 import org.apache.cayenne.gen.ClassGenerationAction;
 import org.apache.cayenne.gen.ClientClassGenerationAction;
 import org.apache.cayenne.map.DataMap;
@@ -39,6 +42,7 @@ import org.gradle.api.tasks.Optional;
 import org.gradle.api.tasks.OutputDirectory;
 import org.gradle.api.tasks.SourceSetContainer;
 import org.gradle.api.tasks.TaskAction;
+import org.slf4j.LoggerFactory;
 
 /**
  * @since 4.0
@@ -109,7 +113,10 @@ public class CgenTask extends BaseCayenneTask {
     @TaskAction
     public void generate() {
         File dataMapFile = getDataMapFile();
-        CayenneGeneratorMapLoaderAction loaderAction = new CayenneGeneratorMapLoaderAction();
+
+        Injector injector = DIBootstrap.createInjector(new ToolsModule(LoggerFactory.getLogger(CgenTask.class)));
+
+        CayenneGeneratorMapLoaderAction loaderAction = new CayenneGeneratorMapLoaderAction(injector);
         loaderAction.setMainDataMapFile(dataMapFile);
 
         CayenneGeneratorEntityFilterAction filterAction = new CayenneGeneratorEntityFilterAction();

http://git-wip-us.apache.org/repos/asf/cayenne/blob/70ca3567/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/DbGenerateTask.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/DbGenerateTask.java
b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/DbGenerateTask.java
index 4e5ec39..c562654 100644
--- a/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/DbGenerateTask.java
+++ b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/DbGenerateTask.java
@@ -21,6 +21,7 @@ package org.apache.cayenne.tools;
 
 import groovy.lang.Closure;
 import org.apache.cayenne.access.DbGenerator;
+import org.apache.cayenne.configuration.DataMapLoader;
 import org.apache.cayenne.datasource.DataSourceBuilder;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.JdbcAdapter;
@@ -31,7 +32,7 @@ import org.apache.cayenne.di.DIBootstrap;
 import org.apache.cayenne.di.Injector;
 import org.apache.cayenne.log.NoopJdbcEventLogger;
 import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.MapLoader;
+import org.apache.cayenne.resource.URLResource;
 import org.apache.cayenne.tools.model.DataSourceConfig;
 import org.apache.cayenne.util.Util;
 import org.gradle.api.GradleException;
@@ -40,7 +41,6 @@ import org.gradle.api.tasks.InputFile;
 import org.gradle.api.tasks.Internal;
 import org.gradle.api.tasks.Optional;
 import org.gradle.api.tasks.TaskAction;
-import org.xml.sax.InputSource;
 
 import java.io.File;
 import javax.sql.DataSource;
@@ -94,8 +94,10 @@ public class DbGenerateTask extends BaseCayenneTask {
                         "[dropTables: {}, dropPK: {}, createTables: {}, createPK: {}, createFK:
{}]",
                 dropTables, dropPK, createTables, createPK, createFK);
 
+        Injector injector = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(getLogger()));
+
         try {
-            DbGenerator generator = createGenerator(loadDataMap());
+            DbGenerator generator = createGenerator(loadDataMap(injector));
             generator.runGenerator(createDataSource());
         } catch (Exception ex) {
             Throwable th = Util.unwindException(ex);
@@ -136,10 +138,9 @@ public class DbGenerateTask extends BaseCayenneTask {
                 .build();
     }
 
-    DataMap loadDataMap() throws Exception {
+    DataMap loadDataMap(Injector injector) throws Exception {
         File dataMapFile = getDataMapFile();
-        InputSource inputSource = new InputSource(dataMapFile.getCanonicalPath());
-        return new MapLoader().loadDataMap(inputSource);
+        return injector.getInstance(DataMapLoader.class).load(new URLResource(dataMapFile.toURI().toURL()));
     }
 
     // setters and getters that will be used by .gradle scripts

http://git-wip-us.apache.org/repos/asf/cayenne/blob/70ca3567/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
b/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
index 3736cef..6af8b0a 100644
--- a/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
+++ b/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
@@ -20,6 +20,9 @@
 package org.apache.cayenne.tools;
 
 import org.apache.cayenne.dbsync.filter.NamePatternMatcher;
+import org.apache.cayenne.dbsync.reverse.configuration.ToolsModule;
+import org.apache.cayenne.di.DIBootstrap;
+import org.apache.cayenne.di.Injector;
 import org.apache.cayenne.gen.ClassGenerationAction;
 import org.apache.cayenne.gen.ClientClassGenerationAction;
 import org.apache.cayenne.map.DataMap;
@@ -30,6 +33,7 @@ import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
+import org.slf4j.LoggerFactory;
 
 import java.io.File;
 import java.io.FilenameFilter;
@@ -181,6 +185,8 @@ public class CayenneGeneratorMojo extends AbstractMojo {
     @Parameter(defaultValue = "false")
     private boolean createPropertyNames;
 
+    private transient Injector injector;
+
 	public void execute() throws MojoExecutionException, MojoFailureException {
 		// Create the destination directory if necessary.
 		// TODO: (KJM 11/2/06) The destDir really should be added as a
@@ -189,8 +195,10 @@ public class CayenneGeneratorMojo extends AbstractMojo {
 			destDir.mkdirs();
 		}
 
+		injector = DIBootstrap.createInjector(new ToolsModule(LoggerFactory.getLogger(CayenneGeneratorMojo.class)));
+
 		Logger logger = new MavenLogger(this);
-		CayenneGeneratorMapLoaderAction loaderAction = new CayenneGeneratorMapLoaderAction();
+		CayenneGeneratorMapLoaderAction loaderAction = new CayenneGeneratorMapLoaderAction(injector);
 		loaderAction.setMainDataMapFile(map);
 
 		CayenneGeneratorEntityFilterAction filterAction = new CayenneGeneratorEntityFilterAction();
@@ -256,6 +264,8 @@ public class CayenneGeneratorMojo extends AbstractMojo {
 			action = new ClassGenerationAction();
 		}
 
+		injector.injectMembers(action);
+
 		action.setDestDir(destDir);
 		action.setEncoding(encoding);
 		action.setMakePairs(makePairs);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/70ca3567/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbGeneratorMojo.java
b/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbGeneratorMojo.java
index 131f3de..cd47dc3 100644
--- a/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbGeneratorMojo.java
+++ b/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbGeneratorMojo.java
@@ -20,6 +20,7 @@
 package org.apache.cayenne.tools;
 
 import org.apache.cayenne.access.DbGenerator;
+import org.apache.cayenne.configuration.DataMapLoader;
 import org.apache.cayenne.datasource.DriverDataSource;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.JdbcAdapter;
@@ -29,8 +30,8 @@ import org.apache.cayenne.di.DIBootstrap;
 import org.apache.cayenne.di.Injector;
 import org.apache.cayenne.log.NoopJdbcEventLogger;
 import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.MapLoader;
 import org.apache.cayenne.dbsync.reverse.configuration.ToolsModule;
+import org.apache.cayenne.resource.URLResource;
 import org.apache.cayenne.util.Util;
 import org.slf4j.Logger;
 import org.apache.maven.plugin.AbstractMojo;
@@ -39,7 +40,6 @@ import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
-import org.xml.sax.InputSource;
 
 import java.io.File;
 import java.sql.Driver;
@@ -140,7 +140,7 @@ public class DbGeneratorMojo extends AbstractMojo {
                     objectFactory.newInstance(DbAdapter.class, adapter);
 
             // Load the data map and run the db generator.
-            DataMap dataMap = loadDataMap();
+            DataMap dataMap = loadDataMap(injector);
             DbGenerator generator = new DbGenerator(adapterInst, dataMap, NoopJdbcEventLogger.getInstance());
             generator.setShouldCreateFKConstraints(createFK);
             generator.setShouldCreatePKSupport(createPK);
@@ -165,9 +165,8 @@ public class DbGeneratorMojo extends AbstractMojo {
     }
 
     /** Loads and returns DataMap based on <code>map</code> attribute. */
-    private DataMap loadDataMap() throws Exception {
-        InputSource in = new InputSource(map.getCanonicalPath());
-        return new MapLoader().loadDataMap(in);
+    private DataMap loadDataMap(Injector injector) throws Exception {
+        return injector.getInstance(DataMapLoader.class).load(new URLResource(map.toURI().toURL()));
     }
 
     @Deprecated

http://git-wip-us.apache.org/repos/asf/cayenne/blob/70ca3567/modeler/cayenne-wocompat/src/test/java/org/apache/cayenne/wocompat/EOModelProcessorTest.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-wocompat/src/test/java/org/apache/cayenne/wocompat/EOModelProcessorTest.java
b/modeler/cayenne-wocompat/src/test/java/org/apache/cayenne/wocompat/EOModelProcessorTest.java
index 4010a9b..e1faf72 100644
--- a/modeler/cayenne-wocompat/src/test/java/org/apache/cayenne/wocompat/EOModelProcessorTest.java
+++ b/modeler/cayenne-wocompat/src/test/java/org/apache/cayenne/wocompat/EOModelProcessorTest.java
@@ -19,6 +19,7 @@
 
 package org.apache.cayenne.wocompat;
 
+import org.apache.cayenne.configuration.EmptyConfigurationNodeVisitor;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
@@ -65,8 +66,7 @@ public class EOModelProcessorTest {
 
     @Test
     public void testLoadModelWithDependencies() throws Exception {
-        URL url = getClass().getClassLoader().getResource(
-                "wotests/cross-model-relationships.eomodeld/");
+        URL url = getClass().getClassLoader().getResource("wotests/cross-model-relationships.eomodeld/");
         assertNotNull(url);
 
         DataMap map = processor.loadEOModel(url);
@@ -74,7 +74,7 @@ public class EOModelProcessorTest {
         ObjEntity entity = map.getObjEntity("CrossModelRelTest");
         assertNotNull(entity);
 
-        ObjAttribute a1 = (ObjAttribute) entity.getAttribute("testAttribute");
+        ObjAttribute a1 = entity.getAttribute("testAttribute");
         assertNotNull(a1);
 
         DbAttribute da1 = a1.getDbAttribute();
@@ -115,11 +115,8 @@ public class EOModelProcessorTest {
         // - Db loaded as two-way, obj - as one-way
 
         ObjEntity exhibitEntity = map.getObjEntity("Exhibit");
-        ObjRelationship toTypeObject = (ObjRelationship) exhibitEntity
-                .getRelationship("toExhibitType");
-        DbRelationship toTypeDB = (DbRelationship) exhibitEntity
-                .getDbEntity()
-                .getRelationship("toExhibitType");
+        ObjRelationship toTypeObject = exhibitEntity.getRelationship("toExhibitType");
+        DbRelationship toTypeDB = exhibitEntity.getDbEntity().getRelationship("toExhibitType");
         assertNotNull(toTypeObject);
         assertNotNull(toTypeDB);
         assertNull(toTypeObject.getReverseRelationship());
@@ -144,11 +141,11 @@ public class EOModelProcessorTest {
         ObjEntity customTypes = map.getObjEntity("CustomTypes");
         assertNotNull(customTypes);
 
-        ObjAttribute pk = (ObjAttribute) customTypes.getAttribute("pk");
+        ObjAttribute pk = customTypes.getAttribute("pk");
         assertNotNull(pk);
         assertEquals("CustomType1", pk.getType());
 
-        ObjAttribute other = (ObjAttribute) customTypes.getAttribute("other");
+        ObjAttribute other = customTypes.getAttribute("other");
         assertNotNull(other);
         assertEquals("CustomType2", other.getType());
     }
@@ -168,7 +165,7 @@ public class EOModelProcessorTest {
         assertSame(artistDE, artistDE1);
 
         // check attributes
-        ObjAttribute a1 = (ObjAttribute) artistE.getAttribute("artistName");
+        ObjAttribute a1 = artistE.getAttribute("artistName");
         assertNotNull(a1);
 
         DbAttribute da1 = a1.getDbAttribute();
@@ -176,25 +173,23 @@ public class EOModelProcessorTest {
         assertSame(da1, artistDE.getAttribute("ARTIST_NAME"));
 
         // check ObjRelationships
-        ObjRelationship rel = (ObjRelationship) artistE
-                .getRelationship("artistExhibitArray");
+        ObjRelationship rel = artistE.getRelationship("artistExhibitArray");
         assertNotNull(rel);
         assertEquals(1, rel.getDbRelationships().size());
 
         // check DbRelationships
-        DbRelationship drel = (DbRelationship) artistDE
-                .getRelationship("artistExhibitArray");
+        DbRelationship drel = artistDE.getRelationship("artistExhibitArray");
         assertNotNull(drel);
         assertSame(drel, rel.getDbRelationships().get(0));
 
         // flattened relationships
-        ObjRelationship frel = (ObjRelationship) artistE.getRelationship("exhibitArray");
+        ObjRelationship frel = artistE.getRelationship("exhibitArray");
         assertNotNull(frel);
         assertEquals(2, frel.getDbRelationships().size());
 
         // storing data map may uncover some inconsistencies
         PrintWriter mockupWriter = new NullPrintWriter();
-        map.encodeAsXML(new XMLEncoder(mockupWriter));
+        map.encodeAsXML(new XMLEncoder(mockupWriter), new EmptyConfigurationNodeVisitor());
     }
 
     class NullPrintWriter extends PrintWriter {


Mime
View raw message