0

I have a Play app that I want to split into:

  • rest - Play module that holds the rest interface

  • services - plain Scala module that holds actors and external services clients (ex S3)

I want to create a S3Client object class, but when instantiating it I need to read the config values from application.conf. I can not use play.api.Play.current.configuration since this is not a play module.

Am I thinking this wrong? What would be the most elegant way to achieve what I want?

biesior
  • 54,554
  • 10
  • 118
  • 177
gdogaru
  • 469
  • 5
  • 20
  • Maybe a better approach would be to factor out all configuration stuff common to all modules to seperate module – maks Mar 17 '14 at 13:13

2 Answers2

1

just use typesafe Config factory

   import com.typesafe.config.ConfigFactory

   val conf = ConfigFactory.load("/path/to/your/conf/file/application.conf")

   //init your object with the conf file.
Nimrod007
  • 9,075
  • 8
  • 43
  • 68
0

You don't even need to put a path in it.

If the application.conf is in the root directory, the config factory will automatically check if it's there.

zx485
  • 24,099
  • 26
  • 45
  • 52