use of org.yaml.snakeyaml.constructor.Constructor in project sharding-jdbc by dangdangdotcom.
the class BestEffortsDeliveryJobMain method main.
/**
* 启动入口.
*
* @param args 启动参数
*/
// CHECKSTYLE:OFF
public static void main(final String[] args) throws Exception {
// CHECKSTYLE:ON
try (InputStreamReader inputStreamReader = new InputStreamReader(BestEffortsDeliveryJobMain.class.getResourceAsStream("/conf/config.yaml"), "UTF-8")) {
BestEffortsDeliveryConfiguration config = new Yaml(new Constructor(BestEffortsDeliveryConfiguration.class)).loadAs(inputStreamReader, BestEffortsDeliveryConfiguration.class);
new BestEffortsDeliveryJobFactory(config).init();
}
}
use of org.yaml.snakeyaml.constructor.Constructor in project jstorm by alibaba.
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 es6draft by anba.
the class Test262Info method readYaml.
private void readYaml(String descriptor, boolean lenient) throws MalformedDataException {
assert descriptor != null && !descriptor.isEmpty();
Yaml yaml = null;
if (lenient) {
yaml = yamlQueue.poll();
}
if (yaml == null) {
Constructor constructor = new Constructor(TestDescriptor.class);
if (lenient) {
PropertyUtils utils = new PropertyUtils();
utils.setSkipMissingProperties(true);
constructor.setPropertyUtils(utils);
}
yaml = new Yaml(constructor);
}
TestDescriptor desc;
try {
desc = yaml.loadAs(descriptor, TestDescriptor.class);
} catch (YAMLException e) {
throw new MalformedDataException(e.getMessage(), e);
}
if (lenient) {
yamlQueue.offer(yaml);
}
this.description = desc.getDescription();
this.includes = desc.getIncludes();
this.features = desc.getFeatures();
this.errorType = desc.getNegative();
this.negative = desc.getNegative() != null;
if (!desc.getFlags().isEmpty()) {
if (!lenient) {
for (String flag : desc.getFlags()) {
if (!allowedFlags.contains(flag)) {
throw new MalformedDataException(String.format("Unknown flag '%s'", flag));
}
}
}
this.negative |= desc.getFlags().contains("negative");
this.noStrict = desc.getFlags().contains("noStrict");
this.onlyStrict = desc.getFlags().contains("onlyStrict");
this.module = desc.getFlags().contains("module");
this.raw = desc.getFlags().contains("raw");
}
}
use of org.yaml.snakeyaml.constructor.Constructor in project camel by apache.
the class SnakeYAMLDataFormat method defaultConstructor.
// ***************************
// Defaults
// ***************************
private BaseConstructor defaultConstructor(CamelContext context) {
ClassLoader yamlClassLoader = this.classLoader;
Collection<TypeFilter> yamlTypeFilters = this.typeFilters;
if (yamlClassLoader == null && useApplicationContextClassLoader) {
yamlClassLoader = context.getApplicationContextClassLoader();
}
if (allowAnyType) {
yamlTypeFilters = Collections.singletonList(TypeFilters.allowAll());
}
BaseConstructor yamlConstructor;
if (yamlTypeFilters != null) {
yamlConstructor = yamlClassLoader != null ? typeFilterConstructor(yamlClassLoader, yamlTypeFilters) : typeFilterConstructor(yamlTypeFilters);
} else {
yamlConstructor = new SafeConstructor();
}
if (typeDescriptions != null && yamlConstructor instanceof Constructor) {
for (TypeDescription typeDescription : typeDescriptions) {
((Constructor) yamlConstructor).addTypeDescription(typeDescription);
}
}
return yamlConstructor;
}
use of org.yaml.snakeyaml.constructor.Constructor in project cassandra by apache.
the class StressProfile method load.
public static StressProfile load(URI file) throws IOError {
try {
Constructor constructor = new Constructor(StressYaml.class);
Yaml yaml = new Yaml(constructor);
InputStream yamlStream = file.toURL().openStream();
if (yamlStream.available() == 0)
throw new IOException("Unable to load yaml file from: " + file);
StressYaml profileYaml = yaml.loadAs(yamlStream, StressYaml.class);
StressProfile profile = new StressProfile();
profile.init(profileYaml);
return profile;
} catch (YAMLException | IOException | RequestValidationException e) {
throw new IOError(e);
}
}
Aggregations