Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArchaiusConfigurationProvider owns all properties even they are not defined. #58

Closed
metacret opened this issue Apr 24, 2013 · 4 comments
Assignees
Labels

Comments

@metacret
Copy link

When I use CompositeConfigurationProvider such as the following code:

binder.bindConfigurationProvider().toInstance(
                                                new CompositeConfigurationProvider(
                                                        ArchaiusConfigurationProvider.builder().build(),
                                                        new PropertiesConfigurationProvider(properties)));

ArchaiusConfigurationProvider owns all properties even they are not defined. If the property is not defined in Archaius, it should fall back to other configuration provider chained above.

The temporary solution can be the following:

ConfigurationOwnershipPolicy ownershipPolicy = new ConfigurationOwnershipPolicy() {
                                            @Override
                                            public boolean has(ConfigurationKey key, Map<String, String> variableValues) {
                                                return !properties.containsKey(key.getKey(variableValues));
                                            }
                                        };

and hook up the above ownershipPolicy with ArchiausConfigurationProvider at withOwnershipPolicy.

@ghost ghost assigned elandau Apr 24, 2013
@metacret
Copy link
Author

With null specifically withOwnershipPolicy(null), it shows the behavior of the previous version(v1.1.1). I think we'd better document this. If null parameter is not ugly, you can close this issue.

@elandau
Copy link
Contributor

elandau commented Apr 26, 2013

Initially I was thinking of changing the default ownership policy to 'null' so that archaius only claims ownership of properties that have been specified at startup. I think now that this will just further confuse things. I think a better approach would be to document that archaius (or any dynamic property source) shouldn't be used with CompoisteConfigurationProvider. The reason for this is that CompositeConfigurationProvider is meant to be used for disjoint sets of properties and mixing it with ArhcaiusConfigurationProvider just confuses things because archaius itself manages properties from multiple sources. With CompositeConfigurationProvider It is difficult to determine which provider owns a property that was not specified at startup but should be picked up dynamically.

Alternatively you could specify a regex for ArchaiusConfigurationProvider to only own properties with a certain prefix.

@Randgalt
Copy link
Contributor

That's fine with me. Eran, please update the wiki/doc

@Randgalt
Copy link
Contributor

@elandau any news on this or should we close the issue?

@elandau elandau closed this as completed Oct 26, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants