Java Code Examples for org.apache.commons.configuration.AbstractConfiguration#getKeys()
The following examples show how to use
org.apache.commons.configuration.AbstractConfiguration#getKeys() .
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: ConfigUtil.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
private static void duplicateCseConfigToServicecomb(AbstractConfiguration source) { Iterator<String> keys = source.getKeys(); while (keys.hasNext()) { String key = keys.next(); if (!key.startsWith(CONFIG_CSE_PREFIX)) { continue; } String servicecombKey = CONFIG_SERVICECOMB_PREFIX + key.substring(key.indexOf(".") + 1); if (!source.containsKey(servicecombKey)) { source.addProperty(servicecombKey, source.getProperty(key)); } else { LOGGER .warn( "Key {} with an ambiguous item {} exists, it's recommended to use only one of them.", key, servicecombKey); } } }
Example 2
Source File: PropertiesServlet.java From chassis with Apache License 2.0 | 6 votes |
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // get list of properties TreeSet<String> properties = new TreeSet<String>(); AbstractConfiguration config = ConfigurationManager.getConfigInstance(); Iterator<String> keys = config.getKeys(); while (keys.hasNext()) { String key = keys.next(); Object value = config.getProperty(key); if ("aws.accessId".equals(key) || "aws.secretKey".equals(key) || "experiments-service.secret".equals(key) || "java.class.path".equals(key) || key.contains("framework.securityDefinition") || key.contains("password") || key.contains("secret")) { value = "*****"; } properties.add(key + "=" + value.toString()); } // write them out in sorted order for (String line : properties) { resp.getWriter().append(line).println(); } }
Example 3
Source File: PropsServlet.java From s2g-zuul with MIT License | 5 votes |
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Map<String, String> allPropsAsString = new TreeMap<String, String>(); AbstractConfiguration config = ConfigurationManager.getConfigInstance(); Iterator<String> keys = config.getKeys(); while (keys.hasNext()) { final String key = keys.next(); final Object value; value = config.getProperty(key); allPropsAsString.put(key, value.toString()); } String jsonStr = JSON.toJSONString(allPropsAsString); //mapper.writeValueAsString(allPropsAsString); resp.addHeader("Access-Control-Allow-Origin", "*"); resp.addHeader("Access-Control-Allow-Headers","Content-Type, Accept"); resp.setContentType("application/json; charset=UTF-8"); PrintWriter writer = resp.getWriter(); try{ writer.write(jsonStr); resp.setStatus(Response.SC_OK); } finally { if (writer != null) { writer.close(); } } }
Example 4
Source File: ConfigUtil.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
public static AbstractConfiguration convertEnvVariable(AbstractConfiguration source) { Iterator<String> keys = source.getKeys(); while (keys.hasNext()) { String key = keys.next(); String[] separatedKey = key.split(CONFIG_KEY_SPLITER); if (separatedKey.length == 1) { continue; } String newKey = String.join(".", separatedKey); source.addProperty(newKey, source.getProperty(key)); } return source; }
Example 5
Source File: ConfigurationSpringInitializer.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
@Override protected Properties mergeProperties() throws IOException { Properties properties = super.mergeProperties(); AbstractConfiguration config = ConfigurationManager.getConfigInstance(); Iterator<String> iter = config.getKeys(); while (iter.hasNext()) { String key = iter.next(); Object value = config.getProperty(key); properties.put(key, value); } return properties; }
Example 6
Source File: PropertiesServlet.java From tcc-transaction with Apache License 2.0 | 5 votes |
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Map<String, String> allPropsAsString = new TreeMap<String, String>(); AbstractConfiguration config = ConfigurationManager.getConfigInstance(); Iterator<String> keys = config.getKeys(); while (keys.hasNext()) { final String key = keys.next(); final Object value; value = config.getProperty(key); allPropsAsString.put(key, value.toString()); } String jsonStr = JSON.toJSONString(allPropsAsString); resp.setCharacterEncoding("utf-8"); resp.addHeader("Access-Control-Allow-Origin", "*"); resp.addHeader("Access-Control-Allow-Headers","Content-Type, Accept"); resp.setContentType("application/json"); PrintWriter writer = resp.getWriter(); try{ writer.write(jsonStr); resp.setStatus(Response.SC_OK); } finally { if (writer != null) { writer.close(); } } }
Example 7
Source File: PropertiesServlet.java From galaxy with Apache License 2.0 | 5 votes |
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Map<String, String> allPropsAsString = new TreeMap<String, String>(); AbstractConfiguration config = ConfigurationManager.getConfigInstance(); Iterator<String> keys = config.getKeys(); while (keys.hasNext()) { final String key = keys.next(); final Object value; value = config.getProperty(key); allPropsAsString.put(key, value.toString()); } String jsonStr = JSON.toJSONString(allPropsAsString); resp.setCharacterEncoding("utf-8"); resp.addHeader("Access-Control-Allow-Origin", "*"); resp.addHeader("Access-Control-Allow-Headers","Content-Type, Accept"); resp.setContentType("application/json"); PrintWriter writer = resp.getWriter(); try{ writer.write(jsonStr); resp.setStatus(Response.SC_OK); } finally { if (writer != null) { writer.close(); } } }