Commit bb5f56b5 authored by michael.simon's avatar michael.simon
Browse files

Reload hooks together with appconfig

parent c3b2214b
......@@ -33,12 +33,10 @@ import edu.kit.scc.webreg.entity.SerialEntity;
import edu.kit.scc.webreg.entity.ServiceEntity;
import edu.kit.scc.webreg.service.AdminUserService;
import edu.kit.scc.webreg.service.GroupService;
import edu.kit.scc.webreg.service.GroupServiceHook;
import edu.kit.scc.webreg.service.RoleService;
import edu.kit.scc.webreg.service.SerialService;
import edu.kit.scc.webreg.service.ServiceService;
import edu.kit.scc.webreg.service.UserService;
import edu.kit.scc.webreg.service.UserServiceHook;
import edu.kit.scc.webreg.service.impl.HookManager;
import edu.kit.scc.webreg.service.mail.TemplateRenderer;
import edu.kit.scc.webreg.service.timer.StandardScheduler;
......@@ -155,6 +153,16 @@ public class ApplicationBootstrap {
standardScheduler.initialize();
}
public void reloadConfig() {
boolean reloaded = appConfig.reload();
if (reloaded) {
logger.info("Reloading Hooks");
hookManager.reloadUserHooks();
hookManager.reloadGroupHooks();
}
}
private void checkGroup(String name, Integer createActual) {
GroupEntity entity = groupService.findByName(name);
if (entity == null) {
......
......@@ -55,13 +55,18 @@ public class ApplicationConfig implements Serializable {
lastLoad = new Date();
}
public void reload() {
public boolean reload() {
ApplicationConfigEntity newAppConfig = dao.findReloadActive(lastLoad);
if (newAppConfig != null) {
logger.info("Reloading Application Configuration");
appConfig = newAppConfig;
lastLoad = new Date();
return true;
}
else {
return false;
}
}
......
......@@ -51,6 +51,7 @@ public class HookManager {
for (String hook : hooks) {
hook = hook.trim();
try {
logger.debug("installing hook {}", hook);
UserServiceHook h = (UserServiceHook) Class.forName(hook).newInstance();
h.setAppConfig(appConfig);
newUserHooks.add(h);
......@@ -77,6 +78,7 @@ public class HookManager {
for (String hook : hooks) {
hook = hook.trim();
try {
logger.debug("installing hook {}", hook);
GroupServiceHook h = (GroupServiceHook) Class.forName(hook).newInstance();
h.setAppConfig(appConfig);
newGroupHooks.add(h);
......
......@@ -26,7 +26,7 @@ import javax.inject.Inject;
import org.slf4j.Logger;
import edu.kit.scc.webreg.bootstrap.ApplicationConfig;
import edu.kit.scc.webreg.bootstrap.ApplicationBootstrap;
import edu.kit.scc.webreg.bootstrap.NodeConfiguration;
import edu.kit.scc.webreg.drools.BpmProcessService;
import edu.kit.scc.webreg.entity.JobClassEntity;
......@@ -62,7 +62,7 @@ public class StandardSchedulerImpl implements StandardScheduler, Serializable {
private BpmProcessService bpmProcessService;
@Inject
private ApplicationConfig appConfig;
private ApplicationBootstrap appBootstrap;
@Override
public void initialize() {
......@@ -159,7 +159,7 @@ public class StandardSchedulerImpl implements StandardScheduler, Serializable {
bpmProcessService.reload();
// Reload App Config here
appConfig.reload();
appBootstrap.reloadConfig();
}
private void cancelTimer(Timer t) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment