mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-12-31 12:50:05 +01:00
Pass ServletContext to Plugin
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package gitbucket.core.plugin
|
||||
|
||||
import javax.servlet.ServletContext
|
||||
import gitbucket.core.util.Version
|
||||
|
||||
/**
|
||||
@@ -17,12 +18,12 @@ trait Plugin {
|
||||
* This method is invoked in initialization of plugin system.
|
||||
* Register plugin functionality to PluginRegistry.
|
||||
*/
|
||||
def initialize(registry: PluginRegistry): Unit
|
||||
def initialize(registry: PluginRegistry, context: ServletContext, ): Unit
|
||||
|
||||
/**
|
||||
* This method is invoked in shutdown of plugin system.
|
||||
* If the plugin has any resources, release them in this method.
|
||||
*/
|
||||
def shutdown(registry: PluginRegistry): Unit
|
||||
def shutdown(registry: PluginRegistry, context: ServletContext, ): Unit
|
||||
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ object PluginRegistry {
|
||||
}
|
||||
|
||||
// Initialize
|
||||
plugin.initialize(instance)
|
||||
plugin.initialize(instance,context)
|
||||
instance.addPlugin(PluginInfo(
|
||||
pluginId = plugin.pluginId,
|
||||
pluginName = plugin.pluginName,
|
||||
@@ -140,7 +140,7 @@ object PluginRegistry {
|
||||
def shutdown(context: ServletContext): Unit = {
|
||||
instance.getPlugins().foreach { pluginInfo =>
|
||||
try {
|
||||
pluginInfo.pluginClass.shutdown(instance)
|
||||
pluginInfo.pluginClass.shutdown(instance, context)
|
||||
} catch {
|
||||
case e: Exception => {
|
||||
logger.error(s"Error during plugin shutdown", e)
|
||||
|
||||
Reference in New Issue
Block a user