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


Java ConfigResolver.TypedResolver方法代码示例

本文整理汇总了Java中org.apache.deltaspike.core.api.config.ConfigResolver.TypedResolver方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigResolver.TypedResolver方法的具体用法?Java ConfigResolver.TypedResolver怎么用?Java ConfigResolver.TypedResolver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.deltaspike.core.api.config.ConfigResolver的用法示例。


在下文中一共展示了ConfigResolver.TypedResolver方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: asResolver

import org.apache.deltaspike.core.api.config.ConfigResolver; //导入方法依赖的package包/类
public <T> ConfigResolver.TypedResolver<T> asResolver(final String key, final String stringDefault,
                                                      final Type ipCls,
                                                      final Class<? extends ConfigResolver.Converter> converterType,
                                                      final String parameterizedBy,
                                                      final boolean projectStageAware, final boolean evaluate)
{
    final ConfigResolver.UntypedResolver<String> untypedResolver = ConfigResolver.resolve(key);
    final ConfigResolver.TypedResolver<T> resolver =
            (ConfigResolver.Converter.class == converterType ?
                    untypedResolver.as(Class.class.cast(ipCls)) :
                    untypedResolver.as(ipCls, BeanProvider.getContextualReference(converterType)))
                    .withCurrentProjectStage(projectStageAware);
    if (!ConfigProperty.NULL.equals(stringDefault))
    {
        resolver.withStringDefault(stringDefault);
    }
    if (!ConfigProperty.NULL.equals(parameterizedBy))
    {
        resolver.parameterizedBy(parameterizedBy);
    }
    return resolver.evaluateVariables(evaluate);
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:23,代码来源:BaseConfigPropertyProducer.java

示例2: testGets

import org.apache.deltaspike.core.api.config.ConfigResolver; //导入方法依赖的package包/类
@Test
public void testGets()
{
    ConfigResolver.TypedResolver<String> resolver = ConfigResolver.resolve("dataSource")
            .withCurrentProjectStage(true)
            .parameterizedBy("dbvendor")
            .withDefault("TESTDEFAULT");

    Assert.assertEquals("TestDataSource", resolver.getValue());
    Assert.assertEquals("dataSource", resolver.getKey());
    Assert.assertEquals("TESTDEFAULT", resolver.getDefaultValue());
    Assert.assertEquals("dataSource.mysql.UnitTest", resolver.getResolvedKey());


    ConfigResolver.TypedResolver<String> resolver2 = ConfigResolver.resolve("testkey2")
            .withCurrentProjectStage(true)
            .parameterizedBy("INVALIDPARAMETER");


    Assert.assertEquals("testvalue", resolver2.getValue());
    Assert.assertEquals("testkey2", resolver2.getResolvedKey());
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:23,代码来源:TypedResolverTest.java

示例3: testWithCacheTime

import org.apache.deltaspike.core.api.config.ConfigResolver; //导入方法依赖的package包/类
@Test
public void testWithCacheTime() throws Exception
{
    ConfigResolver.TypedResolver<String> resolver = ConfigResolver.resolve("dataSource")
        .withCurrentProjectStage(true)
        .parameterizedBy("dbvendor")
        .cacheFor(TimeUnit.MILLISECONDS, 5)
        .withDefault("TESTDEFAULT");

    Assert.assertEquals("TestDataSource", resolver.getValue());
    Assert.assertEquals("TestDataSource", resolver.getValue());
    Assert.assertEquals("dataSource", resolver.getKey());
    Assert.assertEquals("TESTDEFAULT", resolver.getDefaultValue());
    Assert.assertEquals("dataSource.mysql.UnitTest", resolver.getResolvedKey());

    // because the clock steps in certain OS is only 16ms
    Thread.sleep(35L);
    Assert.assertEquals("TestDataSource", resolver.getValue());
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:20,代码来源:TypedResolverTest.java

示例4: testTypedResolver_NonExistingValue

import org.apache.deltaspike.core.api.config.ConfigResolver; //导入方法依赖的package包/类
@Test
public void testTypedResolver_NonExistingValue()
{
    final String key = "non.existing.key";

    ConfigResolver.TypedResolver<String> resolver = ConfigResolver.resolve(key)
        .logChanges(true);

    Assert.assertNull(resolver.getValue());

    setTestConfigSourceValue(key, "somevalue");
    Assert.assertEquals("somevalue", resolver.getValue());

    setTestConfigSourceValue(key, null);
    Assert.assertNull(resolver.getValue());
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:17,代码来源:ConfigResolverTest.java

示例5: readEntry

import org.apache.deltaspike.core.api.config.ConfigResolver; //导入方法依赖的package包/类
public <T> T readEntry(final String key, final String stringDefault, final Type ipCls,
                       final Class<? extends ConfigResolver.Converter> converterType,
                       final String parameterizedBy, final boolean projectStageAware, final boolean evaluate)
{
    final ConfigResolver.TypedResolver<T> resolver = asResolver(
            key, stringDefault, ipCls, converterType, parameterizedBy, projectStageAware, evaluate);
    return resolver.getValue();
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:9,代码来源:BaseConfigPropertyProducer.java

示例6: testConfigVariableRecursiveDeclaration

import org.apache.deltaspike.core.api.config.ConfigResolver; //导入方法依赖的package包/类
@Test
public void testConfigVariableRecursiveDeclaration()
{
    String url = ConfigResolver.getPropertyValue("deltaspike.test.recursive.variable1", "", true);
    Assert.assertEquals("pre-crazy-post/ohgosh/crazy", url);

    ConfigResolver.TypedResolver<String> tr = ConfigResolver.resolve("deltaspike.test.recursive.variable1")
        .evaluateVariables(true).logChanges(true);
    Assert.assertEquals("pre-crazy-post/ohgosh/crazy", tr.getValue());
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:11,代码来源:ConfigResolverTest.java

示例7: DefaultSupplier

import org.apache.deltaspike.core.api.config.ConfigResolver; //导入方法依赖的package包/类
private DefaultSupplier(final ConfigResolver.TypedResolver<T> delegate)
{
    this.delegate = delegate;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:5,代码来源:ProxyConfigurationLifecycle.java


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