Package org.ops4j.pax.tinybundles.core

Examples of org.ops4j.pax.tinybundles.core.TinyBundle


            createWebConsoleTestBundle()
        );
    }

    private Option createWebConsoleTestBundle() {
        TinyBundle bundle = bundle();
        for(Class c : WebConsoleTestActivator.BUNDLE_CLASS_NAMES){
            bundle.add(c);
        }

        bundle.set(Constants.BUNDLE_SYMBOLICNAME,"org.apache.sling.common.log.testbundle")
              .set(Constants.BUNDLE_ACTIVATOR , WebConsoleTestActivator.class.getName());
        return provision(bundle.build(withBnd()));

    }
View Full Code Here


                : null;
        return OptionUtils.combine(base, vmOption);
    }

    private Option createTestBundle() {
        TinyBundle bundle = bundle()
                .add(MDCStateServlet.class)
                .set(Constants.BUNDLE_SYMBOLICNAME,"org.apache.sling.extensions.slf4j.mdc.testbundle")
                .set(Constants.BUNDLE_ACTIVATOR , MDCStateServlet.class.getName());
        return provision(bundle.build(withBnd()));
    }
View Full Code Here

    }

    public Option testedBundle() throws MalformedURLException {
        File out = new File("target/tested/bundle.jar");

        TinyBundle tested = TinyBundles.bundle();

        // We look inside target/classes to find the class and resources
        File classes = new File("target/classes");
        Collection<File> files = FileUtils.listFilesAndDirs(classes, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
        List<File> services = new ArrayList<File>();
        for (File file : files) {
            if (file.isDirectory()) {
                // By convention we export of .services and .service package
                if (file.getName().endsWith("services"|| file.getName().endsWith("service")) {
                    services.add(file);
                }
            } else {
                // We need to compute the path
                String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
                tested.add(path, file.toURI().toURL());
                System.out.println(file.getName() + " added to " + path);
            }
        }

        String export = "";
        for (File file : services) {
            if (export.length() > 0) { export += ", "; }
            String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
            String packageName = path.replace('/', '.');
            export += packageName;
        }

        System.out.println("Exported packages : " + export);

        InputStream inputStream = tested
                .set(Constants.BUNDLE_SYMBOLICNAME, "test.bundle")
                //.set(Constants.IMPORT_PACKAGE, "*")
                //.set(Constants.EXPORT_PACKAGE, export) // No export...
                .build(IPOJOStrategy.withiPOJO(new File("src/main/resources")));

View Full Code Here

            } catch (MalformedURLException e) {
                // Ignore it.
            }
        }

        TinyBundle tested = TinyBundles.bundle();

        // We look inside target/classes to find the class and resources
        File classes = new File("target/classes");
        Collection<File> files = FileUtils.listFilesAndDirs(classes, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
        List<String> exports = new ArrayList<String>();
        for (File file : files) {
            if (file.isDirectory()) {
                // By convention we export of .services and .service package
                if (file.getAbsolutePath().contains("/services"|| file.getAbsolutePath().contains("/service")) {
                    String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
                    String packageName = path.replace('/', '.');
                    exports.add(packageName);
                }
            } else {
                // We need to compute the path
                String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
                try {
                    tested.add(path, file.toURI().toURL());
                } catch (MalformedURLException e) {
                    // Ignore it.
                }
                System.out.println(file.getName() + " added to " + path);
            }
        }

        // Depending on the the order, the probe bundle may already have detected requirements on components.
        String clause = "" +
                "org.apache.felix.ipojo.runtime.core.components, " +
                "org.apache.felix.ipojo.runtime.core.services, " +
                "org.apache.felix.ipojo.runtime.core.services.A123";
        for (String export : exports) {
            if (export.length() > 0) { export += ", "; }
            clause += export;
        }

        System.out.println("Exported packages : " + clause);

        InputStream inputStream = tested
                .set(Constants.BUNDLE_SYMBOLICNAME, BaseTest.TEST_BUNDLE_SYMBOLIC_NAME + "-with-native")
                .set(Constants.IMPORT_PACKAGE, "*")
                .set(Constants.EXPORT_PACKAGE, clause)
                .set(Constants.BUNDLE_NATIVECODE, NATIVE_CLAUSE)
                .build(IPOJOStrategy.withiPOJO(new File("src/main/resources")));
View Full Code Here

    }

    public Option testedBundle() throws MalformedURLException {
        File out = new File("target/tested/bundle.jar");

        TinyBundle tested = TinyBundles.bundle();

        // We look inside target/classes to find the class and resources
        File classes = new File("target/classes");
        Collection<File> files = FileUtils.listFilesAndDirs(classes, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
        List<File> services = new ArrayList<File>();
        for (File file : files) {
            if (file.isDirectory()) {
                // By convention we export of .services and .service package
                if (file.getName().endsWith("services") || file.getName().endsWith("service")) {
                    services.add(file);
                }
            } else {
                // We need to compute the path
                String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() + 1);
                tested.add(path, file.toURI().toURL());
                System.out.println(file.getName() + " added to " + path);
            }
        }

        String export = "";
        for (File file : services) {
            if (export.length() > 0) {
                export += ", ";
            }
            String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() + 1);
            String packageName = path.replace('/', '.');
            export += packageName;
        }

        System.out.println("Exported packages : " + export);

        InputStream inputStream = tested
                .set(Constants.BUNDLE_SYMBOLICNAME, "test.bundle")
                        //.set(Constants.IMPORT_PACKAGE, "*")
                        //.set(Constants.EXPORT_PACKAGE, export) // No export...
                .build(IPOJOStrategy.withiPOJO(new File("src/main/resources")));

View Full Code Here

            } 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 {
View Full Code Here

            } catch (MalformedURLException e) {
                // Ignore it.
            }
        }

        TinyBundle bundle = TinyBundles.bundle();
        bundle.add(HelloServiceProvider.class);
        InputStream inputStream = bundle
                .set(Constants.BUNDLE_SYMBOLICNAME, "iPOJO-Hello-Provider")
                //.set(Constants.IMPORT_PACKAGE, "*")
                .build(IPOJOStrategy.withiPOJO());

        try {
View Full Code Here

            } catch (MalformedURLException e) {
                // Ignore it.
            }
        }

        TinyBundle bundle = TinyBundles.bundle();
        bundle.add(HelloServiceConsumer.class);
        InputStream inputStream = bundle
                .set(Constants.BUNDLE_SYMBOLICNAME, "iPOJO-Hello-Consumer")
                //.set(Constants.IMPORT_PACKAGE, "*")
                .build(IPOJOStrategy.withiPOJO());

        try {
View Full Code Here

            }
        }

        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(Constants.IMPORT_PACKAGE, "*")
                .set("Service-Component", "scr/provider.xml")
                .build(withBnd());

View Full Code Here

            }
        }

        File metadata = new File("src/main/resources/scr", "HelloConsumer.xml");

        TinyBundle bundle = TinyBundles.bundle();
        bundle.add(org.apache.felix.ipojo.test.compatibility.scr.HelloServiceConsumer.class);
        try {
            bundle.add("scr/consumer.xml", new FileInputStream(metadata));
        } catch (FileNotFoundException e) {
            throw new IllegalArgumentException("Cannot find XML metadata : " + metadata.getAbsolutePath());
        }

        InputStream inputStream = bundle
                .set(Constants.BUNDLE_SYMBOLICNAME, "hello-consumer-scr")
               // .set(Constants.IMPORT_PACKAGE, "*")
                .set("Service-Component", "scr/consumer.xml")
                .build(withBnd());

View Full Code Here

TOP

Related Classes of org.ops4j.pax.tinybundles.core.TinyBundle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.