spice.ImplementationManager.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spice-core_sjs1_3 Show documentation
Show all versions of spice-core_sjs1_3 Show documentation
Core functionality leveraged and shared by most other sub-projects of Spice.
package spice
import moduload.Moduload
trait ImplementationManager[Implementation, Config] {
private var creator: Option[Config => Implementation] = None
Moduload.load()
def apply(config: Config): Implementation = creator
.getOrElse(throw new NoImplementationException)
.apply(config)
def register(creator: Config => Implementation): Unit = synchronized {
require(this.creator.isEmpty, "An implementation manager is already registered!")
this.creator = Some(creator)
}
}