]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.init/src/org/argeo/init/StaticRuntimeContext.java
Simplify multi-runtime
[lgpl/argeo-commons.git] / org.argeo.init / src / org / argeo / init / StaticRuntimeContext.java
1 package org.argeo.init;
2
3 import java.util.Map;
4
5 import org.argeo.api.init.RuntimeContext;
6
7 public class StaticRuntimeContext implements RuntimeContext {
8 private Map<String, String> config;
9
10 private boolean running = false;
11
12 protected StaticRuntimeContext(Map<String, String> config) {
13 this.config = config;
14 }
15
16 @Override
17 public synchronized void run() {
18 running = true;
19 notifyAll();
20 }
21
22 @Override
23 public void waitForStop(long timeout) throws InterruptedException {
24 long begin = System.currentTimeMillis();
25 while (running && (timeout == 0 || System.currentTimeMillis() - begin < timeout)) {
26 synchronized (this) {
27 wait(500);
28 }
29 }
30 }
31
32 @Override
33 public synchronized void close() throws Exception {
34 running = false;
35 }
36
37 }