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


Java ConfigurationFactory.config方法代码示例

本文整理汇总了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;
}
 
开发者ID:bootique,项目名称:bootique-jdbc,代码行数:22,代码来源:JdbcModule.java

示例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());
}
 
开发者ID:bootique,项目名称:bootique-logback,代码行数:26,代码来源:LogbackContextFactoryIT.java

示例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);
}
 
开发者ID:bootique,项目名称:bootique-job,代码行数:15,代码来源:JobModule.java

示例4: provideMetricRegistryFactory

import io.bootique.config.ConfigurationFactory; //导入方法依赖的package包/类
@Provides
@Singleton
MetricRegistryFactory provideMetricRegistryFactory(ConfigurationFactory configFactory) {
    return configFactory.config(MetricRegistryFactory.class, configPrefix);
}
 
开发者ID:bootique,项目名称:bootique-metrics,代码行数:6,代码来源:MetricsModule.java

示例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;
}
 
开发者ID:bootique,项目名称:bootique-undertow,代码行数:82,代码来源:UndertowModule.java

示例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);
}
 
开发者ID:bootique,项目名称:bootique-kafka-client,代码行数:6,代码来源:KafkaClient_0_8_Module.java

示例7: providerServerFactory

import io.bootique.config.ConfigurationFactory; //导入方法依赖的package包/类
@Singleton
@Provides
ServerFactory providerServerFactory(ConfigurationFactory configFactory) {
    return configFactory.config(ServerFactory.class, configPrefix);
}
 
开发者ID:bootique,项目名称:bootique-jetty,代码行数:6,代码来源:JettyModule.java


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