View difference between Paste ID: ruriZe09 and i7Jn0vZT
SHOW: | | - or go back to the newest paste.
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
object implicits {
14
	implicit val HostsModule = new HostsModule
15
}
16
/**
17
* ... HostsService.scala
18
*/
19
package project
20
21
import scaldi.{Injectable, Injector}
22
23
class HostsService(implicit inj: Injector) extends Injectable {
24
25
    val googleHost = inject [String] (identified by "hosts.google")
26
27
    def getGoogleUrl = s"http://${googleHost}.com"
28
}
29
30
31
/**
32
* ... main.scala
33
*/
34
35-
import HostsModule
35+
36
37
import implicits.HostsModule
38
import HostsService
39
40
object Main {
41
    def main(args: Array[String]): Unit = { 
42
        val hostsService = new HostsService()
43
        println(hostsService.getGoogleUrl())
44
    }
45
}