Rename OSGi Boot to Argeo Init and introduce logging framework.
[lgpl/argeo-commons.git] / org.argeo.init / src / org / argeo / init / StaticRuntimeContext.java
diff --git a/org.argeo.init/src/org/argeo/init/StaticRuntimeContext.java b/org.argeo.init/src/org/argeo/init/StaticRuntimeContext.java
new file mode 100644 (file)
index 0000000..e01e619
--- /dev/null
@@ -0,0 +1,35 @@
+package org.argeo.init;
+
+import java.util.Map;
+
+public class StaticRuntimeContext implements RuntimeContext {
+       private Map<String, String> config;
+
+       private boolean running = false;
+
+       protected StaticRuntimeContext(Map<String, String> config) {
+               this.config = config;
+       }
+
+       @Override
+       public synchronized void run() {
+               running = true;
+               notifyAll();
+       }
+
+       @Override
+       public void waitForStop(long timeout) throws InterruptedException {
+               long begin = System.currentTimeMillis();
+               while (running && (timeout == 0 || System.currentTimeMillis() - begin < timeout)) {
+                       synchronized (this) {
+                               wait(500);
+                       }
+               }
+       }
+
+       @Override
+       public synchronized void close() throws Exception {
+               running = false;
+       }
+
+}