Closed akhaku closed 2 years ago
@twicksell - we discussed adding a method to the Property interface, but I'm not too sure how I feel about adding a factory (default) method to an interface, so I opted to stick with the separate implementation.
Can you provide additional information about the use case here. Property is normally created by a PropertyRepository and not directly so it feels strange to be creating a static property instance outside of a PropertyRepository.
Absolutely, so a couple different use cases:
I'd be concerned about introducing this given that Archaius is all about dynamic configuration and I don't feel that this is the proper abstraction for introducing 'immutable' configuration. I'd also recommend not relying on the Property interface directly in your code to avoid coupling your business logic specifically with Archaius. There are several alternatives to achieving this,
() -> CONSTANT
.Hm, interesting - we've done something similar in our code, where we have an interface that is implemented using an Archaius PropertyRepository. For non-DI (static creation for local development) we don't pass in a RepositoryFactory and instead initialize properties to static values, but we could instead use a DefaultPropertyFactory and have that use a SettableConfig. I'll give that a shot and add you to the PR so you can take a look, if you're curious.
A StaticProperty is useful for cases where we don't want a property to change, for example in unit tests.