mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +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");
|
LogHelper.debug("Init components");
|
||||||
config.components.forEach((k, v) -> {
|
config.components.forEach((k, v) -> {
|
||||||
LogHelper.subDebug("Init component %s", k);
|
LogHelper.subDebug("Init component %s", k);
|
||||||
registerObject("component.".concat(k), v);
|
|
||||||
v.init(this);
|
v.init(this);
|
||||||
});
|
});
|
||||||
LogHelper.debug("Init components successful");
|
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(".provider"), pair.provider);
|
||||||
server.unregisterObject("auth.".concat(pair.name).concat(".handler"), pair.handler);
|
server.unregisterObject("auth.".concat(pair.name).concat(".handler"), pair.handler);
|
||||||
server.unregisterObject("auth.".concat(pair.name).concat(".texture"), pair.textureProvider);
|
server.unregisterObject("auth.".concat(pair.name).concat(".texture"), pair.textureProvider);
|
||||||
|
pair.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type.equals(LaunchServer.ReloadType.FULL)) {
|
if (type.equals(LaunchServer.ReloadType.FULL)) {
|
||||||
|
@ -169,10 +170,16 @@ public void close(LaunchServer.ReloadType type) {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogHelper.error(e);
|
LogHelper.error(e);
|
||||||
}
|
}
|
||||||
try {
|
if(dao != null) {
|
||||||
for (AuthProviderPair p : auth.values()) p.close();
|
server.unregisterObject("dao", dao);
|
||||||
} catch (IOException e) {
|
if(dao instanceof AutoCloseable)
|
||||||
LogHelper.error(e);
|
{
|
||||||
|
try {
|
||||||
|
((AutoCloseable) dao).close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogHelper.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class HibernateDaoProvider extends DaoProvider implements Reconfigurable {
|
public class HibernateDaoProvider extends DaoProvider implements Reconfigurable, AutoCloseable {
|
||||||
public String driver;
|
public String driver;
|
||||||
public String url;
|
public String url;
|
||||||
public String username;
|
public String username;
|
||||||
|
@ -113,4 +113,9 @@ public void invoke(String... args) throws Exception {
|
||||||
});
|
});
|
||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws Exception {
|
||||||
|
sessionFactory.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue