use of com.hazelcast.internal.config.MemberYamlConfigRootTagRecognizer in project hazelcast by hazelcast.
the class Config method loadFromStream.
/**
* Creates a Config from the provided stream (XML or YAML content).
*
* @param source the XML or YAML stream
* @param properties properties to use for variable resolution
* @return Config created from the stream
*/
public static Config loadFromStream(InputStream source, Properties properties) {
isNotNull(source, "(InputStream) source");
try {
ConfigStream cfgStream = new ConfigStream(source);
if (new MemberXmlConfigRootTagRecognizer().isRecognized(cfgStream)) {
cfgStream.reset();
InputStream stream = new SequenceInputStream(cfgStream, source);
return applyEnvAndSystemVariableOverrides(new XmlConfigBuilder(stream).setProperties(properties).build());
}
cfgStream.reset();
if (new MemberYamlConfigRootTagRecognizer().isRecognized(cfgStream)) {
cfgStream.reset();
InputStream stream = new SequenceInputStream(cfgStream, source);
return applyEnvAndSystemVariableOverrides(new YamlConfigBuilder(stream).setProperties(properties).build());
}
} catch (Exception e) {
throw ExceptionUtil.rethrow(e);
}
throw new IllegalArgumentException("interpretation error: the resource is neither valid XML nor valid YAML");
}
Aggregations