public static void main(URL systemBundle, List<File> classPath, String[] args) throws Exception { SharedClassLoader classLoader = (SharedClassLoader) Thread.currentThread().getContextClassLoader(); long startTime = System.currentTimeMillis(); // parse command line args StandaloneApplication.args = args; options = new CommandLineOptions(args); // start framework StandaloneApplication app = createInstance(classLoader); // start level 0 app.setClassPath(classPath); app.setSystemBundle(new SystemBundle(app, createSystemBundle(systemBundle), classLoader.getLoader())); // start level 1 app.start(); log.info("Framework started in " + ((System.currentTimeMillis() - startTime) / 1000) + " sec."); if (mainTask != null) { mainTask.run(); } }
public void setSystemBundle(SystemBundle systemBundle) throws BundleException { if (this.systemBundle != null) { throw new IllegalStateException("Cannot set system bundle"); } install(systemBundle); registry.addBundleAlias("system.bundle", systemBundle.getSymbolicName()); this.systemBundle = systemBundle; systemBundle.getBundleContext().registerService(PackageAdmin.class.getName(), new PackageAdminImpl(this), null); }
BundleFile bf = new SystemBundleFile(workingDir); bundleLoader = new StandaloneBundleLoader(osgi, RuntimeHarnessImpl.class.getClassLoader()); SystemBundle systemBundle = new SystemBundle(osgi, bf, bundleLoader.getSharedClassLoader().getLoader()); osgi.setSystemBundle(systemBundle); Thread.currentThread().setContextClassLoader(bundleLoader.getSharedClassLoader().getLoader());
public void fireFrameworkStarted() throws BundleException { if (osgi.getSystemBundle() == null) { SystemBundleFile file; try { file = new SystemBundleFile(osgi.getWorkingDir()); } catch (IOException e) { throw new BundleException("Cannot create system bundle file", e); } osgi.setSystemBundle(new SystemBundle(osgi, file, loader)); } osgi.fireFrameworkEvent(new FrameworkEvent(FrameworkEvent.STARTED, osgi.getSystemBundle(), null)); }
private static void doStart() throws BundleException { printStartMessage(); // install system bundle first BundleFile bf; try { bf = new SystemBundleFile(home); } catch (IOException e) { throw new BundleException("Cannot create system bundle for " + home, e); } SystemBundle systemBundle = new SystemBundle(osgi, bf, loader); osgi.setSystemBundle(systemBundle); printDeploymentOrderInfo(bundleFiles); for (File f : bundleFiles) { if (!isBundle(f)) { continue; } try { install(f); } catch (IOException | BundleException | RuntimeException e) { log.error("Failed to install bundle: " + f, e); } } osgi.fireFrameworkEvent(new FrameworkEvent(FrameworkEvent.STARTED, systemBundle, null)); // osgi.fireFrameworkEvent(new // FrameworkEvent(FrameworkEvent.AFTER_START, systemBundle, null)); }