本文整理汇总了Java中io.bootique.config.ConfigurationFactory.config方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationFactory.config方法的具体用法?Java ConfigurationFactory.config怎么用?Java ConfigurationFactory.config使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.bootique.config.ConfigurationFactory
的用法示例。
在下文中一共展示了ConfigurationFactory.config方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDataSource
import io.bootique.config.ConfigurationFactory; //导入方法依赖的package包/类
@Singleton
@Provides
public DataSourceFactory createDataSource(
ConfigurationFactory configFactory,
BootLogger bootLogger,
ShutdownManager shutdownManager,
Set<DataSourceListener> listeners,
Injector injector) {
Map<String, ManagedDataSourceFactory> configs = configFactory
.config(new TypeRef<Map<String, ManagedDataSourceFactory>>() {
}, configPrefix);
LazyDataSourceFactory factory = new LazyDataSourceFactoryFactory(configs).create(injector, listeners);
shutdownManager.addShutdownHook(() -> {
bootLogger.trace(() -> "shutting down LazyDataSourceFactory...");
factory.shutdown();
});
return factory;
}
示例2: testInitFromConfig
import io.bootique.config.ConfigurationFactory; //导入方法依赖的package包/类
@Test
public void testInitFromConfig() {
ConfigurationFactory configFactory = LOGGER_STACK
.newBQRuntime("classpath:io/bootique/logback/test-multi-appender.yml")
.getInstance(ConfigurationFactory.class);
LogbackContextFactory rootFactory = configFactory.config(LogbackContextFactory.class, "log");
assertEquals(LogbackLevel.debug, rootFactory.getLevel());
assertNotNull(rootFactory.getAppenders());
assertEquals(2, rootFactory.getAppenders().size());
AppenderFactory[] appenders = rootFactory.getAppenders().toArray(new AppenderFactory[2]);
assertTrue(appenders[0] instanceof ConsoleAppenderFactory);
ConsoleAppenderFactory a1 = (ConsoleAppenderFactory) appenders[0];
assertEquals(ConsoleTarget.stderr, a1.getTarget());
assertEquals("%c{20}: %m%n", a1.getLogFormat());
assertTrue(appenders[1] instanceof FileAppenderFactory);
FileAppenderFactory a2 = (FileAppenderFactory) appenders[1];
assertEquals("%c{10}: %m%n", a2.getLogFormat());
assertEquals("target/logs/rotate/logfile123.log", a2.getFile());
}
示例3: createJobRegistry
import io.bootique.config.ConfigurationFactory; //导入方法依赖的package包/类
@Provides
@Singleton
JobRegistry createJobRegistry(
Set<Job> jobs,
Set<JobListener> jobListeners,
Scheduler scheduler,
ConfigurationFactory configFactory) {
TypeRef<Map<String, JobDefinition>> ref = new TypeRef<Map<String, JobDefinition>>() {
};
Map<String, JobDefinition> configuredDefinitions = configFactory.config(ref, "jobs");
return new DefaultJobRegistry(jobs, configuredDefinitions, scheduler, jobListeners);
}
示例4: provideMetricRegistryFactory
import io.bootique.config.ConfigurationFactory; //导入方法依赖的package包/类
@Provides
@Singleton
MetricRegistryFactory provideMetricRegistryFactory(ConfigurationFactory configFactory) {
return configFactory.config(MetricRegistryFactory.class, configPrefix);
}
示例5: createBuilder
import io.bootique.config.ConfigurationFactory; //导入方法依赖的package包/类
@Singleton
@Provides
public Builder createBuilder(ConfigurationFactory configFactory,
RoutingHandler routingHandler,
Set<HandlerWrapper> handlerWrappers,
Set<OrderedHandlerWrapper> orderedHandlerWrappers,
Set<Controller> controllers) {
final Builder builder = builder();
final UndertowFactory config = configFactory.config(UndertowFactory.class, configPrefix);
config.getHttpListeners().forEach(listener -> {
builder.addHttpListener(listener.getPort(), listener.getHost());
});
config.getHttpsListeners().forEach(listener -> {
builder.addHttpsListener(listener.getPort(), listener.getHost(), createSslContext(config));
});
if (config.getBufferSize() != null) {
builder.setBufferSize(config.getBufferSize());
}
if (config.getIoThreads() != null) {
builder.setIoThreads(config.getIoThreads());
}
if (config.getWorkerThreads() != null) {
builder.setWorkerThreads(config.getWorkerThreads());
}
if (config.getDirectBuffers() != null) {
builder.setDirectBuffers(config.getDirectBuffers());
}
HttpHandler root = routingHandler;
if (handlerWrappers != null) {
for (HandlerWrapper wrapper : handlerWrappers) {
root = wrapper.wrap(root);
}
}
if (orderedHandlerWrappers != null) {
final List<OrderedHandlerWrapper> orderedWrappers = UndertowModuleUtils.sortWrappers(orderedHandlerWrappers);
for (OrderedHandlerWrapper orderedWrapper : orderedWrappers) {
root = orderedWrapper.wrap(root);
}
}
final PathHandler pathHandler = path();
controllers.forEach(controller -> {
controller.defineRoutes(routingHandler);
LOGGER.info("Controller '{}' registered.", controller.getClass().getSimpleName());
});
if (config.getStaticFiles().size() > 0) {
for (StaticResourceFactory filesConfig : config.getStaticFiles()) {
final String url = filesConfig.getUrl();
if ("/".equals(filesConfig.getUrl())) {
if (routingHandler.getFallbackHandler() != null) {
routingHandler.setFallbackHandler(new ResourceHandler(filesConfig.getResourceManager(), routingHandler.getFallbackHandler()));
}
} else {
final ResourceHandler resourceHandler = new ResourceHandler(filesConfig.getResourceManager());
pathHandler.addPrefixPath(url, resourceHandler);
}
}
}
pathHandler.addPrefixPath("/", root);
builder.setHandler(pathHandler);
// UndertowOptions;
return builder;
}
示例6: provideFactory
import io.bootique.config.ConfigurationFactory; //导入方法依赖的package包/类
@Provides
@Singleton
KafkaClient_0_8_Factory provideFactory(ConfigurationFactory configurationFactory) {
return configurationFactory.config(KafkaClient_0_8_Factory.class, configPrefix);
}
示例7: providerServerFactory
import io.bootique.config.ConfigurationFactory; //导入方法依赖的package包/类
@Singleton
@Provides
ServerFactory providerServerFactory(ConfigurationFactory configFactory) {
return configFactory.config(ServerFactory.class, configPrefix);
}