理解使用"这个:SomeClassOrTrait =>"在斯卡拉

时间:2014-12-18 17:14:54

标签: scala

以下CoreActors中的“ this:Core => ”是什么。

import akka.actor.ActorSystem
import com.demo.service.DemoService
import com.typesafe.config.ConfigFactory

trait Core {
  implicit def system: ActorSystem
}

trait BootedCore extends Core {
  implicit lazy val system = ActorSystem("demo-microservice-system")

  sys.addShutdownHook(system.shutdown())
}

trait ConfigHolder {
  val config = ConfigFactory.load()
}

trait CoreActors extends ConfigHolder {
  this: Core =>

  val demoService = system.actorOf(
    DemoService.props("identity"), "DemoService")

  val services: Services = Map(
    "demoService" -> demoService
  )
}

0 个答案:

没有答案