本文整理了Java中com.flipkart.polyguice.config.YamlConfiguration.subset()
方法的一些代码示例,展示了YamlConfiguration.subset()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlConfiguration.subset()
方法的具体详情如下:
包路径:com.flipkart.polyguice.config.YamlConfiguration
类名称:YamlConfiguration
方法名:subset
暂无
代码示例来源:origin: flipkart-incubator/flux
/**
* Creates hibernate configuration from the configuration yaml properties.
* Since the yaml properties are already flattened in input param <code>yamlConfiguration</code>
* the method loops over them to selectively pick Hibernate specific properties.
*/
@Provides
@Singleton
@Named("schedulerHibernateConfiguration")
public Configuration getConfiguration(YamlConfiguration yamlConfiguration) {
Configuration configuration = new Configuration();
addAnnotatedClassesAndTypes(configuration);
org.apache.commons.configuration.Configuration hibernateConfig = yamlConfiguration.subset(FLUX_SCHEDULER_HIBERNATE_CONFIG_NAME_SPACE);
Iterator<String> propertyKeys = hibernateConfig.getKeys();
Properties configProperties = new Properties();
while (propertyKeys.hasNext()) {
String propertyKey = propertyKeys.next();
Object propertyValue = hibernateConfig.getProperty(propertyKey);
configProperties.put(propertyKey, propertyValue);
}
configuration.addProperties(configProperties);
return configuration;
}
代码示例来源:origin: flipkart-incubator/flux
public void migrate(String dbName) {
try {
Configuration configuration = yamlConfiguration.subset(dbName + ".Hibernate");
Properties properties = new Properties();
properties.put("user", configuration.getProperty("hibernate.connection.username"));
properties.put("password", configuration.getProperty("hibernate.connection.password"));
Class.forName("com.mysql.jdbc.Driver").newInstance();
String url = (String) configuration.getProperty("hibernate.connection.url");
java.sql.Connection connection = DriverManager.getConnection(url, properties);
Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
ClassLoader classLoader = getClass().getClassLoader();
File file = new File(classLoader.getResource(dbName + "/migrations.xml").getFile());
Liquibase liquibase = new Liquibase(file.getCanonicalPath(), new FileSystemResourceAccessor(), database);
liquibase.update(new Contexts());
} catch (Exception e) {
System.err.println("Unable to perform database migration.");
e.printStackTrace();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!