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. */
10 public class AdminThread
extends Thread
{
11 public final static String PROP_ARGEO_OSGI_SHUTDOWN_FILE
= "argeo.osgi.shutdownFile";
12 private File shutdownFile
;
13 private final BundleContext bundleContext
;
15 public AdminThread(BundleContext bundleContext
) {
16 super("OSGi Boot Admin");
17 this.bundleContext
= bundleContext
;
18 if (System
.getProperty(PROP_ARGEO_OSGI_SHUTDOWN_FILE
) != null) {
19 shutdownFile
= new File(
20 System
.getProperty(PROP_ARGEO_OSGI_SHUTDOWN_FILE
));
21 if (!shutdownFile
.exists()) {
23 OsgiBootUtils
.warn("Shutdown file " + shutdownFile
24 + " not found, feature deactivated");
30 if (shutdownFile
!= null) {
31 // wait for file to be removed
32 while (shutdownFile
.exists()) {
35 } catch (InterruptedException e
) {
40 Framework framework
= (Framework
) bundleContext
.getBundle(0);
44 // wait 10 mins for shutdown
45 framework
.waitForStop(10 * 60 * 1000);
48 } catch (Exception e
) {