Advertisement
Guest User

Untitled

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