{8.0.0-new, 8.1.2-deprecated} Config
The following methods can be used to define the configuration for your microservice using the powerful Config API:
If you do not specify any of this information, we attempt to resolve it through the following methods:
If no configuration file is found, and empty in-memory configuration is used.
The {@link oaj.microservice.MicroserviceBuilder#configName(String) configName(String)} method allows you to explicitly specify the name of the external configuration file location for your microservice.
Microservice
.
By default, we try to find the file on the file system and then the classpath. If located on the file system, then the configuration is writeable and the microservice can automatically listen for and react to changes in the configuration file on the file system. If located on the classpath, then the configuration can still react to modifications made to it through the Config API, but the changes cannot be persisted since the location prevents the file from being modified.
The {@link oaj.microservice.MicroserviceBuilder#configStore(ConfigStore) configStore(ConfigStore)} method can be used to explicitly specify a configuration store. This can include your own custom configuration store, such as one that's implemented in a relational database.
Microservice
.
The {@link oaj.microservice.MicroserviceBuilder#config(Config) config(Config)} method can be used to explicitly specify a {@link oaj.config.Config} file as the microservice configuration. When this method is used, the above two methods are bypassed entirely.
Config config =
Once the configuration is resolved, it is made as the system default configuration available through the {@link oaj.config.Config#getSystemDefault()}.
This in turn allows it to be used by REST resources that reference the system default configuration via the
The {@link oaj.microservice.Microservice#getConfig()} method can be used to get access to the configuration.
Config c = Microservice.
Changes to the configuration file can trigger notifications that can be used to restart your microservice or make various other on-the-fly changes. This can be accomplished by either overriding the {@link oaj.microservice.Microservice#onConfigChange(ConfigEvents)} or implementing a listener and using the {@link oaj.microservice.MicroserviceListener#onConfigChange(Microservice,ConfigEvents)} methods. These will be described in detail later.