use of org.osgi.framework.wiring.FrameworkWiring in project bnd by bndtools.
the class EmbeddedActivator method refresh.
/*
* Refresh the stopped bundles
*/
void refresh(BundleContext context, List<Bundle> toStop) throws InterruptedException {
Bundle bundle = context.getBundle(0);
FrameworkWiring framework = bundle.adapt(FrameworkWiring.class);
final Semaphore s = new Semaphore(0);
framework.refreshBundles(toStop, new FrameworkListener() {
@Override
public void frameworkEvent(FrameworkEvent event) {
s.release();
}
});
s.tryAcquire(10, TimeUnit.SECONDS);
}
use of org.osgi.framework.wiring.FrameworkWiring in project rt.equinox.framework by eclipse.
the class EclipseStarter method refreshPackages.
// returns true if the refreshPackages operation caused the framework to shutdown
private static boolean refreshPackages(Bundle[] bundles) throws InterruptedException {
FrameworkWiring frameworkWiring = context.getBundle().adapt(FrameworkWiring.class);
if (frameworkWiring == null)
return false;
Semaphore semaphore = new Semaphore(0);
StartupEventListener listener = new StartupEventListener(semaphore, FrameworkEvent.PACKAGES_REFRESHED);
context.addBundleListener(listener);
frameworkWiring.refreshBundles(Arrays.asList(bundles), listener);
updateSplash(semaphore, listener);
return isForcedRestart();
}
use of org.osgi.framework.wiring.FrameworkWiring in project karaf by apache.
the class BundlesMBeanImpl method update.
public void update(String bundleId, String location, boolean refresh) throws MBeanException {
try {
List<Bundle> bundles = selectBundles(bundleId);
if (location == null) {
for (Bundle bundle : bundles) {
bundle.update();
}
return;
}
if (bundles.size() != 1) {
throw new IllegalArgumentException("Provided bundle Id doesn't return any bundle or more than one bundle selected");
}
InputStream is = new URL(location).openStream();
bundles.get(0).update(is);
if (refresh) {
FrameworkWiring wiring = bundleContext.getBundle(0).adapt(FrameworkWiring.class);
wiring.refreshBundles(null);
}
} catch (Exception e) {
throw new MBeanException(null, e.toString());
}
}
use of org.osgi.framework.wiring.FrameworkWiring in project karaf by apache.
the class Update method doExecute.
protected Object doExecute(Bundle bundle) throws Exception {
if (location != null) {
update(bundle, location.toURL());
} else {
String loc = bundle.getHeaders().get(Constants.BUNDLE_UPDATELOCATION);
if (loc != null && !loc.equals(bundle.getLocation())) {
update(bundle, new URL(loc));
} else {
bundle.update();
}
}
if (refresh) {
FrameworkWiring wiring = bundleContext.getBundle(0).adapt(FrameworkWiring.class);
wiring.refreshBundles(null);
}
return null;
}
use of org.osgi.framework.wiring.FrameworkWiring in project karaf by apache.
the class BundleInstallSupportImpl method refreshPackages.
@Override
public void refreshPackages(Collection<Bundle> bundles) throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
FrameworkWiring fw = systemBundleContext.getBundle().adapt(FrameworkWiring.class);
fw.refreshBundles(bundles, (FrameworkListener) event -> {
if (event.getType() == FrameworkEvent.ERROR) {
LOGGER.error("Framework error", event.getThrowable());
}
latch.countDown();
});
latch.await();
}
Aggregations