Scala 深刻淺出實戰經典 第57講:Scala中Dependency Injection實戰詳解

王家林親授《DT大數據夢工廠》大數據實戰視頻 Scala 深刻淺出實戰經典(1-87講)完整視頻、PPT、代碼下載:
百度雲盤:http://pan.baidu.com/s/1c0noOt6
騰訊微雲:http://url.cn/TnGbdC
360雲盤:http://yunpan.cn/cQ4c2UALDjSKy 訪問密碼 45e2
土豆:http://www.tudou.com/programs/view/5LnLNDBKvi8/
優酷:http://v.youku.com/v_show/id_XMTI4NzM2OTkzMg==.html?from=s1.8-1-1.2
愛奇藝:http://www.iqiyi.com/w_19rrt84uth.html#vfrm=2-3-0-1
騰訊視頻:http://v.qq.com/boke/page/x/0/2/x0159h4oa22.html
技術愛好者尤爲是大數據愛好者 能夠加DT大數據夢工廠的qq羣html

DT大數據夢工廠① :462923555
DT大數據夢工廠②:437123764
DT大數據夢工廠③ :418110145微信

微信公衆帳號: DT_Spark
王家林老師微信號: 18610086859
王家林老師QQ: 1740415547
王家林老師郵箱: 18610086859@126.comide

本視頻由王家林老師, 親自講解, 徹底經過代碼實戰把您帶人大數據的時代.大數據

package com.parllay.scala.type_parameterizitor

/**
* Created by richard on 15-8-13.
* 第57講:Scala中Dependency Injection實戰詳解
*/

trait Logger { def log (msg:String)}
trait Auth {
auth : Logger => //this別名, 在這裏沒有使用this, 而使用了auth, 能夠使用除了this之外的名字
def act( msg : String ): Unit = {
auth.log(msg) //一樣後邊的log也不須要手動增長前綴 auth.log(msg),會被識別爲auth.log(msg)。
}
}

/**
* DI在繼承Auth的時候必須實現trait Logger. 這裏必須有 with Logger,不然報 Main.type 不符合 Auth's selftype Auth with Logger
*/
object DI extends Auth with Logger {
override def log( msg : String ) = println(msg)
}

object Dependency_Injection {

def main(args: Array[String]) {

DI.act("I hope you'll like it")

}

}

  

網站計數器
相關文章
相關標籤/搜索