use of org.ops4j.pax.swissbox.tinybundles.core.TinyBundle in project aries by apache.
the class Helper method createBundleContext.
public static BundleContext createBundleContext(String bundleFilter, TinyBundle[] testBundles) throws Exception {
deleteDirectory("target/bundles");
createDirectory("target/bundles");
// ensure pojosr stores bundles in an unique target directory
System.setProperty("org.osgi.framework.storage", "target/bundles/" + System.currentTimeMillis());
// get the bundles
List<BundleDescriptor> bundles = getBundleDescriptors(bundleFilter);
// with pojosr because it does not support bundle hooks, so events are lost.
if (testBundles != null) {
for (TinyBundle bundle : testBundles) {
File tmp = File.createTempFile("test-", ".jar", new File("target/bundles/"));
tmp.delete();
bundles.add(0, getBundleDescriptor(tmp.getPath(), bundle));
}
}
if (LOG.isDebugEnabled()) {
for (int i = 0; i < bundles.size(); i++) {
BundleDescriptor desc = bundles.get(i);
LOG.debug("Bundle #{} -> {}", i, desc);
}
}
// setup pojosr to use our bundles
Map<String, List<BundleDescriptor>> config = new HashMap<String, List<BundleDescriptor>>();
config.put(PojoServiceRegistryFactory.BUNDLE_DESCRIPTORS, bundles);
// create pojorsr osgi service registry
PojoServiceRegistry reg = new PojoServiceRegistryFactoryImpl().newPojoServiceRegistry(config);
return reg.getBundleContext();
}
Aggregations