Created
July 6, 2014 07:16
-
-
Save choplin/c392cfb9755f78380476 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Lifecycle { | |
def startup(): Unit | |
def shutdown(): Unit | |
} | |
trait FooModule extends Lifecycle { | |
abstract override def startup() { | |
super.startup() | |
println("startup foo") | |
} | |
abstract override def shutdown() { | |
super.shutdown() | |
println("shutdown foo") | |
} | |
} | |
trait BarModule extends Lifecycle { | |
abstract override def startup() { | |
super.startup() | |
println("startup bar") | |
} | |
} | |
trait LifecycleImpl extends Lifecycle { | |
override def startup() { println("startup") } | |
override def shutdown() { println("shutdown") } | |
} | |
trait Application extends LifecycleImpl | |
object Main { | |
def main(args: Array[String]) = { | |
val app = new Application with FooModule with BarModule {} | |
app.startup() | |
app.shutdown() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment