use of org.ops4j.pax.tinybundles.core.TinyBundle in project felix by apache.
the class Common method service.
/**
* Package the service interfaces.
*/
public Option service() {
File out = new File("target/bundles/service.jar");
if (out.exists()) {
try {
return bundle(out.toURI().toURL().toExternalForm());
} catch (MalformedURLException e) {
// Ignore it.
}
}
TinyBundle bundle = TinyBundles.bundle();
bundle.add(CheckService.class);
bundle.add(HelloService.class);
InputStream inputStream = bundle.set(Constants.BUNDLE_SYMBOLICNAME, "services").set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.test.compatibility.service").build(withBnd());
try {
FileUtils.copyInputStreamToFile(inputStream, out);
return bundle(out.toURI().toURL().toExternalForm());
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
use of org.ops4j.pax.tinybundles.core.TinyBundle in project felix by apache.
the class Common method BPHelloProvider.
/**
* Package the Blueprint Hello Service Provider.
*/
public Option BPHelloProvider() {
File out = new File("target/bundles/hello-provider-blueprint.jar");
if (out.exists()) {
try {
return bundle(out.toURI().toURL().toExternalForm());
} catch (MalformedURLException e) {
// Ignore it.
}
}
File metadata = new File("src/main/resources/blueprint", "HelloProvider.xml");
TinyBundle bundle = TinyBundles.bundle();
bundle.add(org.apache.felix.ipojo.test.compatibility.scr.HelloServiceProvider.class);
try {
bundle.add("blueprint/provider.xml", new FileInputStream(metadata));
} catch (FileNotFoundException e) {
throw new IllegalArgumentException("Cannot find XML metadata : " + metadata.getAbsolutePath());
}
InputStream inputStream = bundle.set(Constants.BUNDLE_SYMBOLICNAME, "hello-provider-blueprint").set("Bundle-Blueprint", "blueprint/provider.xml").build(withBnd());
try {
FileUtils.copyInputStreamToFile(inputStream, out);
return bundle(out.toURI().toURL().toExternalForm());
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
use of org.ops4j.pax.tinybundles.core.TinyBundle in project felix by apache.
the class Common method SCRHelloProvider.
/**
* Package the SCR Hello Service Provider.
*/
public Option SCRHelloProvider() {
File out = new File("target/bundles/hello-provider-scr.jar");
if (out.exists()) {
try {
return bundle(out.toURI().toURL().toExternalForm());
} catch (MalformedURLException e) {
// Ignore it.
}
}
File metadata = new File("src/main/resources/scr", "HelloProvider.xml");
TinyBundle bundle = TinyBundles.bundle();
bundle.add(org.apache.felix.ipojo.test.compatibility.scr.HelloServiceProvider.class);
try {
bundle.add("scr/provider.xml", new FileInputStream(metadata));
} catch (FileNotFoundException e) {
throw new IllegalArgumentException("Cannot find XML metadata : " + metadata.getAbsolutePath());
}
InputStream inputStream = bundle.set(Constants.BUNDLE_SYMBOLICNAME, "hello-provider-scr").set("Service-Component", "scr/provider.xml").build(withBnd());
try {
FileUtils.copyInputStreamToFile(inputStream, out);
return bundle(out.toURI().toURL().toExternalForm());
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
use of org.ops4j.pax.tinybundles.core.TinyBundle in project felix by apache.
the class Common method iPOJOHelloProvider.
/**
* iPOJO Hello Service Provider.
*/
public Option iPOJOHelloProvider() {
File out = new File("target/bundles/hello-provider-ipojo.jar");
if (out.exists()) {
try {
return bundle(out.toURI().toURL().toExternalForm());
} catch (MalformedURLException e) {
// Ignore it.
}
}
TinyBundle bundle = TinyBundles.bundle();
bundle.add(HelloServiceProvider.class);
InputStream inputStream = bundle.set(Constants.BUNDLE_SYMBOLICNAME, "iPOJO-Hello-Provider").build(IPOJOStrategy.withiPOJO());
try {
FileUtils.copyInputStreamToFile(inputStream, out);
return bundle(out.toURI().toURL().toExternalForm());
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
Aggregations