ConfiguR, a persistent configuration service
MIT License
ConfiguR is a persistent configuration service, providing modules to store and retrieve configuration properties from various sources.
Those sources can have many types:
The following attributes were defined to represent configuration properties:
All values are stored as strings in the database but methods have been provided to convert them to various other types after being fetched.
Configuration can be stored in a hierarchical manner in order to provide a better structure:
All calls should be made to the ConfigurationPropertySource
and ConfigurationService
to make sure mechanisms such as caching are not bypassed.
If needed, a new property source can be added to the environment upon startup. This can be done by defining a ConfigurationPropertySourceApplicationListener
bean in the application context. By default, this bean will add to the environment property sources for all ConfigurationService
instances but you can also define it with the name of the bean which must be used instead.
Important: as some implementations rely on other beans such as the datasource for Spring Data DAOs, ConfiguR cannot be used to load startup properties such as database configuration. Such properties should remain in flat files or environment properties, ConfiguR can be used for dynamic properties fetched while the application is running.
Remember to add the following package to the list scanned by Hibernate to find entity definitions: com.github.ppodgorsek.configur.springdata.jpa.model
In case you would like to change the table and column names or the database constraints, simply override the default values by creating a new class in your classpath which will supersede com.github.ppodgorsek.configur.springdata.jpa.JpaConfigurationMetadata
.
This abstraction allows to cache properties from any ConfigurationService
instance. To avoid complex invalidation cases, categories are not cached.
In case you would like to change the cache region name, simply override the default value by creating a new class in your classpath which will supersede com.github.ppodgorsek.configur.cache.CacheConfigurationMetadata
.
All artefacts of this project are available on Maven’s central repository, which makes it easy to use in your projects.
If you are using Maven, simply declare the following dependencies:
configur-core:
<dependency>
<groupId>com.github.ppodgorsek</groupId>
<artifactId>configur-core</artifactId>
<version>${configur.version}</version>
</dependency>
configur-cache:
<dependency>
<groupId>com.github.ppodgorsek</groupId>
<artifactId>configur-cache</artifactId>
<version>${configur.version}</version>
</dependency>
configur-springdata-jpa:
<dependency>
<groupId>com.github.ppodgorsek</groupId>
<artifactId>configur-springdata-jpa</artifactId>
<version>${configur.version}</version>
</dependency>
configur-core
is the only mandatory one, the others are optional and depend on what persistent layers your project relies on.
Have you found an issue? Do you have an idea for an improvement? Feel free to contribute by submitting it on the GitHub project.