diff --git a/ebean-api/src/main/java/io/ebean/DatabaseFactory.java b/ebean-api/src/main/java/io/ebean/DatabaseFactory.java index 8dbf05fd0..588f48c24 100644 --- a/ebean-api/src/main/java/io/ebean/DatabaseFactory.java +++ b/ebean-api/src/main/java/io/ebean/DatabaseFactory.java @@ -2,7 +2,6 @@ package io.ebean; import io.ebean.config.ContainerConfig; import io.ebean.config.DatabaseConfig; -import io.ebean.event.ShutdownManager; import io.ebean.service.SpiContainer; import io.ebean.service.SpiContainerFactory; @@ -46,7 +45,7 @@ public class DatabaseFactory { public static void initialiseContainer(ContainerConfig containerConfig) { lock.lock(); try { - getContainer(containerConfig); + container(containerConfig); } finally { lock.unlock(); } @@ -58,7 +57,7 @@ public class DatabaseFactory { public static Database create(String name) { lock.lock(); try { - return getContainer(null).createServer(name); + return container(null).createServer(name); } finally { lock.unlock(); } @@ -133,24 +132,16 @@ public class DatabaseFactory { } } - /** - * Removes the JVM shutdown hook and means the application must shut down ebean - * explicitly using {@link DatabaseFactory#shutdown()}. - */ - public static void disableShutdownHook() { - ShutdownManager.deregisterShutdownHook(); - } - private static Database createInternal(DatabaseConfig config) { - return getContainer(config.getContainerConfig()).createServer(config); + return container(config.getContainerConfig()).createServer(config); } /** - * Get the EbeanContainer initialising it if necessary. + * Return the SpiContainer initialising it if necessary. * * @param containerConfig the configuration controlling clustering communication */ - private static SpiContainer getContainer(ContainerConfig containerConfig) { + private static SpiContainer container(ContainerConfig containerConfig) { // thread safe in that all calling methods hold lock if (container != null) { return container; diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/lib/ShutdownManagerTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/lib/ShutdownManagerTest.java index f643597ed..c48756ed7 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/lib/ShutdownManagerTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/lib/ShutdownManagerTest.java @@ -17,12 +17,12 @@ public class ShutdownManagerTest extends BaseTestCase { @Test public void test_disableShutdownHook_shutdownManually() { // disable hook to make sure app code controls when shutdown is executed - DatabaseFactory.disableShutdownHook(); + ShutdownManager.deregisterShutdownHook(); DB.getDefault(); System.out.println("shutdown manually ... "); // application code explicitly calls shutdown() - DatabaseFactory.shutdown(); + ShutdownManager.shutdown(); } /** @@ -41,7 +41,7 @@ public class ShutdownManagerTest extends BaseTestCase { @Test public void test_disableShutdownHook() { DB.getDefault(); - DatabaseFactory.disableShutdownHook(); // no shutdown is run here (not great, don't do this) + ShutdownManager.deregisterShutdownHook(); // no shutdown is run here (not great, don't do this) } /**