use of javax.xml.bind.Unmarshaller in project asterixdb by apache.
the class PropertiesAccessor method configure.
private AsterixConfiguration configure(InputStream is, String fileName) throws AsterixException {
try {
JAXBContext ctx = JAXBContext.newInstance(AsterixConfiguration.class);
Unmarshaller unmarshaller = ctx.createUnmarshaller();
return (AsterixConfiguration) unmarshaller.unmarshal(is);
} catch (JAXBException e) {
throw new AsterixException("Failed to read configuration file " + fileName, e);
}
}
use of javax.xml.bind.Unmarshaller in project asterixdb by apache.
the class ExternalLibraryUtils method getLibrary.
/**
* Get the library from the xml file
*
* @param libraryXMLPath
* @return
* @throws Exception
*/
private static ExternalLibrary getLibrary(File libraryXMLPath) throws Exception {
JAXBContext configCtx = JAXBContext.newInstance(ExternalLibrary.class);
Unmarshaller unmarshaller = configCtx.createUnmarshaller();
ExternalLibrary library = (ExternalLibrary) unmarshaller.unmarshal(libraryXMLPath);
return library;
}
use of javax.xml.bind.Unmarshaller in project asterixdb by apache.
the class ConfigureConfig method execCommand.
@Override
protected void execCommand() throws Exception {
configureCluster("local", "local.xml");
configureCluster("local", "local_chained_declustering_rep.xml");
configureCluster("local", "local_metadata_only_rep.xml");
configureCluster("demo", "demo.xml");
String installerConfPath = InstallerDriver.getManagixHome() + File.separator + InstallerDriver.MANAGIX_CONF_XML;
JAXBContext ctx = JAXBContext.newInstance(Configuration.class);
Unmarshaller unmarshaller = ctx.createUnmarshaller();
Configuration configuration = (Configuration) unmarshaller.unmarshal(new File(installerConfPath));
configuration.setConfigured(true);
configuration.getBackup().setBackupDir(InstallerDriver.getManagixHome() + File.separator + "backup");
configuration.getZookeeper().setHomeDir(InstallerDriver.getManagixHome() + File.separator + InstallerDriver.MANAGIX_INTERNAL_DIR + File.separator + "zookeeper_home");
configuration.getZookeeper().getServers().setJavaHome(System.getProperty("java.home"));
Marshaller marshaller = ctx.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(configuration, new FileOutputStream(installerConfPath));
}
use of javax.xml.bind.Unmarshaller in project karaf by apache.
the class JaxbUtil method unmarshalNoValidate.
private static Features unmarshalNoValidate(String uri, InputStream stream) {
try {
Unmarshaller unmarshaller = FEATURES_CONTEXT.createUnmarshaller();
NoSourceAndNamespaceFilter xmlFilter = new NoSourceAndNamespaceFilter(XmlUtils.xmlReader());
xmlFilter.setContentHandler(unmarshaller.getUnmarshallerHandler());
InputSource is = new InputSource(uri);
if (stream != null) {
is.setByteStream(stream);
}
SAXSource source = new SAXSource(xmlFilter, is);
Features features = (Features) unmarshaller.unmarshal(source);
features.setNamespace(xmlFilter.getNamespace());
return features;
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException("Unable to load " + uri, e);
}
}
use of javax.xml.bind.Unmarshaller in project poi by apache.
the class PresetGeometries method convertCustomGeometry.
/**
* Convert a single CustomGeometry object, i.e. from xmlbeans
*/
public static CustomGeometry convertCustomGeometry(XMLStreamReader staxReader) {
try {
JAXBContext jaxbContext = JAXBContext.newInstance(BINDING_PACKAGE);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
JAXBElement<CTCustomGeometry2D> el = unmarshaller.unmarshal(staxReader, CTCustomGeometry2D.class);
return new CustomGeometry(el.getValue());
} catch (JAXBException e) {
LOG.log(POILogger.ERROR, "Unable to parse single custom geometry", e);
return null;
}
}
Aggregations