Skip to content

Instantly share code, notes, and snippets.

@choplin
Created July 6, 2014 07:16
Show Gist options
  • Save choplin/c392cfb9755f78380476 to your computer and use it in GitHub Desktop.
Save choplin/c392cfb9755f78380476 to your computer and use it in GitHub Desktop.
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