use of org.ops4j.pax.tinybundles.core.TinyBundle in project sling by apache.
the class ClientSideTeleporter method buildTestBundle.
private InputStream buildTestBundle(Class<?> c, Collection<Class<?>> embeddedClasses, String bundleSymbolicName) throws IOException {
final TinyBundle b = TinyBundles.bundle().set(Constants.BUNDLE_SYMBOLICNAME, bundleSymbolicName).set("Sling-Test-Regexp", c.getName() + ".*").set("Sling-Test-WaitForService-Timeout", Integer.toString(waitForServiceTimout)).add(c);
for (Map.Entry<String, String> header : additionalBundleHeaders.entrySet()) {
log.info("Add bundle header '{}' with value '{}'", header.getKey(), header.getValue());
b.set(header.getKey(), header.getValue());
}
// enrich embedded classes by automatically detected dependencies
for (Class<?> clz : dependencyAnalyzer.getDependencies(log)) {
log.debug("Embed dependent class '{}' because it is referenced and in the allowed package prefixes", clz);
b.add(clz);
}
// Embed specified classes
for (Class<?> clz : embeddedClasses) {
log.info("Embed class '{}'", clz);
b.add(clz);
}
// Embed specified resources
if (!embeddedResourcePaths.isEmpty()) {
for (String path : embeddedResourcePaths) {
final ClassResourceVisitor.Processor p = new ClassResourceVisitor.Processor() {
@Override
public void process(String resourcePath, InputStream resourceStream) throws IOException {
b.add(resourcePath, resourceStream);
log.info("Embed resource '{}'", resourcePath);
}
};
new ClassResourceVisitor(getClass(), path).visit(p);
}
}
return b.build(TinyBundles.withBnd());
}
use of org.ops4j.pax.tinybundles.core.TinyBundle in project camel by apache.
the class CamelCxfBeanInjectTest method installBlueprintXML.
@Before
public void installBlueprintXML() throws Exception {
// install the camel blueprint xml file we use in this test
URL url = ObjectHelper.loadResourceAsURL("org/apache/camel/itest/cxf/CamelCxfBeanInjectTest.xml", CamelCxfBeanInjectTest.class.getClassLoader());
Bundle bundle = installBlueprintAsBundle("CamelCxfBeanInjectTest", url, false, b -> {
((TinyBundle) b).add(BeanInjectRouteBuilder.class, InnerClassStrategy.NONE).add(SimpleService.class, InnerClassStrategy.NONE).add(SimpleBean.class, InnerClassStrategy.NONE).set(Constants.DYNAMICIMPORT_PACKAGE, "*");
});
Properties props = new Properties();
props.put("router.address", ENDPOINT_ADDRESS);
props.put("router.port", Integer.toString(PORT));
overridePropertiesWithConfigAdmin("my-placeholders", props);
bundle.start();
}
use of org.ops4j.pax.tinybundles.core.TinyBundle in project camel by apache.
the class AbstractFeatureTest method installSpringAsBundle.
protected Bundle installSpringAsBundle(String name, URL url, boolean start, Consumer<Object> consumer) throws BundleException {
// TODO Type Consumer<TinyBundle> cannot be used for this method signature to avoid bundle dependency to pax tinybundles
TinyBundle bundle = TinyBundles.bundle();
bundle.add("META-INF/spring/spring-" + name.toLowerCase(Locale.ENGLISH) + ".xml", url);
bundle.set("Manifest-Version", "2").set("Bundle-ManifestVersion", "2").set("Bundle-SymbolicName", name).set("Bundle-Version", "1.0.0");
consumer.accept(bundle);
Bundle answer = bundleContext.installBundle(name, bundle.build());
if (start) {
answer.start();
}
return answer;
}
Aggregations