franta-hg@16: /** franta-hg@16: * SQL-DK franta-hg@189: * Copyright © 2015 František Kučera (frantovo.cz) franta-hg@16: * franta-hg@16: * This program is free software: you can redistribute it and/or modify franta-hg@16: * it under the terms of the GNU General Public License as published by franta-hg@16: * the Free Software Foundation, either version 3 of the License, or franta-hg@16: * (at your option) any later version. franta-hg@16: * franta-hg@16: * This program is distributed in the hope that it will be useful, franta-hg@16: * but WITHOUT ANY WARRANTY; without even the implied warranty of franta-hg@16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the franta-hg@16: * GNU General Public License for more details. franta-hg@16: * franta-hg@16: * You should have received a copy of the GNU General Public License franta-hg@16: * along with this program. If not, see . franta-hg@16: */ franta-hg@189: package info.globalcode.sql.dk.configuration; franta-hg@1: franta-hg@189: import info.globalcode.sql.dk.*; franta-hg@33: import javax.xml.bind.JAXBContext; franta-hg@33: import javax.xml.bind.Unmarshaller; franta-hg@13: franta-hg@1: /** franta-hg@189: * Configuration loader – deserializes Configuration from the XML file. franta-hg@1: * franta-hg@1: * @author Ing. František Kučera (frantovo.cz) franta-hg@1: */ franta-hg@189: public class Loader { franta-hg@1: franta-hg@189: public Configuration loadConfiguration() throws ConfigurationException { franta-hg@33: try { franta-hg@33: JAXBContext jaxb = JAXBContext.newInstance(Configuration.class); franta-hg@33: Unmarshaller u = jaxb.createUnmarshaller(); franta-hg@33: return (Configuration) u.unmarshal(Constants.CONFIG_FILE); franta-hg@33: } catch (Exception e) { franta-hg@33: throw new ConfigurationException("Unable to load configuration from " + Constants.CONFIG_FILE, e); franta-hg@33: } franta-hg@20: } franta-hg@80: franta-hg@1: }