当前位置: 首页>>代码示例>>Java>>正文


Java ConfigFilesProvider类代码示例

本文整理汇总了Java中org.cfg4j.source.context.filesprovider.ConfigFilesProvider的典型用法代码示例。如果您正苦于以下问题:Java ConfigFilesProvider类的具体用法?Java ConfigFilesProvider怎么用?Java ConfigFilesProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ConfigFilesProvider类属于org.cfg4j.source.context.filesprovider包,在下文中一共展示了ConfigFilesProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configurationProvider

import org.cfg4j.source.context.filesprovider.ConfigFilesProvider; //导入依赖的package包/类
@Bean
public ConfigurationProvider configurationProvider() {
  // Specify which files to load. Configuration from both files will be merged.
  ConfigFilesProvider configFilesProvider = () -> Collections.singletonList(Paths.get("application.yaml"));

  // Use local files as configuration store
  ConfigurationSource source = new FilesConfigurationSource(configFilesProvider);

  // Use relative paths
  Environment environment = new ImmutableEnvironment(filesPath);

  // Reload configuration every 500 milliseconds
  ReloadStrategy reloadStrategy = new PeriodicalReloadStrategy(500, TimeUnit.MILLISECONDS);

  // Create provider
  return new ConfigurationProviderBuilder()
      .withConfigurationSource(source)
      .withReloadStrategy(reloadStrategy)
      .withEnvironment(environment)
      .withMetrics(metricRegistry, "firstProvider.")
      .build();
}
 
开发者ID:cfg4j,项目名称:cfg4j-sample-apps,代码行数:23,代码来源:ConfigBeans.java

示例2: configurationProvider

import org.cfg4j.source.context.filesprovider.ConfigFilesProvider; //导入依赖的package包/类
@Bean
public ConfigurationProvider configurationProvider() {
  // Specify which files to load. Configuration from both files will be merged.
  ConfigFilesProvider configFilesProvider = () -> Arrays.asList(Paths.get("application.properties"), Paths.get("otherConfig.properties"));

  // Use Git repository as configuration store
  ConfigurationSource source = new GitConfigurationSourceBuilder()
      .withRepositoryURI(configRepoPath)
      .withConfigFilesProvider(configFilesProvider)
      .build();

  // Select branch to use (use new DefaultEnvironment()) for master
  Environment environment = new ImmutableEnvironment(branch);

  // Reload configuration every 5 seconds
  ReloadStrategy reloadStrategy = new PeriodicalReloadStrategy(5, TimeUnit.SECONDS);

  // Create provider
  return new ConfigurationProviderBuilder()
      .withConfigurationSource(source)
      .withEnvironment(environment)
      .withReloadStrategy(reloadStrategy)
      .build();
}
 
开发者ID:cfg4j,项目名称:cfg4j-sample-apps,代码行数:25,代码来源:ConfigBeans.java

示例3: configurationProvider

import org.cfg4j.source.context.filesprovider.ConfigFilesProvider; //导入依赖的package包/类
@Bean
public ConfigurationProvider configurationProvider() {
  // Specify which files to load. Configuration from both files will be merged.
  ConfigFilesProvider configFilesProvider = () -> Arrays.asList(Paths.get("application.yaml"), Paths.get("otherConfig.properties"));

  // Use local files as configuration store
  ConfigurationSource source = new FilesConfigurationSource(configFilesProvider);

  // Use relative paths
  Environment environment = new ImmutableEnvironment(filesPath);

  // Reload configuration every 5 seconds
  ReloadStrategy reloadStrategy = new PeriodicalReloadStrategy(5, TimeUnit.SECONDS);

  // Create provider
  return new ConfigurationProviderBuilder()
      .withConfigurationSource(source)
      .withReloadStrategy(reloadStrategy)
      .withEnvironment(environment)
      .build();
}
 
开发者ID:cfg4j,项目名称:cfg4j-sample-apps,代码行数:22,代码来源:ConfigBeans.java

示例4: getConfigurationThrowsOnMalformedConfigFile

import org.cfg4j.source.context.filesprovider.ConfigFilesProvider; //导入依赖的package包/类
@Test
public void getConfigurationThrowsOnMalformedConfigFile() throws Exception {
  configFilesProvider = new ConfigFilesProvider() {
    @Override
    public Iterable<Path> getConfigFiles() {
      return Collections.singletonList(
          Paths.get("malformed.properties")
      );
    }
  };

  source = new FilesConfigurationSource(configFilesProvider);

  expectedException.expect(IllegalStateException.class);
  source.getConfiguration(environment);
}
 
开发者ID:cfg4j,项目名称:cfg4j,代码行数:17,代码来源:FilesConfigurationSourceTest.java

示例5: getConfigurationThrowsOnMissingConfigFile

import org.cfg4j.source.context.filesprovider.ConfigFilesProvider; //导入依赖的package包/类
@Test
public void getConfigurationThrowsOnMissingConfigFile() throws Exception {
  configFilesProvider = new ConfigFilesProvider() {
    @Override
    public Iterable<Path> getConfigFiles() {
      return Collections.singletonList(
          Paths.get("nonexistent.properties")
      );
    }
  };

  source = new ClasspathConfigurationSource(configFilesProvider);

  expectedException.expect(IllegalStateException.class);
  source.getConfiguration(new DefaultEnvironment());
}
 
开发者ID:cfg4j,项目名称:cfg4j,代码行数:17,代码来源:ClasspathConfigurationSourceTest.java

示例6: getConfigurationThrowsOnMalformedConfigFile

import org.cfg4j.source.context.filesprovider.ConfigFilesProvider; //导入依赖的package包/类
@Test
public void getConfigurationThrowsOnMalformedConfigFile() throws Exception {
  configFilesProvider = new ConfigFilesProvider() {
    @Override
    public Iterable<Path> getConfigFiles() {
      return Collections.singletonList(
          Paths.get("malformed.properties")
      );
    }
  };

  source = new ClasspathConfigurationSource(configFilesProvider);

  expectedException.expect(IllegalStateException.class);
  source.getConfiguration(new DefaultEnvironment());
}
 
开发者ID:cfg4j,项目名称:cfg4j,代码行数:17,代码来源:ClasspathConfigurationSourceTest.java

示例7: getConfigurationSource

import org.cfg4j.source.context.filesprovider.ConfigFilesProvider; //导入依赖的package包/类
private ConfigurationSource getConfigurationSource(Path configFilePath) {

    ConfigFilesProvider configFilesProvider = () ->
        ImmutableList.of(configFilePath);

    if (configFilePath.isAbsolute()) {
      LOGGER.debug("loading config from: {}", configFilePath);
      return new FilesConfigurationSource(configFilesProvider);
    } else {
      LOGGER.debug("loading config from classpath");
      return new ClasspathConfigurationSource(configFilesProvider);
    }
  }
 
开发者ID:Nexmo,项目名称:comms-router,代码行数:14,代码来源:ConfigurationImpl.java

示例8: FilesConfigurationSource

import org.cfg4j.source.context.filesprovider.ConfigFilesProvider; //导入依赖的package包/类
/**
 * Construct {@link ConfigurationSource} backed by files. Uses "application.properties" file
 * located in the path specified by the {@link Environment} provided to {@link #getConfiguration(Environment)}
 * calls (see corresponding javadoc for detail).
 */
public FilesConfigurationSource() {
  this(new ConfigFilesProvider() {
    @Override
    public Iterable<Path> getConfigFiles() {
      return Collections.singletonList(
          Paths.get("application.properties")
      );
    }
  });
}
 
开发者ID:cfg4j,项目名称:cfg4j,代码行数:16,代码来源:FilesConfigurationSource.java

示例9: ClasspathConfigurationSource

import org.cfg4j.source.context.filesprovider.ConfigFilesProvider; //导入依赖的package包/类
/**
 * Construct {@link ConfigurationSource} backed by classpath files. Uses "application.properties" file
 * located in the path specified by the {@link Environment} provided to {@link #getConfiguration(Environment)}
 * calls (see corresponding javadoc for detail).
 */
public ClasspathConfigurationSource() {
  this(new ConfigFilesProvider() {
    @Override
    public Iterable<Path> getConfigFiles() {
      return Collections.singletonList(
          Paths.get("application.properties")
      );
    }
  });
}
 
开发者ID:cfg4j,项目名称:cfg4j,代码行数:16,代码来源:ClasspathConfigurationSource.java

示例10: getConfigurationReadsFromGivenFiles

import org.cfg4j.source.context.filesprovider.ConfigFilesProvider; //导入依赖的package包/类
@Test
public void getConfigurationReadsFromGivenFiles() throws Exception {
  configFilesProvider = new ConfigFilesProvider() {
    @Override
    public Iterable<Path> getConfigFiles() {
      return Arrays.asList(
          Paths.get("application.properties"),
          Paths.get("otherConfig.properties")
      );
    }
  };

  source = new FilesConfigurationSource(configFilesProvider);
  assertThat(source.getConfiguration(environment)).containsOnlyKeys("some.setting", "otherConfig.setting");
}
 
开发者ID:cfg4j,项目名称:cfg4j,代码行数:16,代码来源:FilesConfigurationSourceTest.java

示例11: getConfigurationReadsFromGivenFiles

import org.cfg4j.source.context.filesprovider.ConfigFilesProvider; //导入依赖的package包/类
@Test
public void getConfigurationReadsFromGivenFiles() throws Exception {
  configFilesProvider = new ConfigFilesProvider() {
    @Override
    public Iterable<Path> getConfigFiles() {
      return Arrays.asList(
          Paths.get("application.properties"),
          Paths.get("otherConfig.properties")
      );
    }
  };

  source = new ClasspathConfigurationSource(configFilesProvider);
  assertThat(source.getConfiguration(new DefaultEnvironment())).containsOnlyKeys("some.setting", "otherConfig.setting");
}
 
开发者ID:cfg4j,项目名称:cfg4j,代码行数:16,代码来源:ClasspathConfigurationSourceTest.java

示例12: getConfigurationProvider

import org.cfg4j.source.context.filesprovider.ConfigFilesProvider; //导入依赖的package包/类
private ConfigurationProvider getConfigurationProvider(final String path) {
  ConfigurationSource source = new ClasspathConfigurationSource(new ConfigFilesProvider() {
    @Override
    public Iterable<Path> getConfigFiles() {
      return Collections.singleton(Paths.get(path));
    }
  });

  return new ConfigurationProviderBuilder()
      .withConfigurationSource(source)
      .build();
}
 
开发者ID:cfg4j,项目名称:cfg4j,代码行数:13,代码来源:SimpleConfigurationProviderWithClasspathIntegrationTest.java

示例13: getConfigurationReadsFromGivenFiles

import org.cfg4j.source.context.filesprovider.ConfigFilesProvider; //导入依赖的package包/类
@Test
public void getConfigurationReadsFromGivenFiles() throws Exception {
  ConfigFilesProvider configFilesProvider = new ConfigFilesProvider() {
    @Override
    public Iterable<Path> getConfigFiles() {
      return Arrays.asList(Paths.get("application.properties"), Paths.get("otherConfig.properties"));
    }
  };
  Environment environment = new DefaultEnvironment();

  try (GitConfigurationSource gitConfigurationSource = getSourceForRemoteRepoWithFilesProvider(configFilesProvider)) {
    assertThat(gitConfigurationSource.getConfiguration(environment)).containsKeys("some.setting", "otherConfig.setting");
  }
}
 
开发者ID:cfg4j,项目名称:cfg4j,代码行数:15,代码来源:GitConfigurationSourceIntegrationTest.java

示例14: getConfigurationThrowsOnMalformedConfigFile

import org.cfg4j.source.context.filesprovider.ConfigFilesProvider; //导入依赖的package包/类
@Test
public void getConfigurationThrowsOnMalformedConfigFile() throws Exception {
  ConfigFilesProvider configFilesProvider = new ConfigFilesProvider() {
    @Override
    public Iterable<Path> getConfigFiles() {
      return Collections.singletonList(Paths.get("malformed.properties"));
    }
  };

  expectedException.expect(IllegalStateException.class);
  getSourceForRemoteRepoWithFilesProvider(configFilesProvider).getConfiguration(new DefaultEnvironment());
}
 
开发者ID:cfg4j,项目名称:cfg4j,代码行数:13,代码来源:GitConfigurationSourceIntegrationTest.java

示例15: getSourceForRemoteRepoWithFilesProvider

import org.cfg4j.source.context.filesprovider.ConfigFilesProvider; //导入依赖的package包/类
private GitConfigurationSource getSourceForRemoteRepoWithFilesProvider(ConfigFilesProvider configFilesProvider) {
  GitConfigurationSource source = getSourceBuilderForRemoteRepoWithDefaults()
      .withConfigFilesProvider(configFilesProvider)
      .build();

  source.init();

  return source;
}
 
开发者ID:cfg4j,项目名称:cfg4j,代码行数:10,代码来源:GitConfigurationSourceIntegrationTest.java


注:本文中的org.cfg4j.source.context.filesprovider.ConfigFilesProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。