Skip to content

Instantly share code, notes, and snippets.

View scottstewartt's full-sized avatar

scottstewartt

View GitHub Profile
@scottstewartt
scottstewartt / PropsLoader.scala
Last active August 29, 2015 14:19
Simple scala class for automatically reloading properties from file
class PropsLoader(val filePath:String, val defaults:Map[String, String] = Map(), val reloadSecs:Int = 5) {
import java.util.concurrent.atomic._
private val file = new java.io.File(filePath)
if (!file.isFile) throw new IllegalArgumentException(s"'$filePath' at ${file.getAbsolutePath} is not a file")
private var javaProps = new java.util.Properties
@volatile //synchronizes, could add thread-local cache
private var props = defaults
private val lastLoadCheck = new AtomicLong(-1)
package x
import unfiltered.request._
import unfiltered.response._
import unfiltered.Cookie
import unfiltered.filter._
import javax.servlet.{Filter, FilterConfig, FilterChain, ServletRequest, ServletResponse}
import javax.servlet.http.{HttpServletRequest, HttpServletResponse, HttpServletRequestWrapper}
import java.security.Principal