Search in sources :

Example 16 with TinyBundle

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;
    }
}
Also used : TinyBundle(org.ops4j.pax.tinybundles.core.TinyBundle) MalformedURLException(java.net.MalformedURLException)

Example 17 with TinyBundle

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;
    }
}
Also used : TinyBundle(org.ops4j.pax.tinybundles.core.TinyBundle) MalformedURLException(java.net.MalformedURLException)

Example 18 with TinyBundle

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;
    }
}
Also used : TinyBundle(org.ops4j.pax.tinybundles.core.TinyBundle) MalformedURLException(java.net.MalformedURLException)

Example 19 with TinyBundle

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;
    }
}
Also used : TinyBundle(org.ops4j.pax.tinybundles.core.TinyBundle) MalformedURLException(java.net.MalformedURLException)

Aggregations

TinyBundle (org.ops4j.pax.tinybundles.core.TinyBundle)19 MalformedURLException (java.net.MalformedURLException)11 InputStream (java.io.InputStream)6 File (java.io.File)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 Bundle (org.osgi.framework.Bundle)3 URL (java.net.URL)2 CoreOptions.mavenBundle (org.ops4j.pax.exam.CoreOptions.mavenBundle)2 BufferedInputStream (java.io.BufferedInputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileInputStream (java.io.FileInputStream)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Properties (java.util.Properties)1 ZipInputStream (java.util.zip.ZipInputStream)1 CamelContext (org.apache.camel.CamelContext)1 DefaultExchange (org.apache.camel.impl.DefaultExchange)1 MyConverter (org.apache.camel.itest.typeconverter.MyConverter)1 AbstractFeatureTest (org.apache.camel.test.karaf.AbstractFeatureTest)1