本文整理汇总了Java中org.apache.commons.configuration.ConfigurationConverter类的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationConverter类的具体用法?Java ConfigurationConverter怎么用?Java ConfigurationConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConfigurationConverter类属于org.apache.commons.configuration包,在下文中一共展示了ConfigurationConverter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: withConfiguration
import org.apache.commons.configuration.ConfigurationConverter; //导入依赖的package包/类
public Builder withConfiguration(Configuration config) {
ConfigurationConverter.getMap(config.subset("embeddedClass"))
.forEach((k, v) -> addEmbeddedClass(k.toString(), v.toString()));
ConfigurationConverter.getMap(config.subset("class"))
.forEach((k, v) -> addClass(k.toString(), v.toString()));
ConfigurationConverter.getMap(config.subset("dataProperties"))
.forEach((k, v) -> addDataProperty(k.toString(), v.toString()));
ConfigurationConverter.getMap(config.subset("objectProperties"))
.forEach((k, v) -> addObjectProperty(k.toString(), v.toString()));
if (config.containsKey("partitionStrategy.partitionKey")) {
partitionStrategy(PartitionStrategy.create(config.subset("partitionStrategy")));
}
return metadataLabel(config.getString("metadataLabel", null))
.rootLabel(config.getString("rootLabel", null))
.identifierKey(config.getString("identifierKey", null))
.unknownKey(config.getString("unknownKey", null))
.implicitKey(config.getString("implicitKey", null));
}
示例2: loadJobConfig
import org.apache.commons.configuration.ConfigurationConverter; //导入依赖的package包/类
/**
* Load a given job configuration file.
*
* @param properties Gobblin framework configuration properties
* @param jobConfigFile job configuration file to be loaded
* @param jobConfigFileDir root job configuration file directory
* @return a job configuration in the form of {@link java.util.Properties}
*/
public static Properties loadJobConfig(Properties properties, File jobConfigFile, File jobConfigFileDir)
throws ConfigurationException, IOException {
List<Properties> commonPropsList = Lists.newArrayList();
getCommonProperties(commonPropsList, jobConfigFileDir, jobConfigFile.getParentFile());
// Add the framework configuration properties to the end
commonPropsList.add(properties);
Properties jobProps = new Properties();
// Include common properties in reverse order
for (Properties commonProps : Lists.reverse(commonPropsList)) {
jobProps.putAll(commonProps);
}
// Then load the job configuration properties defined in the job configuration file
jobProps.putAll(ConfigurationConverter.getProperties(new PropertiesConfiguration(jobConfigFile)));
jobProps.setProperty(ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY, jobConfigFile.getAbsolutePath());
return jobProps;
}
示例3: getCommonProperties
import org.apache.commons.configuration.ConfigurationConverter; //导入依赖的package包/类
private static void getCommonProperties(List<Properties> commonPropsList, File jobConfigFileDir, File dir)
throws ConfigurationException, IOException {
// Make sure the given starting directory is under the job configuration file directory
Preconditions.checkArgument(dir.getCanonicalPath().startsWith(jobConfigFileDir.getCanonicalPath()),
String.format("%s is not an ancestor directory of %s", jobConfigFileDir, dir));
// Traversal backward until the parent of the root job configuration file directory is reached
while (!dir.equals(jobConfigFileDir.getParentFile())) {
// Get the properties file that ends with .properties if any
String[] propertiesFiles = dir.list(PROPERTIES_FILE_FILTER);
if (propertiesFiles != null && propertiesFiles.length > 0) {
// There should be a single properties file in each directory (or sub directory)
if (propertiesFiles.length != 1) {
throw new RuntimeException("Found more than one .properties file in directory: " + dir);
}
commonPropsList.add(
ConfigurationConverter.getProperties(new PropertiesConfiguration(new File(dir, propertiesFiles[0]))));
}
dir = dir.getParentFile();
}
}
示例4: main
import org.apache.commons.configuration.ConfigurationConverter; //导入依赖的package包/类
public static void main(String[] args)
throws Exception {
if (args.length < 1 || args.length > 2) {
System.err.println(
"Usage: SchedulerDaemon <default configuration properties file> [custom configuration properties file]");
System.exit(1);
}
// Load default framework configuration properties
Properties defaultProperties = ConfigurationConverter.getProperties(new PropertiesConfiguration(args[0]));
// Load custom framework configuration properties (if any)
Properties customProperties = new Properties();
if (args.length == 2) {
customProperties.putAll(ConfigurationConverter.getProperties(new PropertiesConfiguration(args[1])));
}
// Start the scheduler daemon
new SchedulerDaemon(defaultProperties, customProperties).start();
}
示例5: databasePropertySourcesPlaceholderConfigurer
import org.apache.commons.configuration.ConfigurationConverter; //导入依赖的package包/类
/**
* The database supplied property sources placeholder configurer that allows access to externalized properties from a database. This method also adds a new
* property source that contains the database properties to the environment.
*
* @return the property sources placeholder configurer.
*/
@Bean
public static PropertySourcesPlaceholderConfigurer databasePropertySourcesPlaceholderConfigurer()
{
// Get the configurable environment and add a new property source to it that contains the database properties.
// That way, the properties can be accessed via the environment or via an injected @Value annotation.
// We are adding this property source last so other property sources (e.g. system properties, environment variables) can be used
// to override the database properties.
Environment environment = ApplicationContextHolder.getApplicationContext().getEnvironment();
if (environment instanceof ConfigurableEnvironment)
{
ConfigurableEnvironment configurableEnvironment = (ConfigurableEnvironment) environment;
ReloadablePropertySource reloadablePropertySource =
new ReloadablePropertySource(ReloadablePropertySource.class.getName(), ConfigurationConverter.getProperties(getPropertyDatabaseConfiguration()),
getPropertyDatabaseConfiguration());
configurableEnvironment.getPropertySources().addLast(reloadablePropertySource);
}
return new PropertySourcesPlaceholderConfigurer();
}
示例6: setPamProperties
import org.apache.commons.configuration.ConfigurationConverter; //导入依赖的package包/类
private void setPamProperties() {
try {
this.groupsFromUGI = ApplicationProperties.get().getBoolean("atlas.authentication.method.pam.ugi-groups", true);
Properties properties = ConfigurationConverter.getProperties(ApplicationProperties.get()
.subset("atlas.authentication.method.pam"));
for (String key : properties.stringPropertyNames()) {
String value = properties.getProperty(key);
options.put(key, value);
}
if (!options.containsKey("service")) {
options.put("service", "atlas-login");
}
} catch (Exception e) {
LOG.error("Exception while setLdapProperties", e);
}
}
示例7: getSail
import org.apache.commons.configuration.ConfigurationConverter; //导入依赖的package包/类
@Override
public synchronized Sail getSail() throws SailException {
if (sail == null) {
try {
config = PlatformConfigHelper.getConfig();
Properties properties = ConfigurationConverter.getProperties(loadProperties());
// BigdataSailRepository repository = new BigdataSailRepository(new com.bigdata.rdf.sail.BigdataSail(properties));
// repo = new BigdataSail(repository);
sail = new SimpleTypeInferencingSail(
// new SmartSailWrapper(
new BigdataSail(properties));
// sail.setPipelineTypes(Arrays.asList(
// "getReadOnlyConnection",
// "getReadWriteConnection",
// "getUnisolatedConnection"));
} catch (Exception e) {
throw new SailException(e);
}
}
return sail;
}
示例8: loadJavaPropsWithFallback
import org.apache.commons.configuration.ConfigurationConverter; //导入依赖的package包/类
/**
* Load a {@link Properties} compatible path using fallback as fallback.
* @return The {@link Config} in path with fallback as fallback.
* @throws IOException
*/
private Config loadJavaPropsWithFallback(Path propertiesPath, Config fallback) throws IOException {
PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration();
try (InputStreamReader inputStreamReader = new InputStreamReader(this.fs.open(propertiesPath),
Charsets.UTF_8)) {
propertiesConfiguration.setDelimiterParsingDisabled(ConfigUtils.getBoolean(fallback,
PROPERTY_DELIMITER_PARSING_ENABLED_KEY, DEFAULT_PROPERTY_DELIMITER_PARSING_ENABLED_KEY));
propertiesConfiguration.load(inputStreamReader);
Config configFromProps =
ConfigUtils.propertiesToConfig(ConfigurationConverter.getProperties(propertiesConfiguration));
return ConfigFactory.parseMap(ImmutableMap.of(ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY,
PathUtils.getPathWithoutSchemeAndAuthority(propertiesPath).toString()))
.withFallback(configFromProps)
.withFallback(fallback);
} catch (ConfigurationException ce) {
throw new IOException(ce);
}
}
示例9: main
import org.apache.commons.configuration.ConfigurationConverter; //导入依赖的package包/类
public static void main(String[] args)
throws Exception {
if (args.length < 1 || args.length > 2) {
System.err.println(
"Usage: SchedulerDaemon <default configuration properties file> [custom configuration properties file]");
System.exit(1);
}
// Load default framework configuration properties
Properties defaultProperties = ConfigurationConverter.getProperties(new PropertiesConfiguration(args[0]));
// Load custom framework configuration properties (if any)
Properties customProperties = new Properties();
if (args.length == 2) {
customProperties.putAll(ConfigurationConverter.getProperties(new PropertiesConfiguration(args[1])));
}
log.debug("Scheduler Daemon::main starting with defaultProperties: {}, customProperties: {}", defaultProperties,
customProperties);
// Start the scheduler daemon
new SchedulerDaemon(defaultProperties, customProperties).start();
}
示例10: createFromProperties
import org.apache.commons.configuration.ConfigurationConverter; //导入依赖的package包/类
public static DbDataComparisonConfig createFromProperties(final Configuration config) {
Properties propsView = ConfigurationConverter.getProperties(config); // config.getString() automatically parses
// for commas...would like to avoid this
DbDataComparisonConfig compConfig = new DbDataComparisonConfig();
compConfig.setInputTables(Lists.mutable.with(propsView.getProperty("tables.include").split(",")));
compConfig.setExcludedTables(Lists.mutable.with(propsView.getProperty("tables.exclude").split(",")).toSet());
String comparisonsStr = propsView.getProperty("comparisons");
MutableList<Pair<String, String>> compCmdPairs = Lists.mutable.empty();
MutableSet<String> dsNames = UnifiedSet.newSet();
for (String compPairStr : comparisonsStr.split(";")) {
String[] pairParts = compPairStr.split(",");
compCmdPairs.add(Tuples.pair(pairParts[0], pairParts[1]));
// note - if I knew where the Pair.TO_ONE TO_TWO selectors were, I'd use those
dsNames.add(pairParts[0]);
dsNames.add(pairParts[1]);
}
compConfig.setComparisonCommandNamePairs(compCmdPairs);
MutableList<DbDataSource> dbDataSources = dsNames.toList().collect(new Function<String, DbDataSource>() {
@Override
public DbDataSource valueOf(String dsName) {
Configuration dsConfig = config.subset(dsName);
DbDataSource dbDataSource = new DbDataSource();
dbDataSource.setName(dsName);
dbDataSource.setUrl(dsConfig.getString("url"));
dbDataSource.setSchema(dsConfig.getString("schema"));
dbDataSource.setUsername(dsConfig.getString("username"));
dbDataSource.setPassword(dsConfig.getString("password"));
dbDataSource.setDriverClassName(dsConfig.getString("driverClass"));
return dbDataSource;
}
});
compConfig.setDbDataSources(dbDataSources);
return compConfig;
}
示例11: exportSQLFileFromDatabase
import org.apache.commons.configuration.ConfigurationConverter; //导入依赖的package包/类
@Override
public File exportSQLFileFromDatabase(int dbId) throws Exception {
OrdsPhysicalDatabase database = this.getPhysicalDatabaseFromID(dbId);
DatabaseServer server = ServerConfigurationService.Factory.getInstance().getDatabaseServer(database.getDatabaseServer());
// create the file
String databaseName = database.getDbConsumedName();
File file = File.createTempFile("dump_" + databaseName, "sql");
Properties properties = ConfigurationConverter.getProperties(MetaConfiguration.getConfiguration());
String postgres_bin = "";
if ( properties.containsKey("ords.postgresql.bin.path")) {
postgres_bin = properties.getProperty("ords.postgresql.bin.path");
}
ProcessBuilder processBuilder = new ProcessBuilder(postgres_bin+"pg_dump",
"-f",
file.toString(),
"-v", "-o", "-h",
database.getDatabaseServer(),
"-U",
server.getUsername(), database.getDbConsumedName());
processBuilder.environment().put("PGPASSWORD", server.getPassword());
Process process = processBuilder.start();
try {
InputStream is = process.getInputStream();
InputStreamReader reader = new InputStreamReader(is);
BufferedReader buffer = new BufferedReader(reader);
String line;
while ((line = buffer.readLine()) != null ) {
System.out.println(line);
if (log.isDebugEnabled()) {
log.debug(line);
}
}
}
catch ( Exception e ) {
log.error("ERROR", e );
}
return file;
}
示例12: Neo4jGraph
import org.apache.commons.configuration.ConfigurationConverter; //导入依赖的package包/类
protected Neo4jGraph(final Configuration configuration) {
this.configuration.copy(configuration);
final String directory = this.configuration.getString(CONFIG_DIRECTORY);
final Map neo4jSpecificConfig = ConfigurationConverter.getMap(this.configuration.subset(CONFIG_CONF));
this.baseGraph = Neo4jFactory.Builder.open(directory, neo4jSpecificConfig);
this.initialize(this.baseGraph, configuration);
}
示例13: parseArgs
import org.apache.commons.configuration.ConfigurationConverter; //导入依赖的package包/类
/**
* Parse command line arguments and return a {@link java.util.Properties} object for the gobblin job found.
* @param caller Class of the calling main method. Used for error logs.
* @param args Command line arguments.
* @return Instance of {@link Properties} for the Gobblin job to run.
* @throws IOException
*/
public static Properties parseArgs(Class<?> caller, String[] args) throws IOException {
try {
// Parse command-line options
CommandLine cmd = new DefaultParser().parse(options(), args);
if (cmd.hasOption(HELP_OPTION.getOpt())) {
printUsage(caller);
System.exit(0);
}
if (!cmd.hasOption(SYS_CONFIG_OPTION.getLongOpt()) || !cmd.hasOption(JOB_CONFIG_OPTION.getLongOpt())) {
printUsage(caller);
System.exit(1);
}
// Load system and job configuration properties
Properties sysConfig = ConfigurationConverter
.getProperties(new PropertiesConfiguration(cmd.getOptionValue(SYS_CONFIG_OPTION.getLongOpt())));
Properties jobConfig = ConfigurationConverter
.getProperties(new PropertiesConfiguration(cmd.getOptionValue(JOB_CONFIG_OPTION.getLongOpt())));
return JobConfigurationUtils.combineSysAndJobProperties(sysConfig, jobConfig);
} catch (ParseException pe) {
throw new IOException(pe);
} catch (ConfigurationException ce) {
throw new IOException(ce);
}
}
示例14: setADProperties
import org.apache.commons.configuration.ConfigurationConverter; //导入依赖的package包/类
private void setADProperties() {
try {
Configuration configuration = ApplicationProperties.get();
Properties properties = ConfigurationConverter.getProperties(configuration.subset("atlas.authentication.method.ldap.ad"));
this.adDomain = properties.getProperty("domain");
this.adURL = properties.getProperty("url");
this.adBindDN = properties.getProperty("bind.dn");
this.adBindPassword = properties.getProperty("bind.password");
this.adUserSearchFilter = properties.getProperty("user.searchfilter");
this.adBase = properties.getProperty("base.dn");
this.adReferral = properties.getProperty("referral");
this.adDefaultRole = properties.getProperty("default.role");
this.groupsFromUGI = configuration.getBoolean("atlas.authentication.method.ldap.ugi-groups", true);
if(LOG.isDebugEnabled()) {
LOG.debug("AtlasADAuthenticationProvider{" +
"adURL='" + adURL + '\'' +
", adDomain='" + adDomain + '\'' +
", adBindDN='" + adBindDN + '\'' +
", adUserSearchFilter='" + adUserSearchFilter + '\'' +
", adBase='" + adBase + '\'' +
", adReferral='" + adReferral + '\'' +
", adDefaultRole='" + adDefaultRole + '\'' +
", groupsFromUGI=" + groupsFromUGI +
'}');
}
} catch (Exception e) {
LOG.error("Exception while setADProperties", e);
}
}
示例15: setLdapProperties
import org.apache.commons.configuration.ConfigurationConverter; //导入依赖的package包/类
private void setLdapProperties() {
try {
Configuration configuration = ApplicationProperties.get();
Properties properties = ConfigurationConverter.getProperties(configuration.subset("atlas.authentication.method.ldap"));
ldapURL = properties.getProperty("url");
ldapUserDNPattern = properties.getProperty("userDNpattern");
ldapGroupSearchBase = properties.getProperty("groupSearchBase");
ldapGroupSearchFilter = properties.getProperty("groupSearchFilter");
ldapGroupRoleAttribute = properties.getProperty("groupRoleAttribute");
ldapBindDN = properties.getProperty("bind.dn");
ldapBindPassword = properties.getProperty("bind.password");
ldapDefaultRole = properties.getProperty("default.role");
ldapUserSearchFilter = properties.getProperty("user.searchfilter");
ldapReferral = properties.getProperty("referral");
ldapBase = properties.getProperty("base.dn");
groupsFromUGI = configuration.getBoolean("atlas.authentication.method.ldap.ugi-groups", true);
if(LOG.isDebugEnabled()) {
LOG.debug("AtlasLdapAuthenticationProvider{" +
"ldapURL='" + ldapURL + '\'' +
", ldapUserDNPattern='" + ldapUserDNPattern + '\'' +
", ldapGroupSearchBase='" + ldapGroupSearchBase + '\'' +
", ldapGroupSearchFilter='" + ldapGroupSearchFilter + '\'' +
", ldapGroupRoleAttribute='" + ldapGroupRoleAttribute + '\'' +
", ldapBindDN='" + ldapBindDN + '\'' +
", ldapDefaultRole='" + ldapDefaultRole + '\'' +
", ldapUserSearchFilter='" + ldapUserSearchFilter + '\'' +
", ldapReferral='" + ldapReferral + '\'' +
", ldapBase='" + ldapBase + '\'' +
", groupsFromUGI=" + groupsFromUGI +
'}');
}
} catch (Exception e) {
LOG.error("Exception while setLdapProperties", e);
}
}