Changeset 4510 for vlo/branches/vlo-3.0/vlo-commons/src/main/java/eu/clarin/cmdi/vlo/config/XmlVloConfigFactory.java
- Timestamp:
- 02/13/14 14:57: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/XmlVloConfigFactory.java
r4507 r4510 17 17 package eu.clarin.cmdi.vlo.config; 18 18 19 import java.io.IOException; 20 import java.io.InputStream; 19 21 import java.net.URL; 22 import javax.xml.bind.JAXBException; 23 import javax.xml.transform.stream.StreamSource; 20 24 21 25 /** … … 25 29 public class XmlVloConfigFactory implements VloConfigFactory { 26 30 31 private final VloConfigMarshaller marshaller; 27 32 private final URL configLocation; 28 33 29 34 public XmlVloConfigFactory(URL configLocation) { 30 35 this.configLocation = configLocation; 36 try { 37 this.marshaller = new VloConfigMarshaller(); 38 } catch (JAXBException ex) { 39 throw new RuntimeException("Could not instantiate configuration marshaller while constructing configuration factory", ex); 40 } 31 41 } 32 42 33 43 public VloConfig newConfig() { 34 //TODO: Unmarshal from file 35 throw new UnsupportedOperationException("Not supported yet."); 44 try { 45 final InputStream fileStream = configLocation.openStream(); 46 try { 47 return marshaller.unmarshal(new StreamSource(fileStream)); 48 } catch (JAXBException ex) { 49 throw new RuntimeException("Could not deserialize configuration file", ex); 50 } finally { 51 fileStream.close(); 52 } 53 } catch (IOException ex) { 54 throw new RuntimeException("Could not read configuration file", ex); 55 } 36 56 } 37 38 57 }
Note: See TracChangeset
for help on using the changeset viewer.