@SuppressWarnings("NullableProblems") public int compareTo(ConfigItem ci) { if (ci == null) { throw new NullPointerException("Cannot compare this to a null value"); } return this.name.compareToIgnoreCase(ci.getName()); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ConfigItem other = (ConfigItem) obj; if (name == null) { if (other.getName() != null) return false; } else if (!name.equals(other.getName())) return false; return true; }
@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 (item == null || neverPersistItems.contains(item.getName())) { return null; 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()); } catch (IllegalClassException ice) { log.error("Skip ConfigItem {}, {}", item, ice.getMessage()); item.getName(), serialValue, serialRawValue,
String propertyName = configItem.getName(); if (IS_DEFAULT && (propertyName.startsWith(DEFAULT_INDEX))) { propertyName = propertyName.replaceFirst(DEFAULT_INDEX, "index.");
break; attributeInfos.add(new MBeanAttributeInfo(item.getName(), type, item.getDescription(), !item.isSecured(), true, false));
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; }
@Override public void changed(ConfigItem item, ConfigItem previous) { // a ConfigItem has changed if (item == null) { return; } HibernateConfigItem hItem = findByName(item.getName()); if (hItem == null) { // new hItem hItem = createHibernateConfigItem(item); } else { // existing hItem, update it hItem = updateHibernateConfigItem(hItem, item); } saveOrUpdate(hItem); }
/** * 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>(); } }