diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index c0a511f1..a6cfed89 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -98,7 +98,6 @@ public void reload(ReloadType type) throws Exception { LogHelper.debug("Init components"); config.components.forEach((k, v) -> { LogHelper.subDebug("Init component %s", k); - registerObject("component.".concat(k), v); v.init(this); }); LogHelper.debug("Init components successful"); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java b/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java index ea387fb5..0c81b263 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java @@ -152,6 +152,7 @@ public void close(LaunchServer.ReloadType type) { server.unregisterObject("auth.".concat(pair.name).concat(".provider"), pair.provider); server.unregisterObject("auth.".concat(pair.name).concat(".handler"), pair.handler); server.unregisterObject("auth.".concat(pair.name).concat(".texture"), pair.textureProvider); + pair.close(); } } if (type.equals(LaunchServer.ReloadType.FULL)) { @@ -169,10 +170,16 @@ public void close(LaunchServer.ReloadType type) { } catch (Exception e) { LogHelper.error(e); } - try { - for (AuthProviderPair p : auth.values()) p.close(); - } catch (IOException e) { - LogHelper.error(e); + if(dao != null) { + server.unregisterObject("dao", dao); + if(dao instanceof AutoCloseable) + { + try { + ((AutoCloseable) dao).close(); + } catch (Exception e) { + LogHelper.error(e); + } + } } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/provider/HibernateDaoProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/provider/HibernateDaoProvider.java index ae3520c3..3d4eb72b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/provider/HibernateDaoProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/provider/HibernateDaoProvider.java @@ -17,7 +17,7 @@ import java.util.HashMap; import java.util.Map; -public class HibernateDaoProvider extends DaoProvider implements Reconfigurable { +public class HibernateDaoProvider extends DaoProvider implements Reconfigurable, AutoCloseable { public String driver; public String url; public String username; @@ -113,4 +113,9 @@ public void invoke(String... args) throws Exception { }); return commands; } + + @Override + public void close() throws Exception { + sessionFactory.close(); + } }