use of org.osgi.framework.Bundle in project karaf by apache.
the class BundlesMBeanImpl method restart.
public void restart(String bundleId) throws MBeanException {
try {
List<Bundle> bundles = selectBundles(bundleId);
for (Bundle bundle : bundles) {
bundle.stop();
bundle.start();
}
} catch (Exception e) {
throw new MBeanException(null, e.toString());
}
}
use of org.osgi.framework.Bundle in project karaf by apache.
the class TestBundleFactory method createBundle.
Bundle createBundle(long id, String name) {
Bundle bundle = createMock(Bundle.class);
expect(bundle.getBundleId()).andReturn(id).anyTimes();
Dictionary<String, String> headers = new Hashtable<>();
headers.put(Constants.BUNDLE_NAME, name);
expect(bundle.getHeaders()).andReturn(headers).anyTimes();
return bundle;
}
use of org.osgi.framework.Bundle in project karaf by apache.
the class TestBundleFactory method createBundleContext.
public BundleContext createBundleContext() {
BundleContext bundleContext = createMock(BundleContext.class);
Bundle[] bundles = createBundles();
expect(bundleContext.getProperty("karaf.systemBundlesStartLevel")).andReturn(Integer.toString(50)).anyTimes();
expect(bundleContext.getBundles()).andReturn(bundles).anyTimes();
expect(bundleContext.getBundle(0)).andReturn(null).anyTimes();
expect(bundleContext.getBundle(1)).andReturn(bundles[0]).anyTimes();
expect(bundleContext.getBundle(2)).andReturn(bundles[1]).anyTimes();
replay(bundleContext);
return bundleContext;
}
use of org.osgi.framework.Bundle in project karaf by apache.
the class BundleSelectorImpl method getBundlesByLocation.
private List<Bundle> getBundlesByLocation(String url) {
Bundle[] bundles = bundleContext.getBundles();
ArrayList<Bundle> result = new ArrayList<>();
Pattern locationPattern = Pattern.compile(url);
for (Bundle bundle : bundles) {
Matcher locationMatcher = locationPattern.matcher(bundle.getLocation());
if (locationMatcher.matches()) {
result.add(bundle);
}
}
return result;
}
use of org.osgi.framework.Bundle in project karaf by apache.
the class MetaCompleter method updateMeta.
private synchronized void updateMeta() {
List<String> pids = MetaServiceCaller.withMetaTypeService(context, metatypeService -> {
List<String> pids1 = new ArrayList<>();
Bundle[] bundles = context.getBundles();
for (Bundle bundle : bundles) {
MetaTypeInformation info = metatypeService.getMetaTypeInformation(bundle);
if (info == null) {
continue;
}
if (info.getFactoryPids() != null) {
pids1.addAll(Arrays.asList(info.getFactoryPids()));
}
if (info.getPids() != null) {
pids1.addAll(Arrays.asList(info.getPids()));
}
}
return pids1;
});
if (pids != null) {
delegate.getStrings().clear();
delegate.getStrings().addAll(pids);
}
}
Aggregations