mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 08:31:07 +03:00
[FIX] Hibernate reload fix
This commit is contained in:
parent
56e1920a8d
commit
44f3a17973
3 changed files with 17 additions and 6 deletions
|
@ -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");
|
||||
|
|
|
@ -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,12 +170,18 @@ public void close(LaunchServer.ReloadType type) {
|
|||
} catch (Exception e) {
|
||||
LogHelper.error(e);
|
||||
}
|
||||
if(dao != null) {
|
||||
server.unregisterObject("dao", dao);
|
||||
if(dao instanceof AutoCloseable)
|
||||
{
|
||||
try {
|
||||
for (AuthProviderPair p : auth.values()) p.close();
|
||||
} catch (IOException e) {
|
||||
((AutoCloseable) dao).close();
|
||||
} catch (Exception e) {
|
||||
LogHelper.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ExeConf {
|
||||
public boolean enabled;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue