# IGNITE-45 Pass custom prefs as parameter
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/20c103ef Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/20c103ef Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/20c103ef Branch: refs/heads/ignite-497-stick Commit: 20c103ef1c3e763734a4264a447e6bc208107e4c Parents: 7a7cc17 Author: AKuznetsov <akuznet...@gridgain.com> Authored: Mon Mar 23 14:13:56 2015 +0700 Committer: AKuznetsov <akuznet...@gridgain.com> Committed: Mon Mar 23 14:13:56 2015 +0700 ---------------------------------------------------------------------- examples/schema-import/README.txt | 4 +- .../ignite/schema/ui/SchemaImportApp.java | 64 ++++++++------------ 2 files changed, 27 insertions(+), 41 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/20c103ef/examples/schema-import/README.txt ---------------------------------------------------------------------- diff --git a/examples/schema-import/README.txt b/examples/schema-import/README.txt index fb28230..dc2ed2d 100644 --- a/examples/schema-import/README.txt +++ b/examples/schema-import/README.txt @@ -17,8 +17,8 @@ Schema Import Utility Demo H2 database will start and H2 Console will be opened in your default browser. Paste content of "examples/schema-import/bin/db-init.sql" into H2 Console and execute. -2. Start Schema Import utility: "bin/ignite-schema-import.sh -customPrefs=examples/schema-import/bin/schema-import.properties" - Schema Utility will start with predifined settings for this demo. +2. Start Schema Import utility: "bin/ignite-schema-import.sh examples/schema-import/bin/schema-import.properties" + Schema Utility will start with predefined settings for this demo. Click "Next", "Generate" and answer "Yes" to override warning. 3. Import "examples/schema-import/pom.xml" in your Java IDE. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/20c103ef/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java ---------------------------------------------------------------------- diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java index a6d0ffa..5c6f82b 100644 --- a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java +++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java @@ -152,20 +152,6 @@ public class SchemaImportApp extends Application { private static final String PREF_NAMING_REPLACE = "naming.replace"; /** */ - private static final String[] PREFS = { - PREF_WINDOW_X, PREF_WINDOW_Y, PREF_WINDOW_WIDTH, PREF_WINDOW_HEIGHT, - PREF_JDBC_DB_PRESET, PREF_JDBC_DRIVER_JAR, PREF_JDBC_DRIVER_CLASS, PREF_JDBC_URL, PREF_JDBC_USER, - PREF_OUT_FOLDER, - PREF_POJO_PACKAGE, PREF_POJO_INCLUDE, PREF_POJO_CONSTRUCTOR, - PREF_XML_SINGLE, - PREF_NAMING_PATTERN, PREF_NAMING_REPLACE - }; - - /** */ - private static final String CUSTOM_PREFS = "-customPrefs="; - - - /** */ private Stage owner; /** */ @@ -1329,37 +1315,37 @@ public class SchemaImportApp extends Application { log.log(Level.SEVERE, "Failed to load preferences. Default preferences will be used", e); } - // Override params. - for (String arg : getParameters().getRaw()) { - if (arg.startsWith(CUSTOM_PREFS)) { - String customPrefsFileName = arg.substring(CUSTOM_PREFS.length()); + // Load custom preferences. + List<String> params = getParameters().getRaw(); - if (customPrefsFileName.isEmpty()) - log.log(Level.WARNING, "Path to file with custom preferences is not specified."); - else { - File customPrefsFile = U.resolveIgnitePath(customPrefsFileName); + if (!params.isEmpty()) { + String customPrefsFileName = params.get(0); - if (customPrefsFile == null) - log.log(Level.WARNING, "Failed to resolve path to file with custom preferences: " + - customPrefsFile); - else { - Properties customPrefs = new Properties(); + if (customPrefsFileName.isEmpty()) + log.log(Level.WARNING, "Path to file with custom preferences is not specified."); + else { + File customPrefsFile = U.resolveIgnitePath(customPrefsFileName); - try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(customPrefsFile))) { - customPrefs.load(in); - } - catch (IOException e) { - log.log(Level.SEVERE, "Failed to load custom preferences.", e); - } + if (customPrefsFile == null) + log.log(Level.WARNING, "Failed to resolve path to file with custom preferences: " + + customPrefsFile); + else { + Properties customPrefs = new Properties(); - String igniteHome = GridFilenameUtils.separatorsToUnix(U.getIgniteHome()); + try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(customPrefsFile))) { + customPrefs.load(in); + } + catch (IOException e) { + log.log(Level.SEVERE, "Failed to load custom preferences.", e); + } - for (Map.Entry<Object, Object> prop : customPrefs.entrySet()) { - String key = prop.getKey().toString(); - String val = prop.getValue().toString().replaceAll("%IGNITE_HOME%", igniteHome); + String igniteHome = GridFilenameUtils.separatorsToUnix(U.getIgniteHome()); - prefs.setProperty(key, val); - } + for (Map.Entry<Object, Object> prop : customPrefs.entrySet()) { + String key = prop.getKey().toString(); + String val = prop.getValue().toString().replaceAll("%IGNITE_HOME%", igniteHome); + + prefs.setProperty(key, val); } } }