+ public void init() throws Exception {
+ final String module = System.getProperty(UNIQUE_LAUNCH_MODULE_PROPERTY);
+ final String flow = System.getProperty(UNIQUE_LAUNCH_FLOW_PROPERTY);
+ if (module != null) {
+ // launch a flow and stops
+ new Thread("Unique Flow") {
+ @Override
+ public void run() {
+ if (log.isDebugEnabled())
+ log.debug("Launch unique flow " + flow
+ + " from module " + module);
+ try {
+ OsgiBundle osgiBundle = bundlesManager
+ .findFromPattern(module);
+ Bundle moduleBundle = bundlesManager
+ .findRelatedBundle(osgiBundle);
+ bundlesManager.startSynchronous(moduleBundle);
+ RealizedFlow lastLaunch = findRealizedFlow(module, flow);
+ if (lastLaunch == null)
+ throw new SlcException("Cannot find launch for "
+ + module + " " + flow);
+ execute(lastLaunch);
+ } catch (Exception e) {
+ log.error("Error in unique flow " + flow
+ + " from module " + module, e);
+ } finally {
+ if (log.isDebugEnabled())
+ log.debug("Shutdown OSGi runtime...");
+ Framework framework = (Framework) bundlesManager
+ .getBundleContext().getBundle(0);
+ try {
+ // shutdown framework
+ framework.stop();
+ // wait 1 min for shutdown
+ framework.waitForStop(60 * 1000);
+ // close VM
+ System.exit(0);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+ }
+ }.start();
+ }
+
+ }
+
+ public void destroy() {
+
+ }
+