mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Refactor EbeanServerFactory internals - use SpiContainerShutdown interface for container shutdown mechanism
This commit is contained in:
@@ -3,11 +3,12 @@ package io.ebean;
|
||||
import io.ebean.common.SpiContainer;
|
||||
import io.ebean.config.ContainerConfig;
|
||||
import io.ebean.config.ServerConfig;
|
||||
import io.ebeaninternal.server.lib.ShutdownManager;
|
||||
import io.ebean.service.SpiContainerShutdown;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.Properties;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
* Creates EbeanServer instances.
|
||||
@@ -99,7 +100,9 @@ public class EbeanServerFactory {
|
||||
* </p>
|
||||
*/
|
||||
public static synchronized void shutdown() {
|
||||
ShutdownManager.shutdown();
|
||||
for (SpiContainerShutdown shutdown : ServiceLoader.load(SpiContainerShutdown.class)) {
|
||||
shutdown.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package io.ebean.service;
|
||||
|
||||
/**
|
||||
* Provides shutdown of the entire container.
|
||||
*/
|
||||
public interface SpiContainerShutdown {
|
||||
|
||||
/**
|
||||
* Shutdown the entire container - all EbeanServer instances.
|
||||
*/
|
||||
void shutdown();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package io.ebeaninternal.server.lib;
|
||||
|
||||
import io.ebean.service.SpiContainerShutdown;
|
||||
|
||||
/**
|
||||
* Default container shutdown implementation.
|
||||
*/
|
||||
public class DContainerShutdown implements SpiContainerShutdown {
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
ShutdownManager.shutdown();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user