Refactor EbeanServerFactory internals - use SpiContainerShutdown interface for container shutdown mechanism

This commit is contained in:
rob bygrave
2017-10-05 00:57:40 +13:00
parent 0bf4c84bc8
commit 3471f6d206
5 changed files with 34 additions and 4 deletions
@@ -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();
}
}
@@ -0,0 +1 @@
io.ebeaninternal.server.lib.DContainerShutdown
+2 -2
View File
@@ -18,7 +18,7 @@
from o_order_detail d
group by d.order_id;
</ddl-script>
<ddl-script name="order views sqlite" platforms="sqlite">
drop view if exists order_agg_vw;
create view order_agg_vw as
@@ -28,7 +28,7 @@
group by d.order_id;
</ddl-script>
<ddl-script name="order views mssql" platforms="sqlserver">
IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = 'order_agg_vw')
DROP VIEW order_agg_vw;