List of usage examples for org.apache.commons.configuration PropertiesConfiguration addProperty
public void addProperty(String key, Object value)
From source file:cross.io.PropertyFileGenerator.java
/** * Creates a property object for the given class, containing those fields, * which are annotated by {/*from w w w . j a v a 2 s . c o m*/ * * @return * @Configurable}. * @param c */ public static PropertiesConfiguration createProperties(Class<?> c) { Collection<String> keys = AnnotationInspector.getRequiredConfigKeys(c); if (!keys.isEmpty()) { PropertiesConfiguration pc = new PropertiesConfiguration(); for (String key : keys) { pc.addProperty(key, AnnotationInspector.getDefaultValueFor(c, key)); } return pc; } else { LoggerFactory.getLogger(PropertyFileGenerator.class) .info("Could not find annotated configuration keys for class {}!", c.getName()); } return new PropertiesConfiguration(); }
From source file:net.orpiske.ssps.common.repository.RepositorySettings.java
private static void addUserConfig(final RepositoryInfo repositoryInfo) throws RepositorySetupException { String repositoryPath = RepositoryUtils.getUserRepository(); String path = repositoryPath + File.separator + repositoryInfo.getName() + File.separator + "user.conf"; File file = new File(path); if (!file.exists()) { try {//from w ww .j a v a2 s. co m file.createNewFile(); } catch (IOException e) { throw new RepositorySetupException("Unable to create user configuration " + "file", e); } } else { throw new RepositorySetupException("This user already exists"); } PropertiesConfiguration userConfig; try { userConfig = new PropertiesConfiguration(path); userConfig.addProperty(repositoryInfo.getName() + ".auth.user", repositoryInfo.getUserName()); userConfig.addProperty(repositoryInfo.getName() + ".auth.password", repositoryInfo.getPassword()); userConfig.save(); } catch (ConfigurationException e) { throw new RepositorySetupException( "Unable to save user configuration to " + path + ":" + e.getMessage(), e); } }
From source file:com.linkedin.pinot.queries.TestingServerPropertiesBuilder.java
public PropertiesConfiguration build() throws IOException { final File file = new File("/tmp/" + TestingServerPropertiesBuilder.class.toString()); if (file.exists()) { FileUtils.deleteDirectory(file); }/*from w ww . ja v a 2s .c om*/ file.mkdir(); final File bootsDir = new File(file, "bootstrap"); final File dataDir = new File(file, "data"); bootsDir.mkdir(); dataDir.mkdir(); final PropertiesConfiguration config = new PropertiesConfiguration(); config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, INSTANCE_PREFIC, "id"), "0"); config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, INSTANCE_PREFIC, "bootstrap.segment.dir"), bootsDir.getAbsolutePath()); config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, INSTANCE_PREFIC, "dataDir"), dataDir.getAbsolutePath()); config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, INSTANCE_PREFIC, "bootstrap.segment.dir"), "0"); config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, INSTANCE_PREFIC, "data.manager.class"), "com.linkedin.pinot.core.data.manager.InstanceDataManager"); config.addProperty( StringUtil.join(".", PINOT_SERVER_PREFIX, INSTANCE_PREFIC, "segment.metadata.loader.class"), "com.linkedin.pinot.core.indexsegment.columnar.ColumnarSegmentMetadataLoader"); config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, INSTANCE_PREFIC, "tableName"), StringUtils.join(tableNames, ",")); for (final String table : tableNames) { config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, INSTANCE_PREFIC, table, "dataManagerType"), "offline"); config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, INSTANCE_PREFIC, table, "readMode"), "heap"); config.addProperty( StringUtil.join(".", PINOT_SERVER_PREFIX, INSTANCE_PREFIC, table, "numQueryExecutorThreads"), "50"); } config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, EXECUTOR_PREFIX, "class"), "com.linkedin.pinot.core.query.executor.ServerQueryExecutor"); config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, EXECUTOR_PREFIX, "timeout"), "150000"); config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, "requestHandlerFactory.class"), "com.linkedin.pinot.server.request.SimpleRequestHandlerFactory"); config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, "netty.port"), "8882"); config.setDelimiterParsingDisabled(true); final Iterator<String> keys = config.getKeys(); while (keys.hasNext()) { final String key = keys.next(); System.out.println(key + " : " + config.getProperty(key)); } return config; }
From source file:fr.jetoile.hadoopunit.HadoopBootstrapRemoteStarter.java
private void editHadoopUnitConfFile() { Path hadoopPropertiesPath = Paths.get(hadoopUnitPath, "conf", "hadoop.properties"); Path hadoopPropertiesBackupPath = Paths.get(hadoopUnitPath, "conf", "hadoop.properties.old"); if (hadoopPropertiesBackupPath.toFile().exists() && hadoopPropertiesBackupPath.toFile().canWrite()) { hadoopPropertiesBackupPath.toFile().delete(); }/*from ww w . j a v a 2s. c o m*/ hadoopPropertiesPath.toFile().renameTo(hadoopPropertiesBackupPath.toFile()); PropertiesConfiguration configuration = new PropertiesConfiguration(); values.forEach(v -> configuration.addProperty(v.toLowerCase(), "true")); try { configuration.save(new FileWriter(hadoopPropertiesPath.toFile())); } catch (ConfigurationException | IOException e) { getLog().error("unable to find or modifying hadoop.properties. Check user rights", e); } }
From source file:com.github.nethad.clustermeister.provisioning.dependencymanager.DependencyConfigurationUtilTest.java
@Test public void testPreloadMultipleArtifacts() throws DependencyResolutionException { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.addProperty(DependencyConfigurationUtil.PRELOAD_ARTIFACTS, EXAMPLE_APP_COORDS); configuration.addProperty(DependencyConfigurationUtil.PRELOAD_ARTIFACTS, EXAMPLE_APP2_COORDS); DependencyConfigurationUtil.getConfiguredDependencies(configuration); verify(mavenRepositorySystem, times(1)).resolveDependencies(EXAMPLE_APP_COORDS); verify(mavenRepositorySystem, times(1)).resolveDependencies(EXAMPLE_APP2_COORDS); }
From source file:com.github.nethad.clustermeister.provisioning.dependencymanager.DependencyConfigurationUtilTest.java
@Test public void testExclusion() throws DependencyResolutionException { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.addProperty(DependencyConfigurationUtil.PRELOAD_EXCLUDES, EXAMPLE_APP_COORDS); configuration.addProperty(DependencyConfigurationUtil.PRELOAD_EXCLUDES, EXAMPLE_APP2_COORDS); DependencyConfigurationUtil.getConfiguredDependencies(configuration); verify(mavenRepositorySystem).addGlobalExclusion(eq(EXAMPLE_APP_COORDS)); verify(mavenRepositorySystem).addGlobalExclusion(eq(EXAMPLE_APP2_COORDS)); }
From source file:com.pinterest.secor.common.FileRegistryTest.java
public void setUp() throws Exception { super.setUp(); PropertiesConfiguration properties = new PropertiesConfiguration(); properties.addProperty("secor.file.reader.writer.factory", "com.pinterest.secor.io.impl.SequenceFileReaderWriterFactory"); SecorConfig secorConfig = new SecorConfig(properties); mRegistry = new FileRegistry(secorConfig); mLogFilePath = new LogFilePath("/some_parent_dir", PATH); mTopicPartition = new TopicPartition("some_topic", 0); mLogFilePathGz = new LogFilePath("/some_parent_dir", PATH_GZ); }
From source file:com.github.nethad.clustermeister.provisioning.dependencymanager.DependencyConfigurationUtilTest.java
@Test public void testPreloadArtifact() throws DependencyResolutionException { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.addProperty(DependencyConfigurationUtil.PRELOAD_ARTIFACTS, EXAMPLE_APP_COORDS); DependencyConfigurationUtil.getConfiguredDependencies(configuration); ArgumentCaptor<Artifact> artifact = ArgumentCaptor.forClass(Artifact.class); verify(mavenRepositorySystem, times(1)).resolveDependencies(artifact.capture(), argThat(isEmptyList()), argThat(isEmptyList()));//from w w w.j av a2s . c om assertThat(artifact.getValue().getGroupId(), is(equalTo(EXAMPLE_APP_GROUPID))); assertThat(artifact.getValue().getArtifactId(), is(equalTo(EXAMPLE_APP_ARTIFACTID))); assertThat(artifact.getValue().getVersion(), is(equalTo(EXAMPLE_APP_VERSION))); }
From source file:com.pinterest.secor.io.FileReaderWriterFactoryTest.java
private void setupSequenceFileReaderConfig() { PropertiesConfiguration properties = new PropertiesConfiguration(); properties.addProperty("secor.file.reader.writer.factory", "com.pinterest.secor.io.impl.SequenceFileReaderWriterFactory"); mConfig = new SecorConfig(properties); }
From source file:com.pinterest.secor.io.FileReaderWriterFactoryTest.java
private void setupDelimitedTextFileWriterConfig() { PropertiesConfiguration properties = new PropertiesConfiguration(); properties.addProperty("secor.file.reader.writer.factory", "com.pinterest.secor.io.impl.DelimitedTextFileReaderWriterFactory"); mConfig = new SecorConfig(properties); }