Package org.apache.karaf.features

Examples of org.apache.karaf.features.FeaturesService


     * @param feature
     * @throws Exception
     */
    public void installAndCheckFeature(String feature) throws Exception {
        System.err.println(executeCommand("features:install " + feature));
        FeaturesService featuresService = getOsgiService(FeaturesService.class);
        System.err.println(executeCommand("osgi:list -t 0"));
        assertTrue("Expected " + feature + " feature to be installed.", featuresService.isInstalled(featuresService.getFeature(feature)));
    }
View Full Code Here


        if (isBlobStoreLiveConfigured()) {
            createManagedBlobStoreService("aws-s3");
            BlobStore blobStoreService = getOsgiService(BlobStore.class);
            Thread.sleep(DEFAULT_TIMEOUT);

            FeaturesService featuresService = getOsgiService(FeaturesService.class);
            featuresService.installFeature("jclouds-url-handler");

            //Let's add a bundle to S3
            String groupId =  "org.jclouds.api";
            String artifactId =  "byon";
            String version =   System.getProperty("jclouds.version");
View Full Code Here

        if (isBlobStoreLiveConfigured()) {
            createManagedBlobStoreService("cloudfiles-us");
            BlobStore blobStoreService = getOsgiService(BlobStore.class);
            Thread.sleep(DEFAULT_TIMEOUT);

            FeaturesService featuresService = getOsgiService(FeaturesService.class);
            featuresService.installFeature("jclouds-url-handler");

            //Let's add a bundle to S3
            String groupId =  "org.jclouds.api";
            String artifactId =  "byon";
            String version =   System.getProperty("jclouds.version");
View Full Code Here

    public void execute() throws MojoExecutionException, MojoFailureException {
        KarArtifactInstaller installer = new KarArtifactInstaller();
        installer.setBasePath(workDirectory);
        installer.setLocalRepoPath(localRepoDirectory);
        FeaturesService featuresService = new OfflineFeaturesService();
        installer.setFeaturesService(featuresService);
        installer.init();
        Collection<Artifact> dependencies = project.getDependencyArtifacts();
        StringBuilder buf = new StringBuilder();
        for (Artifact artifact: dependencies) {
View Full Code Here

            if (!startupPropertiesFile.getParentFile().exists()) {
                startupPropertiesFile.getParentFile().mkdirs();
            }
        }

        FeaturesService featuresService = new OfflineFeaturesService();

        Collection<Artifact> dependencies = project.getDependencyArtifacts();
        StringBuilder buf = new StringBuilder();
        for (Artifact artifact : dependencies) {
            dontAddToStartup = "runtime".equals(artifact.getScope());
            if ("kar".equals(artifact.getType()) && acceptScope(artifact)) {
                File file = artifact.getFile();
                try {
                    Kar kar = new Kar(file.toURI());
                    kar.extract(new File(system.getPath()), new File(workDirectory));
                    for (URI repoUri : kar.getFeatureRepos()) {
                        featuresService.removeRepository(repoUri);
                        featuresService.addRepository(repoUri);
                    }
                } catch (Exception e) {
                    throw new RuntimeException("Could not install kar: " + artifact.toString() + "\n", e);
                    //buf.append("Could not install kar: ").append(artifact.toString()).append("\n");
                    //buf.append(e.getMessage()).append("\n\n");
                }
            }
            if ("features".equals(artifact.getClassifier()) && acceptScope(artifact)) {
                String uri = MavenUtil.artifactToMvn(artifact);

                File source = artifact.getFile();
                DefaultRepositoryLayout layout = new DefaultRepositoryLayout();

                //remove timestamp version
                artifact = factory.createArtifactWithClassifier(artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion(), artifact.getType(), artifact.getClassifier());
                File target = new File(system.resolve(layout.pathOf(artifact)));

                if (!target.exists()) {
                    target.getParentFile().mkdirs();
                    try {
                        copy(source, target);
                    } catch (RuntimeException e) {
                        getLog().error("Could not copy features " + uri + " from source file " + source, e);
                    }

                    // for snapshot, generate the repository metadata in order to avoid override of snapshot from remote repositories
                    if (artifact.isSnapshot()) {
                        getLog().debug("Feature " + uri + " is a SNAPSHOT, generate the maven-metadata-local.xml file");
                        File metadataTarget = new File(target.getParentFile(), "maven-metadata-local.xml");
                        try {
                            MavenUtil.generateMavenMetadata(artifact, metadataTarget);
                        } catch (Exception e) {
                            getLog().warn("Could not create maven-metadata-local.xml", e);
                            getLog().warn("It means that this SNAPSHOT could be overwritten by an older one present on remote repositories");
                        }
                    }

                }
                try {
                    featuresService.addRepository(URI.create(uri));
                } catch (Exception e) {
                    buf.append("Could not install feature: ").append(artifact.toString()).append("\n");
                    buf.append(e.getMessage()).append("\n\n");
                }
            }
View Full Code Here

        if (ref == null) {
            System.out.println("FeaturesService service is unavailable.");
            return null;
        }
        try {
            FeaturesService admin = (FeaturesService) getBundleContext().getService(ref);
            if (admin == null) {
                System.out.println("FeaturesService service is unavailable.");
                return null;
            }
View Full Code Here

            if (!startupPropertiesFile.getParentFile().exists()) {
                startupPropertiesFile.getParentFile().mkdirs();
            }
        }

        FeaturesService featuresService = new OfflineFeaturesService();

        Collection<Artifact> dependencies = project.getDependencyArtifacts();
        StringBuilder buf = new StringBuilder();
        for (Artifact artifact : dependencies) {
            dontAddToStartup = "runtime".equals(artifact.getScope());
            if ("kar".equals(artifact.getType()) && acceptScope(artifact)) {
                File file = artifact.getFile();
                try {
                    Kar kar = new Kar(file.toURI());
                    kar.extract(new File(system.getPath()), new File(workDirectory));
                    for (URI repoUri : kar.getFeatureRepos()) {
                        featuresService.removeRepository(repoUri);
                        featuresService.addRepository(repoUri);
                    }
                } catch (Exception e) {
                    throw new RuntimeException("Could not install kar: " + artifact.toString() + "\n", e);
                    //buf.append("Could not install kar: ").append(artifact.toString()).append("\n");
                    //buf.append(e.getMessage()).append("\n\n");
                }
            }
            if ("features".equals(artifact.getClassifier()) && acceptScope(artifact)) {
                String uri = this.dependencyHelper.artifactToMvn(artifact);

                File source = artifact.getFile();
                DefaultRepositoryLayout layout = new DefaultRepositoryLayout();

                //remove timestamp version
                artifact = factory.createArtifactWithClassifier(artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion(), artifact.getType(), artifact.getClassifier());
                File target = new File(system.resolve(layout.pathOf(artifact)));

                if (!target.exists()) {
                    target.getParentFile().mkdirs();
                    try {
                        copy(source, target);
                    } catch (RuntimeException e) {
                        getLog().error("Could not copy features " + uri + " from source file " + source, e);
                    }

                    // for snapshot, generate the repository metadata in order to avoid override of snapshot from remote repositories
                    if (artifact.isSnapshot()) {
                        getLog().debug("Feature " + uri + " is a SNAPSHOT, generate the maven-metadata-local.xml file");
                        File metadataTarget = new File(target.getParentFile(), "maven-metadata-local.xml");
                        try {
                            MavenUtil.generateMavenMetadata(artifact, metadataTarget);
                        } catch (Exception e) {
                            getLog().warn("Could not create maven-metadata-local.xml", e);
                            getLog().warn("It means that this SNAPSHOT could be overwritten by an older one present on remote repositories");
                        }
                    }

                }
                try {
                    featuresService.addRepository(URI.create(uri));
                } catch (Exception e) {
                    buf.append("Could not install feature: ").append(artifact.toString()).append("\n");
                    buf.append(e.getMessage()).append("\n\n");
                }
            }
View Full Code Here

        ServiceReference ref = bundleContext.getServiceReference(FeaturesService.class.getName());
        if (ref == null) {
            return;
        }

        FeaturesService features = (FeaturesService) bundleContext.getService(ref);
        try {
            // creates header
            outputStreamWriter.write("Repositories:\n");

            // list repositories
            for (Repository repo : features.listRepositories()) {
                outputStreamWriter.write(repo.getURI() + " (" + repo.getName() + ")\n");
            }

            // list features
            outputStreamWriter.write("\nfeatures:\n");
            for (Feature feature : features.listFeatures()) {
                outputStreamWriter.write(feature.getName() + " " + feature.getVersion());
                outputStreamWriter.write(" installed: " + features.isInstalled(feature));
                outputStreamWriter.write("\nBundles:\n");
                for (BundleInfo bundle : feature.getBundles()) {
                    outputStreamWriter.write("\t" + bundle.getLocation());
                    if (bundle.getStartLevel() != 0) {
                        outputStreamWriter.write(" start level " + bundle.getStartLevel());
View Full Code Here

    public void execute() throws MojoExecutionException, MojoFailureException {
        KarArtifactInstaller installer = new KarArtifactInstaller();
        installer.setBasePath(workDirectory);
        installer.setLocalRepoPath(localRepoDirectory);
        FeaturesService featuresService = new OfflineFeaturesService();
        installer.setFeaturesService(featuresService);
        installer.init();
        Collection<Artifact> dependencies = project.getDependencyArtifacts();
        StringBuilder buf = new StringBuilder();
        for (Artifact artifact: dependencies) {
View Full Code Here

    public void execute() throws MojoExecutionException, MojoFailureException {
        KarArtifactInstaller installer = new KarArtifactInstaller();
        installer.setBasePath(workDirectory);
        installer.setLocalRepoPath(systemRepoDirectory);
        FeaturesService featuresService = new OfflineFeaturesService();
        installer.setFeaturesService(featuresService);
        installer.init();
        Collection<Artifact> dependencies = project.getDependencyArtifacts();
        StringBuilder buf = new StringBuilder();
        for (Artifact artifact: dependencies) {
View Full Code Here

TOP

Related Classes of org.apache.karaf.features.FeaturesService

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.