public void installAll(List<BundleFile> bundles) throws BundleException { for (BundleFile bf : bundles) { install(new BundleImpl(this, bf, classLoader.getLoader())); } }
@Override public void installBundle(BundleFile bundleFile) throws BundleException { osgi.install(new BundleImpl(osgi, bundleFile, loader.getLoader())); }
protected void startBundles(List<BundleFile> bundles) throws BundleException { for (BundleFile bf : bundles) { this.install(new BundleImpl(this, bf, classLoader.getLoader())); } }
public void install(BundleFile bf) throws BundleException { install(new BundleImpl(this, bf, classLoader.getLoader())); }
public static void main(String[] args) throws Exception { File home = new File("/tmp/test_osgi_loader"); OSGiAdapter osgi = new OSGiAdapter(home); System.out.println("Starting ..."); StandaloneBundleLoader loader = new StandaloneBundleLoader(osgi); Thread.currentThread().setContextClassLoader(loader.loader.getLoader()); double s = System.currentTimeMillis(); try { loader.setExtractNestedJARs(true); loader.setScanForNestedJARs(true); List<BundleFile> bundles = new ArrayList<BundleFile>(); List<BundleFile> jars = new ArrayList<BundleFile>(); loader.load(new File("/opt/jboss/server/default/deploy/nuxeo.ear"), bundles, jars); loader.installAll(bundles); System.out.println(">>>> Loading done!!!!"); } finally { System.out.println("Shutting down"); osgi.shutdown(); } double e = System.currentTimeMillis(); System.out.println("Total time: " + ((e - s) / 1000) + " sec."); System.exit(0); }
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(); } }
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 ClassLoader loadBundles(List<File> classPath) throws IOException, BundleException { // create the standalone loader bundleLoader = new StandaloneBundleLoader(app, app.getSharedClassLoader()); Thread.currentThread().setContextClassLoader(bundleLoader.getSharedClassLoader().getLoader()); aboutToStartRuntime(); boolean scan = true; File file = getCacheFile(); if (useCache) { if (file.isFile()) { // use the cache scan = false; try { fastLoad(file); } catch (IOException e) { scan = true; } catch (BundleException e) { scan = true; } } } if (scan) { List<BundleFile> bundles = new ArrayList<BundleFile>(); List<BundleFile> jars = new ArrayList<BundleFile>(); scanAndLoad(classPath, bundles, jars); writeCache(file, bundles, jars); app.installAll(bundles); } // that's all runtimeStarted(); return bundleLoader.getSharedClassLoader().getLoader(); }