Java 类io.vertx.core.impl.FileResolver 实例源码

项目:statful-client-vertx    文件:StatfulMetricsFactoryImpl.java   
/**
 * Loads configuration from a file
 *
 * @throws RuntimeException if the file is invalid or non existent
 */
private StatfulMetricsOptions buildFromFile(final Vertx vertx, final String configPath) {

    FileResolver fileResolver = new FileResolver(vertx);
    File file = fileResolver.resolveFile(configPath);

    try (Scanner scanner = new Scanner(file)) {
        scanner.useDelimiter("\\A");
        String metricsConfigString = scanner.next();
        return new StatfulMetricsOptions(new JsonObject(metricsConfigString));
    } catch (IOException | DecodeException exception) {
        LOGGER.error("Error while reading metrics config file", exception);
        throw new RuntimeException("wrong configuration provided");
    }
}
项目:vertx-dropwizard-metrics    文件:VertxMetricsFactoryImpl.java   
private JsonObject loadOptionsFile(String configPath, FileResolver fileResolver) {
  File file = fileResolver.resolveFile(configPath);
  try (Scanner scanner = new Scanner(file)) {
    scanner.useDelimiter("\\A");
    String metricsConfigString = scanner.next();

    return new JsonObject(metricsConfigString);
  } catch (IOException ioe) {
    logger.error("Error while reading metrics config file", ioe);
  } catch (DecodeException de) {
    logger.error("Error while decoding metrics config file into JSON", de);
  }

  return new JsonObject();
}
项目:incubator-servicecomb-java-chassis    文件:VertxUtils.java   
/**
 * 配置vertx的文件缓存功能,默认关闭
 */
protected static void configureVertxFileCaching() {
  if (System.getProperty(FileResolver.DISABLE_CP_RESOLVING_PROP_NAME) == null) {
    System.setProperty(FileResolver.DISABLE_CP_RESOLVING_PROP_NAME, "true");
  }
}