+ /** Executes a single flow and <b>stops the JVM</b> */
+ protected void executeFlowAndExit(final String module,
+ final String version, final String flow) {
+ if (log.isDebugEnabled())
+ log.debug("Launch unique flow " + flow + " from module " + module);
+ try {
+ OsgiBundle osgiBundle = bundlesManager.findFromPattern(module);
+ if (osgiBundle == null)
+ throw new SlcException("No OSGi bundle found for " + 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);
+ }
+ }