Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * HostsModule.scala
- */
- package project
- import scaldi.Module
- class HostsModule extends Module {
- binding identifiedBy "hosts.google" to "google.com"
- binding identifiedBy "hosts.yahoo" to "yahoo.com"
- binding identifiedBy "hosts.facebook" to "facebook.com"
- }
- /**
- * ... HostsService.scala
- */
- package project
- import scaldi.{Injectable, Injector}
- class HostsService(implicit inj: Injector) extends Injectable {
- val googleHost = inject [String] (identified by "hosts.google")
- def getGoogleUrl = s"http://${googleHost}.com"
- }
- /**
- * ... main.scala
- */
- package project
- import project.HostsModule
- import project.HostsService
- object Main {
- def main(args: Array[String]): Unit = {
- val hostsService = new HostsService()
- println(hostsService.getGoogleUrl())
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement