本文整理汇总了Java中org.aeonbits.owner.ConfigFactory类的典型用法代码示例。如果您正苦于以下问题:Java ConfigFactory类的具体用法?Java ConfigFactory怎么用?Java ConfigFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConfigFactory类属于org.aeonbits.owner包,在下文中一共展示了ConfigFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BabelConfig
import org.aeonbits.owner.ConfigFactory; //导入依赖的package包/类
/**
* Creates a config object from file in path or from default if fails to load file
*
* @param pathToConfig
*/
private BabelConfig(String pathToConfig) {
//if string null or empty, use or own configFromFile.properties.
if (pathToConfig == null) {
cfg = ConfigFactory.create(ConfigFromFile.class);
} else {
//get config.properties file from path
try {
Properties props = new Properties();
props.load(new FileInputStream(new File(pathToConfig)));
cfg = ConfigFactory.create(ConfigFromFile.class, props);
} catch (IOException e) {
cfg = ConfigFactory.create(ConfigFromFile.class);
}
}
}
示例2: start
import org.aeonbits.owner.ConfigFactory; //导入依赖的package包/类
@CommandRef(desc = "Start a new Appium session from ${user.home}/appium.txt file")
public void start() throws MalformedURLException, CommandsException {
try {
ConfigCapabilities config = ConfigFactory.create(ConfigCapabilities.class);
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(DEVICE_NAME, config.deviceName());
caps.setCapability(NEW_COMMAND_TIMEOUT, config.cmdTimeout());
caps.setCapability(APP, config.app());
setApp(config.app());
if (!config.udid().isEmpty()) {
caps.setCapability(UDID, config.udid());
setDeviceID(config.udid());
}
URL urlServer = new URL(config.appiumServer());
setPlatformName(config.platformName(), urlServer, caps);
} catch (Exception e) {
throw new RuntimeException(
format("An error has occurred: [%s] Please check the appium.txt file on: [%s]",
e.getMessage(), getProperty("user.home")));
}
}
示例3: create
import org.aeonbits.owner.ConfigFactory; //导入依赖的package包/类
public static DlCheckAgent create(Instrumentation inst, String args) {
String agentName = JAgentUtil.getImplTitle(DlCheckAgent.class);
String agentVersion = JAgentUtil.getImplVersion(DlCheckAgent.class);
Configuration cfg = ConfigFactory.create(Configuration.class, System.getProperties());
Log.Level logLevel;
try {
logLevel = Log.Level.valueOf(cfg.logLevel());
} catch (IllegalArgumentException e) {
System.err.println("Invalid log level: " + cfg.logLevel() + ", INFO used by default");
logLevel = Log.Level.INFO;
}
Log log = new Log(agentName, logLevel, cfg.logFile());
DlCheckAgent agent = new DlCheckAgent(inst, args, agentName, agentVersion, log);
agent.setRedefineClasses(cfg.redefine());
agent.setIsVerboseRedefinition(cfg.verboseRedifinition());
CachingClassFileTransformer transformer = new Transformer(cfg, log, agentVersion);
transformer.setCacheDir(cfg.cacheDir());
transformer.setDumpDir(cfg.dumpDir());
agent.addTransformer(transformer);
LocationManager.getInstance().init(cfg.cacheDir(), agentVersion);
PotentialDeadlockPublisher.init();
return agent;
}
示例4: create
import org.aeonbits.owner.ConfigFactory; //导入依赖的package包/类
public static SampleAgent create(Instrumentation inst, String agentArgs) {
String agentName = JAgentUtil.getImplTitle(SampleAgent.class);
String agentVersion = JAgentUtil.getImplVersion(SampleAgent.class);
Configuration cfg = ConfigFactory.create(Configuration.class, System.getProperties());
Log.Level logLevel;
try {
logLevel = Log.Level.valueOf(cfg.logLevel());
} catch (IllegalArgumentException e) {
System.err.println("Invalid log level: " + cfg.logLevel() + ", INFO used by default");
logLevel = Log.Level.INFO;
}
Log log = new Log(agentName, logLevel, cfg.logFile());
SampleAgent agent = new SampleAgent(inst, agentArgs, agentName, agentVersion, log);
agent.setRedefineClasses(cfg.redefine());
agent.setIsVerboseRedefinition(cfg.verboseRedifinition());
agent.addTransformer(new MethodDeleterTransformer(cfg.clazz(), cfg.method(), log));
return agent;
}
示例5: testOwnerAPI
import org.aeonbits.owner.ConfigFactory; //导入依赖的package包/类
@Test
public void testOwnerAPI() throws Exception
{
final Properties props = new Properties()
{
private static final long serialVersionUID = 1L;
{
setProperty("server.host.name", "localhost");
setProperty("server.http.port", "80");
}
};
final TestConfig cfg1 = ConfigFactory.create(TestConfig.class, props);
LOG.trace("Server " + cfg1.hostname() + ":" + cfg1.port()
+ " will run " + cfg1.maxThreads());
final TestConfig cfg2 = ConfigCache
.getOrCreate(TestConfig.class, props);
LOG.trace("Server " + cfg2.hostname() + ":" + cfg2.port()
+ " will run " + cfg2.maxThreads());
}
示例6: main
import org.aeonbits.owner.ConfigFactory; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
Thread back = new Thread(new MainBack());
back.start();
MainBack.PM.waitUntilProcessesLoaded();
cfg = ConfigFactory.create(ThisConfig.class);
try {
readFromConfig();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
createAndShowGUI();
setupTray();
}
示例7: main
import org.aeonbits.owner.ConfigFactory; //导入依赖的package包/类
public static void main(String[] args) throws Exception{
//使用owner管理项目配置 @see owner-doc
ServerConf cfg = ConfigFactory.create(ServerConf.class);
//初始化请求分发路由配置
ActionDispatcher dispatcher = new ActionDispatcher();
dispatcher.init(cfg.routerConfigPath());
//启动 netty 服务
new HttpServer(cfg.port()).run();
}
示例8: beforeTest
import org.aeonbits.owner.ConfigFactory; //导入依赖的package包/类
@Before
public void beforeTest()
{
cfg = ConfigFactory.create(TestConfig.class, System.getenv(), System.getProperties());
restTemplate = Mockito.mock(RestTemplate.class);
assertNotNull(cfg.authToken());
}
示例9: beforeTest
import org.aeonbits.owner.ConfigFactory; //导入依赖的package包/类
@Before
public void beforeTest()
{
cfg = ConfigFactory.create(TestConfig.class, System.getenv(), System.getProperties());
restTemplate = Mockito.mock(RestTemplate.class);
String authTokenMock = "authMockTockenString";
translationAPI = new DefaultPhraseTranslationAPI(restTemplate, authTokenMock);
projectId = "SomeProjectId";
localeId = "SomeLocaleId";
}
示例10: getMongoClient
import org.aeonbits.owner.ConfigFactory; //导入依赖的package包/类
public synchronized SharedMongoClient getMongoClient() {
if(sharedMongoClient == null) {
logger.debug("Bootstrapping a new MongoClient Instance");
mongoConfiguration = ConfigFactory.create(MongoConfiguration.class);
MongoClientOptions clientOptions = mongoClientOptionsFromConfiguration();
ServerAddress serverAddress = buildAddressFromConfiguration();
MongoClient mongoClient = new MongoClient(serverAddress, clientOptions);
sharedMongoClient = new SharedMongoClient(mongoClient, mongoConfiguration);
}
return sharedMongoClient;
}
示例11: getConfiguration
import org.aeonbits.owner.ConfigFactory; //导入依赖的package包/类
@Provides
public EndPointHealthConfiguration getConfiguration() {
return ConfigFactory
.create(EndPointHealthConfiguration.class, System.getProperties());
}
示例12: loadConfiguration
import org.aeonbits.owner.ConfigFactory; //导入依赖的package包/类
private boolean loadConfiguration() {
cfg = ConfigFactory.create(ThisConfig.class);
return true;
}
示例13: loadConfiguration
import org.aeonbits.owner.ConfigFactory; //导入依赖的package包/类
private boolean loadConfiguration() {
cfg = ConfigFactory.create(ThisConfig.class);
return true;
}
示例14: main
import org.aeonbits.owner.ConfigFactory; //导入依赖的package包/类
public static void main(String[] args) {
TestConfig cfg = ConfigFactory.create(TestConfig.class);
System.out.println("Server " + cfg.hostname() + ":" + cfg.port() + " will run " + cfg.maxThreads());
}
示例15: conf
import org.aeonbits.owner.ConfigFactory; //导入依赖的package包/类
public static VideoConfiguration conf() {
ConfigFactory.setProperty("os.type", getOsType());
return ConfigFactory.create(VideoConfiguration.class, System.getProperties());
}