Iterate properties in DynamicProperyFactory

less than 1 minute read

This might not be a common scenario, but sometimes you might need to iterate all of the properties managed by archaius utlity. Here is the code that can you do it:

Object config = DynamicPropertyFactory.getBackingConfigurationSource();
if (DynamicPropertyFactory.isInitializedWithDefaultConfig()) {
    ConcurrentCompositeConfiguration composite = (ConcurrentCompositeConfiguration) config;
    Properties p = composite.getProperties();

    Iterator<Object> it = p.keySet().iterator();
    while (it.hasNext()) {
        String name = (String) it.next();
        DynamicStringProperty value = DynamicPropertyFactory.getInstance().getStringProperty(name, null);
    }
}

Updated:

Comments