Java 类org.elasticsearch.common.settings.loader.SettingsLoaderFactory 实例源码

项目:elasticsearch_my    文件:Settings.java   
/**
 * Loads settings from the actual string content that represents them using the
 * {@link SettingsLoaderFactory#loaderFromSource(String)}.
 * @deprecated use {@link #loadFromSource(String, XContentType)} to avoid content type detection
 */
@Deprecated
public Builder loadFromSource(String source) {
    SettingsLoader settingsLoader = SettingsLoaderFactory.loaderFromSource(source);
    try {
        Map<String, String> loadedSettings = settingsLoader.load(source);
        put(loadedSettings);
    } catch (Exception e) {
        throw new SettingsException("Failed to load settings from [" + source + "]", e);
    }
    return this;
}
项目:elasticsearch_my    文件:Settings.java   
/**
 * Loads settings from the actual string content that represents them using the
 * {@link SettingsLoaderFactory#loaderFromXContentType(XContentType)} method to obtain a loader
 */
public Builder loadFromSource(String source, XContentType xContentType) {
    SettingsLoader settingsLoader = SettingsLoaderFactory.loaderFromXContentType(xContentType);
    try {
        Map<String, String> loadedSettings = settingsLoader.load(source);
        put(loadedSettings);
    } catch (Exception e) {
        throw new SettingsException("Failed to load settings from [" + source + "]", e);
    }
    return this;
}
项目:elasticsearch_my    文件:Settings.java   
/**
 * Loads settings from a stream that represents them using the
 * {@link SettingsLoaderFactory#loaderFromResource(String)}.
 */
public Builder loadFromStream(String resourceName, InputStream is) throws IOException {
    SettingsLoader settingsLoader = SettingsLoaderFactory.loaderFromResource(resourceName);
    // NOTE: copyToString will close the input stream
    Map<String, String> loadedSettings =
        settingsLoader.load(Streams.copyToString(new InputStreamReader(is, StandardCharsets.UTF_8)));
    put(loadedSettings);
    return this;
}
项目:Elasticsearch    文件:Settings.java   
/**
 * Loads settings from the actual string content that represents them using the
 * {@link SettingsLoaderFactory#loaderFromSource(String)}.
 */
public Builder loadFromSource(String source) {
    SettingsLoader settingsLoader = SettingsLoaderFactory.loaderFromSource(source);
    try {
        Map<String, String> loadedSettings = settingsLoader.load(source);
        put(loadedSettings);
    } catch (Exception e) {
        throw new SettingsException("Failed to load settings from [" + source + "]", e);
    }
    return this;
}
项目:Elasticsearch    文件:Settings.java   
/**
 * Loads settings from a stream that represents them using the
 * {@link SettingsLoaderFactory#loaderFromSource(String)}.
 */
public Builder loadFromStream(String resourceName, InputStream is) throws SettingsException {
    SettingsLoader settingsLoader = SettingsLoaderFactory.loaderFromResource(resourceName);
    try {
        Map<String, String> loadedSettings = settingsLoader.load(Streams.copyToString(new InputStreamReader(is, Charsets.UTF_8)));
        put(loadedSettings);
    } catch (Exception e) {
        throw new SettingsException("Failed to load settings from [" + resourceName + "]", e);
    }
    return this;
}
项目:elasticshell    文件:MessagesProvider.java   
Map<String, String> loadFromClasspath(String resourceName) throws IOException {
    InputStream is = this.getClass().getResourceAsStream(resourceName);
    if (is == null) {
        throw new FileNotFoundException("Unable to find file " + MESSAGES_FILE);
    }
    SettingsLoader settingsLoader = SettingsLoaderFactory.loaderFromResource(resourceName);
    return settingsLoader.load(Streams.copyToString(new InputStreamReader(is, "UTF-8")));
}