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; ...@@ -33,12 +33,10 @@ import edu.kit.scc.webreg.entity.SerialEntity;
import edu.kit.scc.webreg.entity.ServiceEntity; import edu.kit.scc.webreg.entity.ServiceEntity;
import edu.kit.scc.webreg.service.AdminUserService; import edu.kit.scc.webreg.service.AdminUserService;
import edu.kit.scc.webreg.service.GroupService; 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.RoleService;
import edu.kit.scc.webreg.service.SerialService; import edu.kit.scc.webreg.service.SerialService;
import edu.kit.scc.webreg.service.ServiceService; import edu.kit.scc.webreg.service.ServiceService;
import edu.kit.scc.webreg.service.UserService; 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.impl.HookManager;
import edu.kit.scc.webreg.service.mail.TemplateRenderer; import edu.kit.scc.webreg.service.mail.TemplateRenderer;
import edu.kit.scc.webreg.service.timer.StandardScheduler; import edu.kit.scc.webreg.service.timer.StandardScheduler;
...@@ -155,6 +153,16 @@ public class ApplicationBootstrap { ...@@ -155,6 +153,16 @@ public class ApplicationBootstrap {
standardScheduler.initialize(); 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) { private void checkGroup(String name, Integer createActual) {
GroupEntity entity = groupService.findByName(name); GroupEntity entity = groupService.findByName(name);
if (entity == null) { if (entity == null) {
......
...@@ -55,13 +55,18 @@ public class ApplicationConfig implements Serializable { ...@@ -55,13 +55,18 @@ public class ApplicationConfig implements Serializable {
lastLoad = new Date(); lastLoad = new Date();
} }
public void reload() { public boolean reload() {
ApplicationConfigEntity newAppConfig = dao.findReloadActive(lastLoad); ApplicationConfigEntity newAppConfig = dao.findReloadActive(lastLoad);
if (newAppConfig != null) { if (newAppConfig != null) {
logger.info("Reloading Application Configuration"); logger.info("Reloading Application Configuration");
appConfig = newAppConfig; appConfig = newAppConfig;
lastLoad = new Date(); lastLoad = new Date();
return true;
}
else {
return false;
} }
} }
......
...@@ -51,6 +51,7 @@ public class HookManager { ...@@ -51,6 +51,7 @@ public class HookManager {
for (String hook : hooks) { for (String hook : hooks) {
hook = hook.trim(); hook = hook.trim();
try { try {
logger.debug("installing hook {}", hook);
UserServiceHook h = (UserServiceHook) Class.forName(hook).newInstance(); UserServiceHook h = (UserServiceHook) Class.forName(hook).newInstance();
h.setAppConfig(appConfig); h.setAppConfig(appConfig);
newUserHooks.add(h); newUserHooks.add(h);
...@@ -77,6 +78,7 @@ public class HookManager { ...@@ -77,6 +78,7 @@ public class HookManager {
for (String hook : hooks) { for (String hook : hooks) {
hook = hook.trim(); hook = hook.trim();
try { try {
logger.debug("installing hook {}", hook);
GroupServiceHook h = (GroupServiceHook) Class.forName(hook).newInstance(); GroupServiceHook h = (GroupServiceHook) Class.forName(hook).newInstance();
h.setAppConfig(appConfig); h.setAppConfig(appConfig);
newGroupHooks.add(h); newGroupHooks.add(h);
......
...@@ -26,7 +26,7 @@ import javax.inject.Inject; ...@@ -26,7 +26,7 @@ import javax.inject.Inject;
import org.slf4j.Logger; 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.bootstrap.NodeConfiguration;
import edu.kit.scc.webreg.drools.BpmProcessService; import edu.kit.scc.webreg.drools.BpmProcessService;
import edu.kit.scc.webreg.entity.JobClassEntity; import edu.kit.scc.webreg.entity.JobClassEntity;
...@@ -62,7 +62,7 @@ public class StandardSchedulerImpl implements StandardScheduler, Serializable { ...@@ -62,7 +62,7 @@ public class StandardSchedulerImpl implements StandardScheduler, Serializable {
private BpmProcessService bpmProcessService; private BpmProcessService bpmProcessService;
@Inject @Inject
private ApplicationConfig appConfig; private ApplicationBootstrap appBootstrap;
@Override @Override
public void initialize() { public void initialize() {
...@@ -159,7 +159,7 @@ public class StandardSchedulerImpl implements StandardScheduler, Serializable { ...@@ -159,7 +159,7 @@ public class StandardSchedulerImpl implements StandardScheduler, Serializable {
bpmProcessService.reload(); bpmProcessService.reload();
// Reload App Config here // Reload App Config here
appConfig.reload(); appBootstrap.reloadConfig();
} }
private void cancelTimer(Timer t) { 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