use of javax.xml.bind.JAXBContext in project oxAuth by GluuFederation.
the class ConfigurationTest method loadConfFromFile.
private static AppConfiguration loadConfFromFile(String p_filePath) throws JAXBException {
final JAXBContext jc = JAXBContext.newInstance(AppConfiguration.class);
final Unmarshaller u = jc.createUnmarshaller();
return (AppConfiguration) u.unmarshal(new File(p_filePath));
}
use of javax.xml.bind.JAXBContext in project oxAuth by GluuFederation.
the class ConfSerialization method loadXml.
public static <T> T loadXml(String p_fileName, Class p_clazz) {
final URL url = ConfSerialization.class.getResource(p_fileName);
try {
System.out.println("Loading configuration file: " + url);
JAXBContext jc = JAXBContext.newInstance(p_clazz);
Unmarshaller u = jc.createUnmarshaller();
return (T) u.unmarshal(url);
} catch (JAXBException e) {
System.out.println("Failed to get the configuration file: " + url);
e.printStackTrace();
}
return null;
}
use of javax.xml.bind.JAXBContext in project sukija by ahomansikka.
the class JAXBUtil method marshal.
/** Kirjoitetaan XML-dataa.
*
* @param value Data, joka kirjoitetaan.
* @param contextPath
* @param out Paikka, johon kirjoitetaan.
*/
public static final <T> void marshal(JAXBElement<T> value, String contextPath, OutputStream out, ClassLoader classLoader) throws JAXBException {
JAXBContext jc = JAXBContext.newInstance(contextPath, classLoader);
Marshaller m = jc.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m.marshal(value, out);
}
use of javax.xml.bind.JAXBContext in project asterixdb by apache.
the class AsterixInstallerIntegrationUtil method initZookeeperTestConfiguration.
private static void initZookeeperTestConfiguration(int port) throws JAXBException, FileNotFoundException {
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.getZookeeper().setClientPort(new BigInteger("" + port));
Marshaller marshaller = ctx.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(configuration, new FileOutputStream(installerConfPath));
}
use of javax.xml.bind.JAXBContext in project asterixdb by apache.
the class InstallerUtil method getAsterixConfiguration.
public static AsterixConfiguration getAsterixConfiguration(String asterixConf) throws FileNotFoundException, IOException, JAXBException {
if (asterixConf == null) {
asterixConf = InstallerDriver.getManagixHome() + File.separator + DEFAULT_ASTERIX_CONFIGURATION_PATH;
}
File file = new File(asterixConf);
JAXBContext ctx = JAXBContext.newInstance(AsterixConfiguration.class);
Unmarshaller unmarshaller = ctx.createUnmarshaller();
AsterixConfiguration asterixConfiguration = (AsterixConfiguration) unmarshaller.unmarshal(file);
return asterixConfiguration;
}
Aggregations