Commit b91afff6 authored by Michel Schudel's avatar Michel Schudel

geen requests doorlaten zolang de initialisatiefase nog niet voorbij is.

parent b7b62f86
......@@ -44,6 +44,6 @@ class ApplicationStartedListener implements ApplicationListener<ApplicationStart
network.connectToNetwork();
blockchainService.init();
signatureService.init();
startedInterceptor.setOpen(true);
startedInterceptor.open();
}
}
package nl.craftsmen.blockchain.craftscoinnode;
import nl.craftsmen.blockchain.craftscoinnode.util.GenericRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
......@@ -7,17 +10,19 @@ import javax.servlet.http.HttpServletResponse;
public class StartedInterceptor implements HandlerInterceptor {
private boolean isOpen = false;
private static final Logger LOGGER = LoggerFactory.getLogger(StartedInterceptor.class);
private boolean open = false;
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
if (!isOpen) {
if (!open) {
throw new RuntimeException("no open for business yet!");
} else {
return true;
}
}
public void setOpen(boolean open) {
isOpen = open;
void open() {
this.open = true;
LOGGER.info("Node is open for business.");
}
}
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