Skip to content

ldaume/commons

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Dependencies UpToDate Latest Version License
Build Status Dependencies UpToDate Maven Central License: MIT

Commons

Abstract

Common dependencies and utils for projects.

Usage

Repo

Just add the following maven central dependency.

SBT

Add dependency to build.sbt.

libraryDependencies += "software.reinvent" % "commons" % "x.y.z"

Maven

<dependency>
    <groupId>software.reinvent</groupId>
    <artifactId>commons</artifactId>
    <version>x.y.z</version>
</dependency

Overview

software.reinvent.commons.config

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 resources
  • application.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)

Cached Config

A cached version is available via software.reinvent.commons.config.CachedConfig.load() provided with a LoadingCache.

Guice Provider

For any Guice powered applications, one would love software.reinvent.commons.config.ConfigProvider or software.reinvent.commons.config.CachedConfigProvider

software.reinvent.commons.jvm

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).

software.reinvent.commons.log

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.

software.reinvent.commons.utils

Comparators - Provides a null friendly version string comparator for dot-separated tuple like v2.1.10 or 0.1.12.5.

software.reinvent.commons.test

ConfigTestUtils - Provides some methods to add, replace or remove entries in the immutable typesafe config.

About

Common utility classes for Java projects.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published