1 package org
.argeo
.init
.osgi
;
5 import org
.osgi
.framework
.BundleContext
;
6 import org
.osgi
.framework
.launch
.Framework
;
8 /** Monitors the runtime and can shut it down. */
9 public class AdminThread
extends Thread
{
10 public final static String PROP_ARGEO_OSGI_SHUTDOWN_FILE
= "argeo.osgi.shutdownFile";
11 private File shutdownFile
;
12 private final BundleContext bundleContext
;
14 public AdminThread(BundleContext bundleContext
) {
15 super("OSGi Boot Admin");
16 this.bundleContext
= bundleContext
;
17 if (System
.getProperty(PROP_ARGEO_OSGI_SHUTDOWN_FILE
) != null) {
18 shutdownFile
= new File(
19 System
.getProperty(PROP_ARGEO_OSGI_SHUTDOWN_FILE
));
20 if (!shutdownFile
.exists()) {
22 OsgiBootUtils
.warn("Shutdown file " + shutdownFile
23 + " not found, feature deactivated");
29 if (shutdownFile
!= null) {
30 // wait for file to be removed
31 while (shutdownFile
.exists()) {
34 } catch (InterruptedException e
) {
39 Framework framework
= (Framework
) bundleContext
.getBundle(0);
43 // wait 10 mins for shutdown
44 framework
.waitForStop(10 * 60 * 1000);
47 } catch (Exception e
) {