本文整理汇总了Java中org.apache.commons.configuration2.Configuration类的典型用法代码示例。如果您正苦于以下问题:Java Configuration类的具体用法?Java Configuration怎么用?Java Configuration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Configuration类属于org.apache.commons.configuration2包,在下文中一共展示了Configuration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpClass
import org.apache.commons.configuration2.Configuration; //导入依赖的package包/类
@BeforeClass
public static void setUpClass() throws Exception {
faker = new Faker();
String ip = esContainer.getContainerIpAddress();
Integer transportPort = esContainer.getMappedPort(9300);
MapConfiguration memoryParams = new MapConfiguration(new HashMap<>());
memoryParams.setProperty(CONFIG_ES_CLUSTER_HOST, ip);
memoryParams.setProperty(CONFIG_ES_CLUSTER_PORT, transportPort);
memoryParams.setProperty(CONFIG_ES_CLUSTER_NAME, "elasticsearch");
injector = Guice.createInjector(
Modules.override(new ElasticSearchModule())
.with(binder -> {
binder.bind(Configuration.class).toProvider(() -> memoryParams);
})
);
productDao = injector.getInstance(ProductDao.class);
esClient = injector.getInstance(TransportClient.class);
}
示例2: savePropertyForStandaloneProfile
import org.apache.commons.configuration2.Configuration; //导入依赖的package包/类
/**
* Save property for standalone profile.
*
* @param pair the pair
*/
public void savePropertyForStandaloneProfile(final Pair<String, String> pair) {
try {
final File file = getStandaloneProfileConfigurationDirectory();
final Parameters params = new Parameters();
final FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
.configure(params.properties().setFile(new File(file, getApplicationName() + ".properties")));
final Configuration config = builder.getConfiguration();
config.setProperty(pair.getKey(), pair.getValue());
builder.save();
} catch (final Exception e) {
throw Throwables.propagate(e);
}
}
示例3: configure
import org.apache.commons.configuration2.Configuration; //导入依赖的package包/类
@Override
protected void configure() {
bind(Configuration.class).toProvider(ConfigurationProvider.class).in(Singleton.class);
bind(TransportClient.class).toProvider(TransportClientProvider.class).in(Singleton.class);
bind(JsonFormat.Printer.class).toInstance(JsonFormat.printer());
bind(JsonFormat.Parser.class).toInstance(JsonFormat.parser());
}
示例4: setUp
import org.apache.commons.configuration2.Configuration; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
String ip = esContainer.getContainerIpAddress();
Integer transportPort = esContainer.getMappedPort(9300);
MapConfiguration memoryParams = new MapConfiguration(new HashMap<>());
memoryParams.setProperty(CONFIG_ES_CLUSTER_HOST, ip);
memoryParams.setProperty(CONFIG_ES_CLUSTER_PORT, transportPort);
memoryParams.setProperty(CONFIG_ES_CLUSTER_NAME, "elasticsearch");
Injector injector = Guice.createInjector(
Modules.override(new ElasticSearchModule()).with(
binder -> {
binder.bind(Configuration.class).toInstance(memoryParams);
}
)
);
transportClientProvider = injector.getInstance(TransportClientProvider.class);
}
示例5: fetchDebeziumConfig
import org.apache.commons.configuration2.Configuration; //导入依赖的package包/类
/**
* Get DebeziumSource configuration.
*
* @param debeziumConf An empty {@code SourceConfig}
* @throws BiremeException miss some required configuration
*/
protected void fetchDebeziumConfig(SourceConfig debeziumConf) throws BiremeException {
Configuration subConfig = new SubsetConfiguration(config, debeziumConf.name, ".");
String prefix = subConfig.getString("namespace");
if (prefix == null) {
String messages = "Please designate your namespace.";
logger.fatal(messages);
throw new BiremeException(messages);
}
debeziumConf.type = SourceType.DEBEZIUM;
debeziumConf.server = subConfig.getString("kafka.server");
debeziumConf.topic = prefix;
debeziumConf.groupID = subConfig.getString("kafka.groupid", "bireme");
if (debeziumConf.server == null) {
String message = "Please designate server for " + debeziumConf.name + ".";
logger.fatal(message);
throw new BiremeException(message);
}
}
示例6: testGet
import org.apache.commons.configuration2.Configuration; //导入依赖的package包/类
@Test
public void testGet() throws Exception {
String site = "bitflyer4j-site.properties";
// Classpath exists
Configuration conf = ConfigurationType.get(site, null).get();
assertEquals(conf.getString(VERSION.getKey()), "test");
// Classpath does not exist. (And should not load from file path.)
assertFalse(ConfigurationType.get("build.gradle", null).isPresent());
// File exists.
conf = ConfigurationType.get(site, "src/test/resources").get();
assertEquals(conf.getString(VERSION.getKey()), "test");
// File does not exist. (And should not load from classpath.)
assertFalse(ConfigurationType.get(site, "build").isPresent());
}
示例7: test
import org.apache.commons.configuration2.Configuration; //导入依赖的package包/类
@Test
public void test() throws ConfigurationException {
// Null input. (= Default value.)
assertEquals(VERSION.fetch(null), VERSION.getDefaultValue());
// Not found. (= Default value.)
Configuration conf = new MapConfiguration(new HashMap<>());
assertEquals(VERSION.fetch(conf), VERSION.getDefaultValue());
// Retrieved from properties. (Empty)
conf.setProperty(VERSION.getKey(), "");
assertNull(VERSION.fetch(conf));
// Retrieved from properties. (Configured)
conf.setProperty(VERSION.getKey(), "test");
assertEquals(VERSION.fetch(conf), "test");
}
示例8: configure
import org.apache.commons.configuration2.Configuration; //导入依赖的package包/类
@Override
protected void configure() {
bind(ConfigurationProvider.class).to(ConfigurationProviderImpl.class).asEagerSingleton();
bind(Configuration.class).toProvider(ConfigurationProvider.class).asEagerSingleton();
bind(ImmutableConfiguration.class).to(Configuration.class).asEagerSingleton();
bind(PropertyController.class).to(PropertyManagerImpl.class).asEagerSingleton();
bind(PropertyManager.class).to(PropertyController.class).asEagerSingleton();
bind(ServiceFactory.class).to(ServiceFactoryImpl.class).asEagerSingleton();
bind(ExecutorFactory.class).to(ExecutorFactoryImpl.class).asEagerSingleton();
bind(Context.class).to(ContextImpl.class).asEagerSingleton();
bind(Estimator.class).to(EstimatorImpl.class).asEagerSingleton();
bind(Adviser.class).to(AdviserImpl.class).asEagerSingleton();
bind(Instructor.class).to(InstructorImpl.class).asEagerSingleton();
bind(Agent.class).to(AgentImpl.class).asEagerSingleton();
bind(Pipeline.class).to(PipelineImpl.class).asEagerSingleton();
bind(Trader.class).to(traderClass).asEagerSingleton();
bind(Cryptotrader.class).to(CryptotraderImpl.class);
}
示例9: setUp
import org.apache.commons.configuration2.Configuration; //导入依赖的package包/类
@BeforeMethod
public void setUp() throws Exception {
module = new TestModule();
accountService = module.getMock(AccountService.class);
marketService = module.getMock(MarketService.class);
orderService = module.getMock(OrderService.class);
realtimeService = module.getMock(RealtimeService.class);
when(module.getMock(Bitflyer4j.class).getAccountService()).thenReturn(accountService);
when(module.getMock(Bitflyer4j.class).getMarketService()).thenReturn(marketService);
when(module.getMock(Bitflyer4j.class).getOrderService()).thenReturn(orderService);
when(module.getMock(Bitflyer4j.class).getRealtimeService()).thenReturn(realtimeService);
target = new BitflyerContext(module.getMock(Bitflyer4j.class));
target.setConfiguration(module.getMock(Configuration.class));
target = spy(target);
}
示例10: testGet
import org.apache.commons.configuration2.Configuration; //导入依赖的package包/类
@Test
public void testGet() throws Exception {
// Proxy (Invoke to initialize delegate)
Configuration c = target.get();
String version = c.getString(KEY);
// Same proxy, same delegate.
assertSame(target.get(), c);
assertEquals(c.getString(KEY), version);
// Same proxy, new delegate.
target.clear();
assertSame(target.get(), c);
assertEquals(c.getString(KEY), version);
}
示例11: getName
import org.apache.commons.configuration2.Configuration; //导入依赖的package包/类
private static String getName(Configuration _config)
{
String result = "";
if (_config == null)
return result;
if (_config.getBoolean("wrapper.service", false))
result += "Service ";
String name = _config.getString("wrapper.console.title");
if (name == null)
name = _config.getString("wrapper.ntservice.name");
if (name == null)
name = _config.getString("wrapper.image");
if (name == null)
name = _config.getString("wrapper.groovy");
if (name == null)
name = _config.getString("wrapper.java.app.mainclass");
if (name == null)
name = _config.getString("wrapper.java.app.jar");
if (name == null)
name = "";
result += name;
return result;
}
示例12: doReconnect
import org.apache.commons.configuration2.Configuration; //导入依赖的package包/类
/**
* Do reconnect.
*/
private static void doReconnect()
{
prepareProperties();
Configuration localConf = new MapConfiguration(_properties);
YajswConfiguration conf = new YajswConfigurationImpl(localConf, true);
WrappedProcess w = WrappedProcessFactory.createProcess(conf);
System.out.println("************* RECONNECTING WRAPPER TO PID " + pid
+ " ***********************");
System.out.println();
if (w.reconnect(pid))
System.out.println("Connected to PID " + pid);
else
System.out.println("NOT connected to PID " + pid);
_exitOnTerminate = false;
}
示例13: getConfiguration
import org.apache.commons.configuration2.Configuration; //导入依赖的package包/类
public Configuration getConfiguration()
{
if (_config == null)
{
Map utils = new HashMap();
utils.put("util", new Utils(this));
try
{
VFSUtils.init();
}
catch (FileSystemException e)
{
e.printStackTrace();
}
_config = new YajswConfigurationImpl(_localConfiguration,
_useSystemProperties, utils);
}
return _config;
}
示例14: createGInterpolatornew
import org.apache.commons.configuration2.Configuration; //导入依赖的package包/类
private YajswConfigurationInterpolator createGInterpolatornew(Configuration conf, boolean b,
String[] object, Map utils)
{
YajswConfigurationInterpolator result = null;
try
{
Class clazz = conf
.getClass()
.getClassLoader()
.loadClass("org.rzo.yajsw.config.groovy.GInterpolator");
Constructor rc = clazz.getDeclaredConstructor(Configuration.class,
boolean.class, String[].class, Map.class);
result = (YajswConfigurationInterpolator) rc.newInstance(conf, b, object, utils);
}
catch (Exception e)
{
// e.printStackTrace();
log.warn("WARNING: could not load configuration groovy interpolator");
}
return result;
}
示例15: testOverride
import org.apache.commons.configuration2.Configuration; //导入依赖的package包/类
@Test
public void testOverride() {
Parameters params = new Parameters();
FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
.configure(params.properties()
.setFileName("file.properties"));
Configuration config = null;
try {
config = builder.getConfiguration();
config.setProperty("somekey", "somevalue");
builder.save();
} catch (ConfigurationException e) {
e.printStackTrace();
}
}