Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2. * HostsModule.scala
  3. */
  4. package project
  5.  
  6. import scaldi.Module
  7.  
  8. class HostsModule extends Module {
  9.     binding identifiedBy "hosts.google"   to "google.com"
  10.     binding identifiedBy "hosts.yahoo"    to "yahoo.com"
  11.     binding identifiedBy "hosts.facebook" to "facebook.com"
  12. }
  13.  
  14. /**
  15. * ... HostsService.scala
  16. */
  17. package project
  18.  
  19. import scaldi.{Injectable, Injector}
  20.  
  21. class HostsService(implicit inj: Injector) extends Injectable {
  22.  
  23.     val googleHost = inject [String] (identified by "hosts.google")
  24.  
  25.     def getGoogleUrl = s"http://${googleHost}.com"
  26. }
  27.  
  28.  
  29. /**
  30. * ... main.scala
  31. */
  32.  
  33. package project
  34.  
  35. import HostsModule
  36. import HostsService
  37.  
  38. object Main {
  39.     def main(args: Array[String]): Unit = {
  40.         val hostsService = new HostsService()
  41.         println(hostsService.getGoogleUrl())
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement