/** * Update this global configuration from a string-string. Only the known keys are taken * from this map * * @param pConfig config map from where to take the configuration */ public void updateGlobalConfiguration(Map<String, String> pConfig) { for (ConfigKey c : ConfigKey.values()) { if (c.isGlobalConfig()) { String value = pConfig.get(c.getKeyValue()); if (value != null) { globalConfig.put(c,value); } } } }
/** * Get a processing parameter * * @param pKey key to lookup * @return the value or the default value from the key if no config value is set */ public String get(ConfigKey pKey) { String value = params.get(pKey); if (value != null) { return value; } else { return pKey.getDefaultValue(); } }
/** * Update the configuration hold by this object * * @param pExtractor an extractor for retrieving the configuration from some external object */ public void updateGlobalConfiguration(ConfigExtractor pExtractor) { Enumeration e = pExtractor.getNames(); while (e.hasMoreElements()) { String keyS = (String) e.nextElement(); ConfigKey key = ConfigKey.getGlobalConfigKey(keyS); if (key != null) { globalConfig.put(key,pExtractor.getParameter(keyS)); } } }
private String getConfiguration(ConfigKey pKey) { // TODO: Use fragments if available. String value = getConfigurationFromConfigAdmin(pKey); if (value == null) { value = bundleContext.getProperty(CONFIG_PREFIX + "." + pKey.getKeyValue()); } if (value == null) { value = pKey.getDefaultValue(); } return value; }
private Dictionary<String,String> getConfiguration() { Dictionary<String,String> config = new Hashtable<String,String>(); for (ConfigKey key : ConfigKey.values()) { String value = getConfiguration(key); if (value != null) { config.put(key.getKeyValue(),value); } } String jolokiaId = NetworkUtil.replaceExpression(config.get(ConfigKey.AGENT_ID.getKeyValue())); if (jolokiaId == null) { config.put(ConfigKey.AGENT_ID.getKeyValue(), NetworkUtil.getAgentId(hashCode(),"osgi")); } config.put(ConfigKey.AGENT_TYPE.getKeyValue(),"osgi"); return config; }
private boolean isStreamingEnabled(HttpServletRequest pReq) { String streamingFromReq = pReq.getParameter(ConfigKey.STREAMING.getKeyValue()); if (streamingFromReq != null) { return Boolean.parseBoolean(streamingFromReq); } return streamingEnabled; }
static Map<ConfigKey, String> convertToConfigMap(Map<String, String> pParams) { Map<ConfigKey,String> config = new HashMap<ConfigKey, String>(); if (pParams != null) { for (Map.Entry<String,?> entry : pParams.entrySet()) { ConfigKey cKey = ConfigKey.getRequestConfigKey(entry.getKey()); if (cKey != null) { Object value = entry.getValue(); config.put(cKey, value != null ? value.toString() : null); } } } return config; } }
/** * Get processing parameters from a string-string map * * @param pParams params to extra. A parameter "p" is used as extra path info * @return the processing parameters */ public ProcessingParameters getProcessingParameters(Map<String,String> pParams) { Map<ConfigKey,String> procParams = ProcessingParameters.convertToConfigMap(pParams); for (Map.Entry<ConfigKey,String> entry : globalConfig.entrySet()) { ConfigKey key = entry.getKey(); if (key.isRequestConfig() && !procParams.containsKey(key)) { procParams.put(key,entry.getValue()); } } return new ProcessingParameters(procParams,pParams.get(PATH_QUERY_PARAM)); }
private void addJolokiaId(Map<String, String> pFinalCfg) { if (!pFinalCfg.containsKey(ConfigKey.AGENT_ID.getKeyValue())) { pFinalCfg.put(ConfigKey.AGENT_ID.getKeyValue(), NetworkUtil.getAgentId(hashCode(),"jvm")); } pFinalCfg.put(ConfigKey.AGENT_TYPE.getKeyValue(), "jvm"); }
public static boolean containsEnum(String test) { for (ConfigKey c : ConfigKey.values()) { if (c.getKeyValue().equals(test)) { return true; } } return false; }
private String getConfiguration(ConfigKey pKey) { // TODO: Use fragments if available. String value = getConfigurationFromConfigAdmin(pKey); if (value == null) { value = bundleContext.getProperty(CONFIG_PREFIX + "." + pKey.getKeyValue()); } if (value == null) { value = pKey.getDefaultValue(); } return value; }
static Map<ConfigKey, String> convertToConfigMap(Map<String, String> pParams) { Map<ConfigKey,String> config = new HashMap<ConfigKey, String>(); if (pParams != null) { for (Map.Entry<String,?> entry : pParams.entrySet()) { ConfigKey cKey = ConfigKey.getRequestConfigKey(entry.getKey()); if (cKey != null) { Object value = entry.getValue(); config.put(cKey, value != null ? value.toString() : null); } } } return config; } }
/** * Get processing parameters from a string-string map * * @param pParams params to extra. A parameter "p" is used as extra path info * @return the processing parameters */ public ProcessingParameters getProcessingParameters(Map<String,String> pParams) { Map<ConfigKey,String> procParams = ProcessingParameters.convertToConfigMap(pParams); for (Map.Entry<ConfigKey,String> entry : globalConfig.entrySet()) { ConfigKey key = entry.getKey(); if (key.isRequestConfig() && !procParams.containsKey(key)) { procParams.put(key,entry.getValue()); } } return new ProcessingParameters(procParams,pParams.get(PATH_QUERY_PARAM)); }
private JSONObject configToJSONObject() { JSONObject info = new JSONObject(); if (config != null) { for (ConfigKey key : ConfigKey.values()) { if (key.isGlobalConfig()) { String value = config.get(key); if (value != null) { info.put(key.getKeyValue(), value); } } } } return info; }
protected void prepareDetectorOptions(Map<String, String> pConfig) { StringBuffer detectorOpts = new StringBuffer("{"); if (pConfig.containsKey("bootAmx") && Boolean.parseBoolean(pConfig.get("bootAmx"))) { detectorOpts.append("\"glassfish\" : { \"bootAmx\" : true }"); } if (detectorOpts.length() > 1) { detectorOpts.append("}"); pConfig.put(ConfigKey.DETECTOR_OPTIONS.getKeyValue(),detectorOpts.toString()); } }
private Dictionary<String,String> getConfiguration() { Dictionary<String,String> config = new Hashtable<String,String>(); for (ConfigKey key : ConfigKey.values()) { String value = getConfiguration(key); if (value != null) { config.put(key.getKeyValue(),value); } } String jolokiaId = NetworkUtil.replaceExpression(config.get(ConfigKey.AGENT_ID.getKeyValue())); if (jolokiaId == null) { config.put(ConfigKey.AGENT_ID.getKeyValue(), NetworkUtil.getAgentId(hashCode(),"osgi")); } config.put(ConfigKey.AGENT_TYPE.getKeyValue(),"osgi"); return config; }
/** * Get a configuration value if set as configuration or the default * value if not * * @param pKey the configuration key to lookup * @return the configuration value or the default value if no configuration * was given. */ public String get(ConfigKey pKey) { String value = globalConfig.get(pKey); if (value == null) { value = pKey.getDefaultValue(); } return value; }
static Map<ConfigKey, String> convertToConfigMap(Map<String, String> pParams) { Map<ConfigKey,String> config = new HashMap<ConfigKey, String>(); if (pParams != null) { for (Map.Entry<String,?> entry : pParams.entrySet()) { ConfigKey cKey = ConfigKey.getRequestConfigKey(entry.getKey()); if (cKey != null) { Object value = entry.getValue(); config.put(cKey, value != null ? value.toString() : null); } } } return config; } }
/** * Get processing parameters from a string-string map * * @param pParams params to extra. A parameter "p" is used as extra path info * @return the processing parameters */ public ProcessingParameters getProcessingParameters(Map<String,String> pParams) { Map<ConfigKey,String> procParams = ProcessingParameters.convertToConfigMap(pParams); for (Map.Entry<ConfigKey,String> entry : globalConfig.entrySet()) { ConfigKey key = entry.getKey(); if (key.isRequestConfig() && !procParams.containsKey(key)) { procParams.put(key,entry.getValue()); } } return new ProcessingParameters(procParams,pParams.get(PATH_QUERY_PARAM)); }
/** * Update the configuration hold by this object * * @param pExtractor an extractor for retrieving the configuration from some external object */ public void updateGlobalConfiguration(ConfigExtractor pExtractor) { Enumeration e = pExtractor.getNames(); while (e.hasMoreElements()) { String keyS = (String) e.nextElement(); ConfigKey key = ConfigKey.getGlobalConfigKey(keyS); if (key != null) { globalConfig.put(key,pExtractor.getParameter(keyS)); } } }