Esempio n. 1
0
 /**
  * Deploys a whole OSGI bundle.
  *
  * <p>The lookup is first done on symbolic name, as set in <code>MANIFEST.MF</code> and then falls
  * back to the bundle url (e.g., <code>nuxeo-platform-search-api</code>) for backwards
  * compatibility.
  *
  * @param name the symbolic name
  */
 @Override
 public void deployBundle(String name) throws Exception {
   // install only if not yet installed
   BundleImpl bundle = bundleLoader.getOSGi().getRegistry().getBundle(name);
   if (bundle == null) {
     BundleFile bundleFile = lookupBundle(name);
     bundleLoader.loadBundle(bundleFile);
     bundleLoader.installBundle(bundleFile);
     bundle = bundleLoader.getOSGi().getRegistry().getBundle(name);
   }
   if (runtime.getContext(bundle) == null) {
     runtime.createContext(bundle);
   }
 }
Esempio n. 2
0
 @Override
 public RuntimeContext deployTestContrib(String bundle, URL contrib) throws Exception {
   Bundle b = bundleLoader.getOSGi().getRegistry().getBundle(bundle);
   if (b == null) {
     b = osgi.getSystemBundle();
   }
   OSGiRuntimeContext ctx = new OSGiRuntimeContext(runtime, b);
   ctx.deploy(contrib);
   return ctx;
 }
Esempio n. 3
0
  protected void initOsgiRuntime() throws Exception {
    try {
      if (!restart) {
        Environment.setDefault(null);
        if (System.getProperties().remove("nuxeo.home") != null) {
          log.warn("Removed System property nuxeo.home.");
        }
        workingDir =
            File.createTempFile(
                "nxruntime-" + Thread.currentThread().getName() + "-", null, new File("target"));
        workingDir.delete();
      }
    } catch (IOException e) {
      log.error("Could not init working directory", e);
      throw e;
    }
    osgi = new OSGiAdapter(workingDir);
    BundleFile bf = new SystemBundleFile(workingDir);
    bundleLoader = new StandaloneBundleLoader(osgi, NXRuntimeTestCase.class.getClassLoader());
    SystemBundle systemBundle =
        new SystemBundle(osgi, bf, bundleLoader.getSharedClassLoader().getLoader());
    osgi.setSystemBundle(systemBundle);
    Thread.currentThread().setContextClassLoader(bundleLoader.getSharedClassLoader().getLoader());

    for (WorkingDirectoryConfigurator cfg : wdConfigs) {
      cfg.configure(this, workingDir);
    }

    bundleLoader.setScanForNestedJARs(false); // for now
    bundleLoader.setExtractNestedJARs(false);

    BundleFile bundleFile = lookupBundle("org.nuxeo.runtime");
    runtimeBundle =
        new RootRuntimeBundle(osgi, bundleFile, bundleLoader.getClass().getClassLoader(), true);
    runtimeBundle.start();

    runtime = handleNewRuntime((OSGiRuntimeService) Framework.getRuntime());

    assertNotNull(runtime);
  }