@Override public void unregisterProperties(Class<?> componentClass, boolean clear) { checkPermission(CONFIG_WRITE); String componentName = componentClass.getName(); checkNotNull(componentName, COMPONENT_NULL); Map<String, ConfigProperty> cps = properties.remove(componentName); if (clear && cps != null) { cps.keySet().forEach(name -> store.unsetProperty(componentName, name)); clearExistingValues(componentName); } }
@Override public void registerProperties(Class<?> componentClass) { checkPermission(CONFIG_WRITE); String componentName = componentClass.getName(); String resourceName = componentClass.getSimpleName() + RESOURCE_EXT; try (InputStream ris = componentClass.getResourceAsStream(resourceName)) { checkArgument(ris != null, "Property definitions not found at resource %s", resourceName); // Read the definitions Set<ConfigProperty> defs = ConfigPropertyDefinitions.read(ris); // Produce a new map of the properties and register it. Map<String, ConfigProperty> map = Maps.newConcurrentMap(); defs.forEach(p -> map.put(p.name(), p)); properties.put(componentName, map); loadExistingValues(componentName); } catch (IOException e) { log.error("Unable to read property definitions from resource " + resourceName, e); } }