Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling properties in Scala

I'd like to know what is the most efficient way of handling properties in Scala. I'm tired of having gazillion property files, xml files and other type of configuration files in Java and wonder if there's "best practice" to handle those someway more efficient in Scala?

like image 921
Roman Kagan Avatar asked Jun 08 '09 04:06

Roman Kagan


2 Answers

Why would you have a gazillion property files?

I'm still using the Apache commons Digester, which works perfectly well in Scala. It's basically a very easy way of making a user-defined XML document map to method calls on a user-defined configurator class. I find it extremely useful when I want to parse some configuration data (as opposed to application properties).

For application properties, you might either use a dependency injection framework (like Spring) or just plain old property files. I'd also be interested to see if Scala offers anything on top of this, though.

like image 94
oxbow_lakes Avatar answered Sep 30 '22 08:09

oxbow_lakes


EDIT: Typesafe config gives you a simple and powerful solution for configuration - https://github.com/typesafehub/config

ORIGINAL (possibly not very useful):

Quoting from "Programming in Scala":

"In Scala, you can configure via Scala code itself."

Scala's runtime linking allows for classes to be swapped at runtime and the general philosophy of these languages tends to favour convention over configuration. If you don't want to deal with gazillion property files, just don't have them.

like image 30
George Avatar answered Sep 30 '22 09:09

George