Created
June 17, 2015 08:48
-
-
Save davegurnell/94fbf5087d8102167e05 to your computer and use it in GitHub Desktop.
PluginDemo.scala
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 FooPlugin { | |
| def name: String = | |
| // Get rid of synthetic '$'s in generated class names for singleton objects: | |
| getClass.getSimpleName.filterNot(_ == '$') | |
| // TODO: Insert Plugin Methods | |
| } | |
| object FooPlugin1 extends FooPlugin | |
| object FooPlugin2 extends FooPlugin | |
| object FooPlugin3 extends FooPlugin | |
| object FooPlugin extends SomeLoggingFramework { | |
| val all = Seq( | |
| FooPlugin1, | |
| FooPlugin2, | |
| FooPlugin3) | |
| def load(name: String): Option[FooPlugin] = { | |
| val optPlugin = all find (_.name == name) | |
| if(optPlugin.isEmpty) { | |
| logger.warn(s"HealthCheck plugin not found: $name") | |
| } | |
| optPlugin | |
| } | |
| def loadAll(names: Seq[String]): Seq[FooPlugin] = | |
| names flatMap load | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment