Created
November 16, 2015 17:35
-
-
Save nemo83/b170c72b92dd56d2c346 to your computer and use it in GitHub Desktop.
Guice Module similar to Spring Configuration class.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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