本文整理汇总了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);
}
示例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());
}
示例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());
}
示例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());
}
示例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();
}
示例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());
}
示例7: DefaultSupplier
import org.apache.deltaspike.core.api.config.ConfigResolver; //导入方法依赖的package包/类
private DefaultSupplier(final ConfigResolver.TypedResolver<T> delegate)
{
this.delegate = delegate;
}