Skip to content

Utility library to assist in providing default config properties to dropwizard services

License

Notifications You must be signed in to change notification settings

kiwiproject/dropwizard-config-providers

Repository files navigation

Dropwizard Config Providers

Build Quality Gate Status Coverage CodeQL javadoc License: MIT Maven Central

Utility library to assist in providing default config properties to dropwizard services

How to use it

  • Add the Maven dependency (available in Maven Central)
<dependency>
    <groupId>org.kiwiproject</groupId>
    <artifactId>dropwizard-config-providers</artifactId>
    <version>[latest-version]</version>
</dependency>
  • Add the following to your Configuration class:
public class YourConfiguration extends Configuration {

    private String serviceName = ServiceIdentityProvider.builder().build().getName();

}

Property resolution order of precedence

The service providers will resolve properties in the following order:

  1. System property with the given system property key
  2. System property with the default system property key (See the specific provider for details)
  3. Environment variable with the given variable name
  4. Environment variable with the default variable name (See the specific provider for details)
  5. An explicit value
  6. The value from an external configuration file with the given key (See ExternalPropertyProvider for details)
  7. The value from an external configuration file with the default key (See the specific provider for details)
  8. The value from a given supplier

Current Providers

The following providers are currently available in this library.

Provider Description Properties Resolved
ActiveMQConfigProvider Resolves the connection string for ActiveMQ servers activeMQServers
DropwizardDataSourceConfigProvider Resolves a DataSourceFactory for connecting to a relational database in Dropwizard dataSourceFactory
ElkLoggerConfigProvider Resolves the connection and configuration information for an ELK Logger server host, port, customFields
ElucidationConfigProvider Resolves the connection and configuration for an Elucidation server host, port, enabled
HibernateConfigProvider Resolves default properties for a Hibernate connection hibernateProperties
MongoConfigProvider Resolves the connection string for Mongo servers url
NetworkIdentityConfigProvider Resolves a named network, useful if you want to have services run in different subnets/VPCs network
ServiceIdentityConfigProvider Resolves identity information for a running service name, version, environment (deployed)
TlsConfigProvider Resolves the properties to use in a TLS Configuration tlsContextConfiguration
SharedStorageConfigProvider Resolves a directory path that will be used for shared storage between services sharedStoragePath
ZooKeeperConfigProvider Resolves the ZooKeeper connection string connectString

Custom Providers

Custom providers can be created by extending the ConfigProvider interface. Also, the existing providers can be extended by setting various lookup mechanisms listed in the order of precedence section.