Build Status | Dependencies UpToDate | Latest Version | License |
---|---|---|---|
Common dependencies and utils for projects.
Just add the following maven central dependency.
Add dependency to build.sbt
.
libraryDependencies += "software.reinvent" % "commons" % "x.y.z"
<dependency>
<groupId>software.reinvent</groupId>
<artifactId>commons</artifactId>
<version>x.y.z</version>
</dependency
The typesafe config is great for any configuration. The convenience method
software.reinvent.commons.config.ConfigLoader.load()
, loads the following (first-listed are higher priority):
- system properties
- file path from system property
provided.config
{username}.conf
in classpath resourcesapplication.conf
(all resources on classpath with this name)application.json
(all resources on classpath with this name)application.properties
(all resources on classpath with this name)reference.conf
(all resources on classpath with this name)
A cached version is available via software.reinvent.commons.config.CachedConfig.load()
provided with a LoadingCache.
For any Guice powered applications, one would love software.reinvent.commons.config.ConfigProvider
or software.reinvent.commons.config.CachedConfigProvider
The JvmUtil
comes from my former colleague Daniel Galán y Martins and provides access to information about the currently running JVM and some process-control (eg. fluent Termination of JVM, ShutdownHook methods).
Provides a injectable logback implementation for slf4j which can be used for every logging.
Just bind the Slf4jTypeListener
in a Guice module:
import static com.google.inject.matcher.Matchers.any;
...
@Override
protected void configure() {
bindListener(any(), new Slf4jTypeListener());
}
And use the logger in any injected class like this:
import org.slf4j.Logger;
import software.reinvent.log.InjectLogger;
...
@InjectLogger
private Logger log;
log.info("{}st log.", 1)
will log something like 10:21:17,914 INFO [ForkJoinPool-1-worker-3] application: Class::Method:#Line - 1st log.
Comparators
- Provides a null friendly version string comparator for dot-separated tuple like v2.1.10 or 0.1.12.5.
ConfigTestUtils
- Provides some methods to add, replace or remove entries in the immutable typesafe config.