use of org.yaml.snakeyaml.constructor.Constructor in project eiger by wlloyd.
the class CliClient method loadHelp.
private CliUserHelp loadHelp() {
final InputStream is = CliClient.class.getClassLoader().getResourceAsStream("org/apache/cassandra/cli/CliHelp.yaml");
assert is != null;
try {
final Constructor constructor = new Constructor(CliUserHelp.class);
TypeDescription desc = new TypeDescription(CliUserHelp.class);
desc.putListPropertyType("commands", CliCommandHelp.class);
final Yaml yaml = new Yaml(new Loader(constructor));
return (CliUserHelp) yaml.load(is);
} finally {
FileUtils.closeQuietly(is);
}
}
use of org.yaml.snakeyaml.constructor.Constructor in project Essentials by drtshock.
the class YamlStorageReader method prepareConstructor.
private Constructor prepareConstructor(final Class<?> clazz) {
final Constructor constructor = new BukkitConstructor(clazz, plugin);
final Set<Class> classes = new HashSet<Class>();
prepareConstructor(constructor, classes, clazz);
return constructor;
}
use of org.yaml.snakeyaml.constructor.Constructor in project cassandra by apache.
the class YamlConfigurationLoader method loadConfig.
public Config loadConfig(URL url) throws ConfigurationException {
try {
logger.debug("Loading settings from {}", url);
byte[] configBytes;
try (InputStream is = url.openStream()) {
configBytes = ByteStreams.toByteArray(is);
} catch (IOException e) {
// getStorageConfigURL should have ruled this out
throw new AssertionError(e);
}
Constructor constructor = new CustomConstructor(Config.class);
PropertiesChecker propertiesChecker = new PropertiesChecker();
constructor.setPropertyUtils(propertiesChecker);
Yaml yaml = new Yaml(constructor);
Config result = loadConfig(yaml, configBytes);
propertiesChecker.check();
return result;
} catch (YAMLException e) {
throw new ConfigurationException("Invalid yaml: " + url + SystemUtils.LINE_SEPARATOR + " Error: " + e.getMessage(), false);
}
}
use of org.yaml.snakeyaml.constructor.Constructor in project storm by apache.
the class FluxParser method yaml.
private static Yaml yaml() {
Constructor constructor = new Constructor(TopologyDef.class);
TypeDescription topologyDescription = new TypeDescription(TopologyDef.class);
topologyDescription.putListPropertyType("spouts", SpoutDef.class);
topologyDescription.putListPropertyType("bolts", BoltDef.class);
topologyDescription.putListPropertyType("includes", IncludeDef.class);
constructor.addTypeDescription(topologyDescription);
Yaml yaml = new Yaml(constructor);
return yaml;
}
use of org.yaml.snakeyaml.constructor.Constructor in project spring-boot by spring-projects.
the class YamlConfigurationFactory method afterPropertiesSet.
@Override
@SuppressWarnings("unchecked")
public void afterPropertiesSet() throws Exception {
if (this.yaml == null) {
Assert.state(this.resource != null, "Resource should not be null");
this.yaml = StreamUtils.copyToString(this.resource.getInputStream(), Charset.defaultCharset());
}
Assert.state(this.yaml != null, "Yaml document should not be null: " + "either set it directly or set the resource to load it from");
if (logger.isTraceEnabled()) {
logger.trace(String.format("Yaml document is %n%s", this.yaml));
}
Constructor constructor = new YamlJavaBeanPropertyConstructor(this.type, this.propertyAliases);
this.configuration = (T) (new Yaml(constructor)).load(this.yaml);
if (this.validator != null) {
validate();
}
}
Aggregations