1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java Sat May 16 20:25:16 2015 +0200
1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java Sat May 16 21:42:52 2015 +0200
1.3 @@ -27,6 +27,7 @@
1.4 import info.globalcode.sql.dk.configuration.ConfigurationException;
1.5 import info.globalcode.sql.dk.configuration.DatabaseDefinition;
1.6 import info.globalcode.sql.dk.configuration.FormatterDefinition;
1.7 +import info.globalcode.sql.dk.configuration.Loader;
1.8 import info.globalcode.sql.dk.configuration.NameIdentified;
1.9 import info.globalcode.sql.dk.formatting.Formatter;
1.10 import info.globalcode.sql.dk.formatting.FormatterContext;
1.11 @@ -43,8 +44,6 @@
1.12 import java.util.logging.Level;
1.13 import java.util.logging.LogRecord;
1.14 import java.util.logging.Logger;
1.15 -import javax.xml.bind.JAXBContext;
1.16 -import javax.xml.bind.Unmarshaller;
1.17
1.18 /**
1.19 * Entry point of the command line interface of SQL-DK.
1.20 @@ -64,7 +63,8 @@
1.21 public static final int EXIT_FORMATTING_ERROR = 7; // doc:formatting error
1.22 public static final int EXIT_BATCH_ERROR = 8; // doc:batch error
1.23 private static final Logger log = Logger.getLogger(CLIStarter.class.getName());
1.24 - private CLIOptions options;
1.25 + private final CLIOptions options;
1.26 + private final Loader configurationLoader = new Loader();
1.27 private Configuration configuration;
1.28
1.29 public static void main(String[] args) {
1.30 @@ -186,7 +186,7 @@
1.31 @Override
1.32 public Configuration getConfiguration() throws ConfigurationException {
1.33 if (configuration == null) {
1.34 - configuration = loadConfiguration();
1.35 + configuration = configurationLoader.loadConfiguration();
1.36 }
1.37 return configuration;
1.38 }
1.39 @@ -206,16 +206,6 @@
1.40 }
1.41 }
1.42
1.43 - private Configuration loadConfiguration() throws ConfigurationException {
1.44 - try {
1.45 - JAXBContext jaxb = JAXBContext.newInstance(Configuration.class);
1.46 - Unmarshaller u = jaxb.createUnmarshaller();
1.47 - return (Configuration) u.unmarshal(Constants.CONFIG_FILE);
1.48 - } catch (Exception e) {
1.49 - throw new ConfigurationException("Unable to load configuration from " + Constants.CONFIG_FILE, e);
1.50 - }
1.51 - }
1.52 -
1.53 private void generateBashCompletion() {
1.54 if (configuration == null) {
1.55 log.log(Level.FINER, "Not writing Bash completion helper files. In order to generate these files please run some command which requires configuration.");