Changeset 4509 for vlo/branches/vlo-3.0/vlo-commons/src/main/java/eu/clarin/cmdi/vlo/config/DefaultVloConfigFactory.java
- Timestamp:
- 02/13/14 14:42:31 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vlo/branches/vlo-3.0/vlo-commons/src/main/java/eu/clarin/cmdi/vlo/config/DefaultVloConfigFactory.java
r4507 r4509 15 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 16 */ 17 package eu.clarin.cmdi.vlo.config; 17 18 18 package eu.clarin.cmdi.vlo.config; 19 import java.io.InputStream; 20 import javax.xml.bind.JAXBException; 21 import javax.xml.transform.stream.StreamSource; 19 22 20 23 /** … … 24 27 public class DefaultVloConfigFactory implements VloConfigFactory { 25 28 29 public static final String DEFAULT_CONFIG_RESOURCE = "/VloConfig.xml"; 30 private final VloConfigMarshaller marshaller; 31 32 public DefaultVloConfigFactory() { 33 try { 34 this.marshaller = new VloConfigMarshaller(); 35 } catch (JAXBException ex) { 36 throw new RuntimeException("Could not instantiate configuration marshaller while constructing configuration factory", ex); 37 } 38 } 39 26 40 public VloConfig newConfig() { 27 return new VloConfig(); 41 InputStream configResourceStream = getClass().getResourceAsStream(DEFAULT_CONFIG_RESOURCE); 42 try { 43 return marshaller.unmarshal(new StreamSource(configResourceStream)); 44 } catch (JAXBException ex) { 45 throw new RuntimeException("Could not read default configuration due to deserialization error", ex); 46 } 28 47 } 29 30 48 }
Note: See TracChangeset
for help on using the changeset viewer.