+ // Authenticate
+ lc = new LoginContext(os);
+ lc.login();
+
+ // Prepare directories
+ String executionDir = System.getProperty("user.dir");
+ File slcDir = new File(executionDir, ".slc");
+ File tempDir = new File(System.getProperty("java.io.tmpdir"));
+
+ if (isTransient)
+ dataDir = new File(tempDir, "slc-data-"
+ + UUID.randomUUID().toString());
+ else
+ dataDir = new File(slcDir, "data");
+ if (!dataDir.exists())
+ dataDir.mkdirs();
+
+ File confDir = new File(slcDir, "conf");
+ if (!confDir.exists())
+ confDir.mkdirs();
+
+ System.setProperty("log4j.configuration", "file:./log4j.properties");
+ if (isTransient)
+ System.setProperty("argeo.node.repo.configuration",
+ "osgibundle:repository-memory.xml");
+
+ // Start Equinox
+ ServiceLoader<FrameworkFactory> ff = ServiceLoader
+ .load(FrameworkFactory.class);
+ FrameworkFactory frameworkFactory = ff.iterator().next();
+ Map<String, String> configuration = new HashMap<String, String>();
+ configuration.put("osgi.configuration.area",
+ confDir.getCanonicalPath());
+ configuration.put("osgi.instance.area", dataDir.getCanonicalPath());
+ // configuration.put("osgi.clean", "true");
+ // configuration.put("osgi.console", "");
+
+ // Spring configs currently require System properties
+ System.getProperties().putAll(configuration);
+
+ Framework framework = frameworkFactory.newFramework(configuration);
+ framework.start();
+ BundleContext bundleContext = framework.getBundleContext();
+ // String[] osgiRuntimeArgs = { "-configuration",
+ // confDir.getCanonicalPath(), "-data",
+ // dataDir.getCanonicalPath(), "-clean" };
+ // BundleContext bundleContext = EclipseStarter.startup(
+ // osgiRuntimeArgs, null);
+
+ // OSGi bootstrap
+ OsgiBoot osgiBoot = new OsgiBoot(bundleContext);
+ osgiBoot.installUrls(osgiBoot.getBundlesUrls(bundlesToInstall));
+
+ // Start runtime
+ osgiBoot.startBundles(bundlesToStart);
+
+ // Find SLC Agent
+ ServiceReference sr = null;
+ while (sr == null) {
+ sr = bundleContext
+ .getServiceReference("org.argeo.slc.execution.SlcAgentCli");
+ if (System.currentTimeMillis() - begin > timeout)
+ throw new RuntimeException("Cannot find SLC agent CLI");
+ Thread.sleep(100);