mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-02 11:36:05 +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.
|
* If the plugin has any resources, release them in this method.
|
||||||
*/
|
*/
|
||||||
def shutdown(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Unit = {}
|
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.
|
* 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 {
|
def uninstall(pluginId: String, context: ServletContext, settings: SystemSettings, conn: java.sql.Connection): Unit = synchronized {
|
||||||
instance.getPlugins().find(_.pluginId == pluginId).foreach { plugin =>
|
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)
|
shutdown(context, settings)
|
||||||
// TODO kick uninstall action here?
|
|
||||||
plugin.pluginJar.delete()
|
plugin.pluginJar.delete()
|
||||||
instance = new PluginRegistry()
|
instance = new PluginRegistry()
|
||||||
initialize(context, settings, conn)
|
initialize(context, settings, conn)
|
||||||
@@ -260,15 +265,15 @@ object PluginRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def shutdown(context: ServletContext, settings: SystemSettings): Unit = synchronized {
|
def shutdown(context: ServletContext, settings: SystemSettings): Unit = synchronized {
|
||||||
instance.getPlugins().foreach { pluginInfo =>
|
instance.getPlugins().foreach { plugin =>
|
||||||
try {
|
try {
|
||||||
pluginInfo.pluginClass.shutdown(instance, context, settings)
|
plugin.pluginClass.shutdown(instance, context, settings)
|
||||||
} catch {
|
} catch {
|
||||||
case e: Exception => {
|
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 {
|
} finally {
|
||||||
pluginInfo.classLoader.close()
|
plugin.classLoader.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user