gpt4 book ai didi

io.dropwizard.configuration.YamlConfigurationFactory.()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 14:56:40 25 4
gpt4 key购买 nike

本文整理了Java中io.dropwizard.configuration.YamlConfigurationFactory.<init>()方法的一些代码示例,展示了YamlConfigurationFactory.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlConfigurationFactory.<init>()方法的具体详情如下:
包路径:io.dropwizard.configuration.YamlConfigurationFactory
类名称:YamlConfigurationFactory
方法名:<init>

YamlConfigurationFactory.<init>介绍

[英]Creates a new configuration factory for the given class.
[中]为给定类创建新的配置工厂。

代码示例

代码示例来源:origin: dropwizard/dropwizard

@Override
public ConfigurationFactory<T> create(
    Class<T>     klass,
    Validator    validator,
    ObjectMapper objectMapper,
    String       propertyPrefix) {
  return new YamlConfigurationFactory<>(
    klass,
    validator,
    configureObjectMapper(objectMapper.copy()),
    propertyPrefix);
}

代码示例来源:origin: dropwizard/dropwizard

} else if (customPropertyPrefix.isPresent()) {
  bootstrap.setConfigurationFactoryFactory((klass, validator, objectMapper, propertyPrefix) ->
    new YamlConfigurationFactory<>(klass, validator, objectMapper, customPropertyPrefix.get()));

代码示例来源:origin: yammer/breakerbox

public YamlInstanceDiscovery(Path path,
               Validator validator,
               ObjectMapper objectMapper) {
  this.path = path;
  this.configurationFactory = new YamlConfigurationFactory<>(
      YamlInstanceConfiguration.class,
      validator,
      objectMapper,
      "dw");
  parseYamlInstanceConfiguration();
}

代码示例来源:origin: bazaarvoice/ostrich

private static DictionaryConfiguration loadConfigFile(String configFile)
      throws IOException, ConfigurationException {
    Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
    ConfigurationFactory<DictionaryConfiguration> configFactory = new YamlConfigurationFactory<>(
        DictionaryConfiguration.class, validator, Jackson.newObjectMapper(), "dictionary"
    );
    if (configFile != null) {
      return configFactory.build(new File(configFile));
    } else {
      return configFactory.build();
    }
  }
}

代码示例来源:origin: bazaarvoice/ostrich

private static CalculatorConfiguration loadConfigFile(String configFile) throws IOException,
      ConfigurationException {
    Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
    ConfigurationFactory<CalculatorConfiguration> configFactory = new YamlConfigurationFactory<>(
        CalculatorConfiguration.class, validator, Jackson.newObjectMapper(), "calculator"
    );
    if (configFile != null) {
      return configFactory.build(new File(configFile));
    } else {
      return configFactory.build();
    }
  }
}

代码示例来源:origin: io.dropwizard/dropwizard-configuration

@Override
public ConfigurationFactory<T> create(
    Class<T>     klass,
    Validator    validator,
    ObjectMapper objectMapper,
    String       propertyPrefix) {
  return new YamlConfigurationFactory<>(
    klass,
    validator,
    configureObjectMapper(objectMapper.copy()),
    propertyPrefix);
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testConfigurationNamespaces1() throws Exception {
  final AppConfiguration config = new YamlConfigurationFactory<>(AppConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  assertEquals("/tmp/trellisData/namespaces.json", config.getNamespaces(), "Incorrect namespace location!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetCORSConfig() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  assertTrue(TrellisUtils.getCorsConfiguration(config).isPresent(), "CORS configuration is missing!");
  config.getCors().setEnabled(false);
  assertFalse(TrellisUtils.getCorsConfiguration(config).isPresent(), "CORS config persists after disabling it!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetJwksAuthenticator() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  assertTrue(TrellisUtils.getJwtAuthenticator(config.getAuth().getJwt()) instanceof JwksAuthenticator,
      "JWT auth not enabled!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testConfigurationLocations() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  assertEquals("http://localhost:8080/", config.getBaseUrl(), "Incorrect baseUrl!");
  assertEquals("http://hub.example.com/", config.getHubUrl(), "Incorrect hubUrl!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetWebacCache() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  assertTrue(TrellisUtils.getWebacCache(config).isPresent(), "WebAC configuration not present!");
  config.getAuth().getWebac().setEnabled(false);
  assertFalse(TrellisUtils.getWebacCache(config).isPresent(), "WebAC config persists after disabling it!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testConfigurationAssets1() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  assertEquals("org/trellisldp/rdfa/resource.mustache", config.getAssets().getTemplate(), "Bad assets/template");
  assertEquals("http://example.com/image.icon", config.getAssets().getIcon(), "Bad assets/icon value!");
  assertTrue(config.getAssets().getJs().contains("http://example.com/scripts1.js"), "Missing assets/js value!");
  assertTrue(config.getAssets().getCss().contains("http://example.com/styles1.css"), "Missing assets/css value!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetJwtAuthenticatorNoKeystore() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  final String nonexistent = resourceFilePath("config1.yml").replaceAll("config1.yml", "nonexistent.yml");
  config.getAuth().getJwt().setJwks(null);
  config.getAuth().getJwt().setKeyStore(nonexistent);
  assertTrue(TrellisUtils.getJwtAuthenticator(config.getAuth().getJwt()) instanceof JwtAuthenticator,
      "JWT auth not disabled!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testConfigurationAssets1() throws Exception {
  final AppConfiguration config = new YamlConfigurationFactory<>(AppConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  assertEquals("org/trellisldp/rdfa/resource.mustache", config.getAssets().getTemplate(), "Incorrect asset tpl!");
  assertEquals("http://example.org/image.icon", config.getAssets().getIcon(), "Incorrect asset icon!");
  assertTrue(config.getAssets().getJs().contains("http://example.org/scripts1.js"), "Incorrect asset js!");
  assertTrue(config.getAssets().getCss().contains("http://example.org/styles1.css"), "Incorrect asset css!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetJwtAuthenticatorBadKeystore() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  config.getAuth().getJwt().setJwks(null);
  config.getAuth().getJwt().setKeyStore(resourceFilePath("config1.yml"));
  assertTrue(TrellisUtils.getJwtAuthenticator(config.getAuth().getJwt()) instanceof JwtAuthenticator,
      "JWT auth not disabled!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetJwtAuthenticatorNoKeyIds() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  config.getAuth().getJwt().setJwks(null);
  config.getAuth().getJwt().setKeyStore(resourceFilePath("keystore.jks"));
  config.getAuth().getJwt().setKeyIds(asList("foo", "bar"));
  assertTrue(TrellisUtils.getJwtAuthenticator(config.getAuth().getJwt()) instanceof JwtAuthenticator,
      "JWT auth not disabled!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testConfigurationLocations() throws Exception {
  final AppConfiguration config = new YamlConfigurationFactory<>(AppConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  assertEquals("/tmp/trellisData/binaries", config.getBinaries(), "Incorrect binary location!");
  assertEquals("/tmp/trellisData/mementos", config.getMementos(), "Incorrect memento location!");
  assertEquals("http://localhost:8080/", config.getBaseUrl(), "Incorrect base URL!");
  assertEquals("http://hub.example.com/", config.getHubUrl(), "Incorrect hub URL!");
  final String resources = "http://triplestore.example.com/";
  config.setResources(resources);
  assertEquals(resources, config.getResources(), "Incorrect resource location!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetJwtAuthenticatorFederated() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  config.getAuth().getJwt().setJwks(null);
  config.getAuth().getJwt().setKeyStore(resourceFilePath("keystore.jks"));
  config.getAuth().getJwt().setKeyIds(asList("trellis", "trellis-ec", "trellis-public"));
  assertTrue(TrellisUtils.getJwtAuthenticator(config.getAuth().getJwt()) instanceof FederatedJwtAuthenticator,
      "JWT auth not enabled!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetJwtAuthenticator() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  config.getAuth().getJwt().setJwks(null);
  config.getAuth().getJwt().setKeyStore(resourceFilePath("keystore.jks"));
  assertTrue(TrellisUtils.getJwtAuthenticator(config.getAuth().getJwt()) instanceof JwtAuthenticator,
      "JWT auth not enabled!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
  public void testGetNoJwtAuthenticator() throws Exception {
    final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
        Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
      .build(new File(getClass().getResource("/config1.yml").toURI()));
    config.getAuth().getJwt().setKeyStore(null);
    config.getAuth().getJwt().setKey("");
    config.getAuth().getJwt().setJwks(null);
    assertTrue(TrellisUtils.getJwtAuthenticator(config.getAuth().getJwt()) instanceof NullAuthenticator,
        "JWT auth not disabled!");
  }
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com