/** @deprecated since 0.9.0, replaced with {@code SystemFrameworkLoader.get().isSystemBundle(bundle)} */ @Deprecated public static boolean isExtensionBundle(Bundle bundle) { return SystemFrameworkLoader.get().isSystemBundle(bundle); }
public static SystemFramework get() { if (framework == null) { return createFramework(); } else { return framework; } } private synchronized static SystemFramework createFramework() {
/** * Stops/ungets the OSGi framework. * * See {@link #getFramework(java.lang.String, boolean)} * * @param framework */ public static void ungetFramework(Framework framework) { SystemFrameworkLoader.get().ungetFramework(framework); }
/** * Provides an OSGI framework. * * When running inside an OSGi container, the container framework is returned. * When running standalone a new Apache Felix container is created. * * @param felixCacheDir * @param clean * @return * @todo Use felixCacheDir ? */ public static Framework getFramework(String felixCacheDir, boolean clean) { return SystemFrameworkLoader.get().getFramework(felixCacheDir, clean); }
@Override public Maybe<URL> tryLoadFrom(Bundle bundle, String name) { return Maybe.ofDisallowingNull(SystemFrameworkLoader.get().getResourceFromBundle(name, bundle)); }
@Override public Maybe<Iterable<URL>> tryLoadFrom(Bundle bundle, String name) { try { return emptyToMaybeNull(SystemFrameworkLoader.get().getResourcesFromBundle(name, bundle)); } catch (IOException e) { throw Exceptions.propagate(e); } }
for (Bundle installedBundle : framework.getBundleContext().getBundles()) { if (versionedId.equals(OsgiUtils.getVersionedId(installedBundle))) { if (SystemFrameworkLoader.get().isSystemBundle(installedBundle)) { LOG.debug("Already have system bundle "+versionedId+" from "+installedBundle+"/"+installedBundle.getLocation()+" when requested "+url+"; not installing");
@Override public Maybe<Class<?>> tryLoadFrom(Bundle bundle, String className) { try { return Maybe.<Class<?>>of(SystemFrameworkLoader.get().loadClassFromBundle(className, bundle)); } catch (ClassNotFoundException e) { return Maybe.absent("Failed to load class " + className + " from bundle " + bundle, e); } catch (NoClassDefFoundError e) { // Can happen if a bundle misbehaves (e.g. it doesn't include Import-Package for // all the packages it really needs. return Maybe.absent("Failed to load class " + className + " from bundle " + bundle, e); } }
public void helperDuplicateBundle(String url) throws Exception { //The bundle is already installed from the boot path. //Make sure that we still get the initially loaded //bundle after trying to install the same version. Bundle bundle = install(url); Assert.assertTrue(SystemFrameworkLoader.get().isSystemBundle(bundle)); }
Class<T> clazz = SystemFrameworkLoader.get().loadClassFromBundle(typeToLoad, b); return Maybe.of(clazz); } else {