mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-01 19:15:59 +01:00
Added Plugin.uninstall() method to cleanup, but remove for now
This commit is contained in:
@@ -248,11 +248,17 @@ abstract class Plugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is invoked in shutdown of plugin system.
|
||||
* This method is invoked when the plugin system is shutting down.
|
||||
* If the plugin has any resources, release them in this method.
|
||||
*/
|
||||
def shutdown(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Unit = {}
|
||||
|
||||
// /**
|
||||
// * This method is invoked when this plugin is uninstalled.
|
||||
// * Cleanup database or any other resources in this method if necessary.
|
||||
// */
|
||||
// def uninstall(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Unit = {}
|
||||
|
||||
/**
|
||||
* Helper method to get a resource from classpath.
|
||||
*/
|
||||
|
||||
@@ -181,8 +181,13 @@ object PluginRegistry {
|
||||
*/
|
||||
def uninstall(pluginId: String, context: ServletContext, settings: SystemSettings, conn: java.sql.Connection): Unit = synchronized {
|
||||
instance.getPlugins().find(_.pluginId == pluginId).foreach { plugin =>
|
||||
// try {
|
||||
// plugin.pluginClass.uninstall(instance, context, settings)
|
||||
// } catch {
|
||||
// case e: Exception =>
|
||||
// logger.error(s"Error during uninstalling plugin: ${plugin.pluginJar.getName}", e)
|
||||
// }
|
||||
shutdown(context, settings)
|
||||
// TODO kick uninstall action here?
|
||||
plugin.pluginJar.delete()
|
||||
instance = new PluginRegistry()
|
||||
initialize(context, settings, conn)
|
||||
@@ -260,15 +265,15 @@ object PluginRegistry {
|
||||
}
|
||||
|
||||
def shutdown(context: ServletContext, settings: SystemSettings): Unit = synchronized {
|
||||
instance.getPlugins().foreach { pluginInfo =>
|
||||
instance.getPlugins().foreach { plugin =>
|
||||
try {
|
||||
pluginInfo.pluginClass.shutdown(instance, context, settings)
|
||||
plugin.pluginClass.shutdown(instance, context, settings)
|
||||
} catch {
|
||||
case e: Exception => {
|
||||
logger.error(s"Error during plugin shutdown: ${pluginInfo.pluginJar.getName}", e)
|
||||
logger.error(s"Error during plugin shutdown: ${plugin.pluginJar.getName}", e)
|
||||
}
|
||||
} finally {
|
||||
pluginInfo.classLoader.close()
|
||||
plugin.classLoader.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user