Java Code Examples for org.apache.commons.configuration.PropertiesConfiguration#copy()
The following examples show how to use
org.apache.commons.configuration.PropertiesConfiguration#copy() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseSecurityTest.java From atlas with Apache License 2.0 | 6 votes |
public static String writeConfiguration(final PropertiesConfiguration configuration) throws Exception { String confLocation = System.getProperty("atlas.conf"); URL url; if (confLocation == null) { url = BaseSecurityTest.class.getResource("/" + ApplicationProperties.APPLICATION_PROPERTIES); } else { url = new File(confLocation, ApplicationProperties.APPLICATION_PROPERTIES).toURI().toURL(); } PropertiesConfiguration configuredProperties = new PropertiesConfiguration(); configuredProperties.load(url); configuredProperties.copy(configuration); String persistDir = TestUtils.getTempDirectory(); configuredProperties.setProperty("atlas.authentication.method.file", "true"); configuredProperties.setProperty("atlas.authentication.method.file.filename", persistDir + "/users-credentials"); configuredProperties.setProperty("atlas.auth.policy.file",persistDir + "/policy-store.txt" ); TestUtils.writeConfiguration(configuredProperties, persistDir + File.separator + ApplicationProperties.APPLICATION_PROPERTIES); setupUserCredential(persistDir); setUpPolicyStore(persistDir); ApplicationProperties.forceReload(); return persistDir; }
Example 2
Source File: BaseSecurityTest.java From incubator-atlas with Apache License 2.0 | 6 votes |
public static String writeConfiguration(final PropertiesConfiguration configuration) throws Exception { String confLocation = System.getProperty("atlas.conf"); URL url; if (confLocation == null) { url = BaseSecurityTest.class.getResource("/" + ApplicationProperties.APPLICATION_PROPERTIES); } else { url = new File(confLocation, ApplicationProperties.APPLICATION_PROPERTIES).toURI().toURL(); } PropertiesConfiguration configuredProperties = new PropertiesConfiguration(); configuredProperties.load(url); configuredProperties.copy(configuration); String persistDir = TestUtils.getTempDirectory(); configuredProperties.setProperty("atlas.authentication.method.file", "true"); configuredProperties.setProperty("atlas.authentication.method.file.filename", persistDir + "/users-credentials"); configuredProperties.setProperty("atlas.auth.policy.file",persistDir + "/policy-store.txt" ); TestUtils.writeConfiguration(configuredProperties, persistDir + File.separator + ApplicationProperties.APPLICATION_PROPERTIES); setupUserCredential(persistDir); setUpPolicyStore(persistDir); ApplicationProperties.forceReload(); return persistDir; }
Example 3
Source File: MetricsSystemImpl.java From hadoop with Apache License 2.0 | 5 votes |
@Override public synchronized String currentConfig() { PropertiesConfiguration saver = new PropertiesConfiguration(); StringWriter writer = new StringWriter(); saver.copy(config); try { saver.save(writer); } catch (Exception e) { throw new MetricsConfigException("Error stringify config", e); } return writer.toString(); }
Example 4
Source File: MetricsConfig.java From hadoop with Apache License 2.0 | 5 votes |
static String toString(Configuration c) { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); try { PrintStream ps = new PrintStream(buffer, false, "UTF-8"); PropertiesConfiguration tmp = new PropertiesConfiguration(); tmp.copy(c); tmp.save(ps); return buffer.toString("UTF-8"); } catch (Exception e) { throw new MetricsConfigException(e); } }
Example 5
Source File: ConfigUtil.java From hadoop with Apache License 2.0 | 5 votes |
static void dump(String header, Configuration c, PrintStream out) { PropertiesConfiguration p = new PropertiesConfiguration(); p.copy(c); if (header != null) { out.println(header); } try { p.save(out); } catch (Exception e) { throw new RuntimeException("Error saving config", e); } }
Example 6
Source File: MetricsSystemImpl.java From big-c with Apache License 2.0 | 5 votes |
@Override public synchronized String currentConfig() { PropertiesConfiguration saver = new PropertiesConfiguration(); StringWriter writer = new StringWriter(); saver.copy(config); try { saver.save(writer); } catch (Exception e) { throw new MetricsConfigException("Error stringify config", e); } return writer.toString(); }
Example 7
Source File: MetricsConfig.java From big-c with Apache License 2.0 | 5 votes |
static String toString(Configuration c) { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); try { PrintStream ps = new PrintStream(buffer, false, "UTF-8"); PropertiesConfiguration tmp = new PropertiesConfiguration(); tmp.copy(c); tmp.save(ps); return buffer.toString("UTF-8"); } catch (Exception e) { throw new MetricsConfigException(e); } }
Example 8
Source File: ConfigUtil.java From big-c with Apache License 2.0 | 5 votes |
static void dump(String header, Configuration c, PrintStream out) { PropertiesConfiguration p = new PropertiesConfiguration(); p.copy(c); if (header != null) { out.println(header); } try { p.save(out); } catch (Exception e) { throw new RuntimeException("Error saving config", e); } }