mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#394 - ENH: Add plugin API SpiServer - add shutdown() method to SpiServerPlugin.
This commit is contained in:
@@ -14,4 +14,12 @@ public interface SpiServerPlugin {
|
||||
* Called just before the server starts indicating if it is coming up in online mode.
|
||||
*/
|
||||
void online(boolean online);
|
||||
|
||||
/**
|
||||
* Called when the server is shutting down.
|
||||
* <p>
|
||||
* Plugins should shutdown any resources they are using cleanly.
|
||||
* </p>
|
||||
*/
|
||||
void shutdown();
|
||||
}
|
||||
|
||||
@@ -438,6 +438,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
// Already shutdown
|
||||
return;
|
||||
}
|
||||
shutdownPlugins();
|
||||
try {
|
||||
if (mbeanServer != null) {
|
||||
mbeanServer.unregisterMBean(new ObjectName(mbeanName + ",key=AutoFetch"));
|
||||
@@ -454,7 +455,18 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
transactionManager.shutdown(shutdownDataSource, deregisterDriver);
|
||||
shutdown = true;
|
||||
}
|
||||
|
||||
|
||||
private void shutdownPlugins() {
|
||||
|
||||
for (SpiServerPlugin plugin : serverPlugins) {
|
||||
try {
|
||||
plugin.shutdown();
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error when shutting down plugin", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the server name.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user