use of org.osgi.framework.wiring.FrameworkWiring in project motech by motech.
the class JarGeneratorServiceImpl method clearModulesCache.
private void clearModulesCache(String[] moduleNames) {
for (String moduleName : moduleNames) {
if (StringUtils.isNotBlank(moduleName)) {
Bundle bundleToRefresh = WebBundleUtil.findBundleBySymbolicName(bundleContext, moduleName);
Bundle frameworkBundle = bundleContext.getBundle(0);
FrameworkWiring frameworkWiring = frameworkBundle.adapt(FrameworkWiring.class);
Collection<Bundle> dependencyClosureBundles = frameworkWiring.getDependencyClosure(Arrays.asList(bundleToRefresh));
for (Bundle bundle : dependencyClosureBundles) {
MdsBundleHelper.unregisterBundleJDOClasses(bundle);
}
}
}
ResourceBundle.clearCache();
}
use of org.osgi.framework.wiring.FrameworkWiring in project vespa by vespa-engine.
the class FelixFramework method refreshPackages.
@Override
public void refreshPackages() {
FrameworkWiring wiring = felix.adapt(FrameworkWiring.class);
final CountDownLatch latch = new CountDownLatch(1);
wiring.refreshBundles(null, event -> {
switch(event.getType()) {
case FrameworkEvent.PACKAGES_REFRESHED:
latch.countDown();
break;
case FrameworkEvent.ERROR:
log.log(Level.SEVERE, "ERROR FrameworkEvent received.", event.getThrowable());
break;
}
});
try {
long TIMEOUT_SECONDS = 60L;
if (!latch.await(TIMEOUT_SECONDS, TimeUnit.SECONDS)) {
log.warning("No PACKAGES_REFRESHED FrameworkEvent received within " + TIMEOUT_SECONDS + " seconds of calling FrameworkWiring.refreshBundles()");
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
use of org.osgi.framework.wiring.FrameworkWiring in project aries by apache.
the class FrameworkMBeanTest method testGetDependencyClosure.
@Test
public void testGetDependencyClosure() throws Exception {
Bundle bundleA = getBundleByName("org.apache.aries.jmx.test.bundlea");
Bundle bundleB = getBundleByName("org.apache.aries.jmx.test.bundleb");
BundleWiring bw = (BundleWiring) bundleB.adapt(BundleWiring.class);
List<BundleWire> initialRequiredWires = bw.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE);
assertEquals(1, initialRequiredWires.size());
BundleWire wire = initialRequiredWires.get(0);
Map<String, Object> capabilityAttributes = wire.getCapability().getAttributes();
assertEquals("Precondition", bundleA.getSymbolicName(), capabilityAttributes.get(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE));
assertEquals("Precondition", new Version("1.0"), capabilityAttributes.get(Constants.BUNDLE_VERSION_ATTRIBUTE));
assertEquals("Precondition", "org.apache.aries.jmx.test.bundlea.api", capabilityAttributes.get(BundleRevision.PACKAGE_NAMESPACE));
Collection<Bundle> expectedDC = ((FrameworkWiring) context().getBundle(0).adapt(FrameworkWiring.class)).getDependencyClosure(Collections.singleton(bundleA));
Set<Long> expectedClosure = new TreeSet<Long>();
for (Bundle b : expectedDC) {
expectedClosure.add(b.getBundleId());
}
long[] actualDC = framework.getDependencyClosure(new long[] { bundleA.getBundleId() });
Set<Long> actualClosure = new TreeSet<Long>();
for (long l : actualDC) {
actualClosure.add(l);
}
assertEquals(expectedClosure, actualClosure);
}
use of org.osgi.framework.wiring.FrameworkWiring in project aries by apache.
the class Framework method getDependencyClosure.
/**
* @see org.osgi.jmx.framework.FrameworkMBean#getDependencyClosureBundles(long[])
*/
public long[] getDependencyClosure(long[] bundles) throws IOException {
FrameworkWiring fw = context.getBundle(0).adapt(FrameworkWiring.class);
List<Bundle> bl = new ArrayList<Bundle>();
for (int i = 0; i < bundles.length; i++) {
bl.add(context.getBundle(bundles[i]));
}
Collection<Bundle> rc = fw.getDependencyClosure(bl);
Iterator<Bundle> it = rc.iterator();
long[] result = new long[rc.size()];
for (int i = 0; i < result.length; i++) {
result[i] = it.next().getBundleId();
}
return result;
}
use of org.osgi.framework.wiring.FrameworkWiring in project aries by apache.
the class SubsystemTest method assertResolve.
protected void assertResolve(Collection<Bundle> bundles) {
FrameworkWiring wiring = getSystemBundleAsFrameworkWiring();
assertTrue("Bundles not resolved", wiring.resolveBundles(bundles));
}
Aggregations