Skip to content

Instantly share code, notes, and snippets.

@nemo83
Created November 16, 2015 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nemo83/b170c72b92dd56d2c346 to your computer and use it in GitHub Desktop.
Save nemo83/b170c72b92dd56d2c346 to your computer and use it in GitHub Desktop.
Guice Module similar to Spring Configuration class.
package config
import akka.actor.ActorSystem
import com.example.driver.RedisClient
import com.google.inject.name.Named
import com.google.inject.{AbstractModule, Provides}
class Config extends AbstractModule {
override def configure(): Unit = {
// Just make compiler happy
}
@Provides
@Named("myDbOne")
def dbOneRedisClient(actorSystem: ActorSystem): RedisClient = {
new RedisClient("localhost", 1234)(actorSystem)
}
@Provides
@Named("myDbTwo")
def dbTwoRedisClient(actorSystem: ActorSystem): RedisClient = {
new RedisClient("localhost", 5678)(actorSystem)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment