/** * {@inheritDoc} */ public String getRawProperty(String name) { String rv = null; if (this.rawProperties.containsKey(name)) { // NOTE: raw properties ONLY contains the data read in from the properties files rv = StringUtils.trimToNull((String) this.rawProperties.get(name)); } else { // check the config storage since it is not in the raw props ConfigItem ci = getConfigItem(name); if (ci != null && ci.getValue() != null) { rv = ci.getValue().toString(); } } if (rv == null) rv = ""; return rv; }
@Override public AttributeList getAttributes(String[] attributes) { AttributeList list = new AttributeList(); for (ConfigItem item: serverConfigurationService.getConfigData().getItems()) { String name = item.getName(); Object value = item.getValue(); Attribute attribute; if (item.isSecured()) { attribute = new Attribute(name, null); } else { attribute = new Attribute(name, value); } list.add(attribute); } return list; }
if (IS_DEFAULT && (propertyName.startsWith(DEFAULT_INDEX))) { propertyName = propertyName.replaceFirst(DEFAULT_INDEX, "index."); mergedConfig.put(propertyName, (String) configItem.getValue()); } else if (propertyName.startsWith(LOCAL_INDEX)) { propertyName = propertyName.replaceFirst(LOCAL_INDEX, "index."); mergedConfig.put(propertyName, (String) configItem.getValue());
if (item.getValue() != null) { return false; if (!value.equals(item.getValue())) { return false; if (!value.equals(String.valueOf(item.getValue()))) { return false; if (!value.equals(String.valueOf(item.getValue()))) { return false; if (!value.equals(join((String[]) item.getValue(), ARRAY_SEPARATOR))) { return false;
if (item.getValue() != null) { return false; if (!value.equals(item.getValue())) { return false; if (!value.equals(String.valueOf(item.getValue()))) { return false; if (!value.equals(String.valueOf(item.getValue()))) { return false; if (!value.equals(join((String[]) item.getValue(), ARRAY_SEPARATOR))) { return false;
serialValue = serializeValue(item.getValue(), item.getType(), item.isSecured()); serialDefaultValue = serializeValue(item.getDefaultValue(), item.getType(), item.isSecured()); serialRawValue = serializeValue(getRawProperty(item.getName()), ServerConfigurationService.TYPE_STRING, item.isSecured());
public ConfigItem registerConfigItem(ConfigItem configItem) { if (configItem == null) { throw new IllegalArgumentException("configItem must be set"); } ConfigItemImpl ci = null; if (StringUtils.isNotBlank(configItem.getName())) { ci = new ConfigItemImpl(configItem.getName(), configItem.getValue(), configItem.getSource()); if (configItem.getValue() != null) { ci.setValue(configItem.getValue()); } if (configItem.getDefaultValue() != null) { ci.setDefaultValue(configItem.getDefaultValue()); } ci = this.addConfigItem(ci, ci.getSource()); } else { log.warn("Skipping registering invalid config item (name not set): "+configItem); } return ci; }
/** * merges the contents of one config item (the safely changed fields) into this one * @param ci any config item */ public void merge(ConfigItem ci) { if (ci != null) { //this.name = name; this.value = ci.getValue(); this.type = setValue(ci.getValue()); this.description = ci.getDescription(); if (StringUtils.isNotBlank(ci.getSource())) { this.source = ci.getSource(); } this.defaultValue = ci.getDefaultValue(); this.dynamic = ci.isDynamic(); } }
/** * Make an impl from something that implements ConfigItem by copying the field values * @param ci a ci object */ @SuppressWarnings("unused") public ConfigItemImpl(ConfigItem ci) { this(ci.getName(), ci.getValue(), ci.getType(), ci.getDescription(), ci.getSource(), ci.getDefaultValue(), ci.getRequested(), ci.getChanged(), null, ci.isRegistered(), ci.isDefaulted(), ci.isSecured(), ci.isDynamic()); if (ci.getHistory() != null) { this.history = Arrays.asList(ci.getHistory()); } else { this.history = new ArrayList<ConfigHistory>(); } }
@Override public Object getAttribute(String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException { ConfigItem configItem = serverConfigurationService.getConfigItem(attribute); if (configItem.isSecured()) { return null; } return configItem.getValue(); }