Improve declarative Plugin definition interface

This commit is contained in:
Naoki Takezoe
2015-06-27 20:54:19 +09:00
parent 6f3f3eaa99
commit 5b445c9736
2 changed files with 25 additions and 5 deletions

2
env.sh
View File

@@ -1,2 +1,2 @@
#!/bin/sh
export GITBUCKET_VERSION=3.4.0
export GITBUCKET_VERSION=3.4.1-SNAPSHOT

View File

@@ -22,36 +22,56 @@ trait Plugin {
*/
val images: Seq[(String, Array[Byte])] = Nil
/**
* Override to declare this plug-in provides images.
*/
def images(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Seq[(String, Array[Byte])] = Nil
/**
* Override to declare this plug-in provides controllers.
*/
val controllers: Seq[(String, ControllerBase)] = Nil
/**
* Override to declare this plug-in provides controllers.
*/
def controllers(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Seq[(String, ControllerBase)] = Nil
/**
* Override to declare this plug-in provides JavaScript.
*/
val javaScripts: Seq[(String, String)] = Nil
/**
* Override to declare this plug-in provides JavaScript.
*/
def javaScripts(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Seq[(String, String)] = Nil
/**
* Override to declare this plug-in provides renderers.
*/
val renderers: Seq[(String, Renderer)] = Nil
/**
* Override to declare this plug-in provides renderers.
*/
def renderers(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Seq[(String, Renderer)] = Nil
/**
* This method is invoked in initialization of plugin system.
* Register plugin functionality to PluginRegistry.
*/
def initialize(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Unit = {
images.foreach { case (id, in) =>
(images ++ images(registry, context, settings)).foreach { case (id, in) =>
registry.addImage(id, in)
}
controllers.foreach { case (path, controller) =>
(controllers ++ controllers(registry, context, settings)).foreach { case (path, controller) =>
registry.addController(path, controller)
}
javaScripts.foreach { case (path, script) =>
(javaScripts ++ javaScripts(registry, context, settings)).foreach { case (path, script) =>
registry.addJavaScript(path, script)
}
renderers.foreach { case (extension, renderer) =>
(renderers ++ renderers(registry, context, settings)).foreach { case (extension, renderer) =>
registry.addRenderer(extension, renderer)
}
}