Skip to content

Instantly share code, notes, and snippets.

@nemo83
Created Nov 16, 2015
Embed
What would you like to do?
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