Examples of Features


Examples of org.apache.karaf.features.internal.model.Features

    private List<Artifact> readResources() throws MojoExecutionException {
        List<Artifact> resources = new ArrayList<Artifact>();
        try {
            InputStream in = new FileInputStream(featuresFile);
            try {
                Features features = JaxbUtil.unmarshal(in, false);
                for (Feature feature : features.getFeature()) {
                    for (BundleInfo bundle : feature.getBundles()) {
                        if (ignoreDependencyFlag || (!ignoreDependencyFlag && !bundle.isDependency())) {
                            resources.add(resourceToArtifact(bundle.getLocation(), false));
                        }
                    }
View Full Code Here

Examples of org.apache.karaf.features.internal.model.Features

    private void writeFeatures(PrintStream out) throws ArtifactResolutionException, ArtifactNotFoundException,
            IOException, JAXBException, SAXException, ParserConfigurationException, XMLStreamException, MojoExecutionException {
        getLogger().info("Generating feature descriptor file " + outputFile.getAbsolutePath());
        //read in an existing feature.xml
        ObjectFactory objectFactory = new ObjectFactory();
        Features features;
        if (inputFile.exists()) {
            filter(inputFile, filteredInputFile);
            features = readFeaturesFile(filteredInputFile);
        } else {
            features = objectFactory.createFeaturesRoot();
        }
        if (features.getName() == null) {
            features.setName(project.getArtifactId());
        }

        Feature feature = null;
        for (Feature test : features.getFeature()) {
            if (test.getName().equals(project.getArtifactId())) {
                feature = test;
            }
        }
        if (feature == null) {
            feature = objectFactory.createFeature();
            feature.setName(project.getArtifactId());
        }
        if (!feature.hasVersion()) {
            feature.setVersion(project.getArtifact().getBaseVersion());
        }
        if (feature.getDescription() == null) {
            feature.setDescription(project.getName());
        }
        if (resolver != null) {
            feature.setResolver(resolver);
        }
        if (installMode != null) {
            feature.setInstall(installMode);
        }
        if (project.getDescription() != null && feature.getDetails() == null) {
            feature.setDetails(project.getDescription());
        }
        for (Map.Entry<Artifact, String> entry : localDependencies.entrySet()) {
            Artifact artifact = entry.getKey();

            if (excludedArtifactIds.contains(artifact.getArtifactId())) {
                continue;
            }

            if (DependencyHelper.isFeature(artifact)) {
                if (aggregateFeatures && FEATURE_CLASSIFIER.equals(artifact.getClassifier())) {
                    File featuresFile = resolve(artifact);
                    if (featuresFile == null || !featuresFile.exists()) {
                        throw new MojoExecutionException("Cannot locate file for feature: " + artifact + " at " + featuresFile);
                    }
                    Features includedFeatures = readFeaturesFile(featuresFile);
                    //TODO check for duplicates?
                    features.getFeature().addAll(includedFeatures.getFeature());
                }
            } else if (addBundlesToPrimaryFeature) {
                String bundleName = MavenUtil.artifactToMvn(artifact);
                File bundleFile = resolve(artifact);
                Manifest manifest = getManifest(bundleFile);
View Full Code Here

Examples of org.apache.karaf.features.internal.model.Features

        return result.getArtifact().getFile();
    }


    private Features readFeaturesFile(File featuresFile) throws XMLStreamException, JAXBException, IOException {
        Features features;
        InputStream in = new FileInputStream(featuresFile);
        try {
            features = JaxbUtil.unmarshal(in, false);
        } finally {
            in.close();
View Full Code Here

Examples of org.apache.karaf.features.internal.model.Features

    protected Map<String, String> systemProperties;

    private void checkChanges(Features newFeatures, ObjectFactory objectFactory) throws Exception, IOException, JAXBException, XMLStreamException {
        if (checkDependencyChange) {
            //combine all the dependencies to one feature and strip out versions
            Features features = objectFactory.createFeaturesRoot();
            features.setName(newFeatures.getName());
            Feature feature = objectFactory.createFeature();
            features.getFeature().add(feature);
            for (Feature f : newFeatures.getFeature()) {
                for (Bundle b : f.getBundle()) {
                    Bundle bundle = objectFactory.createBundle();
                    bundle.setLocation(b.getLocation());
                    feature.getBundle().add(bundle);
                }
                for (Dependency d : f.getFeature()) {
                    Dependency dependency = objectFactory.createDependency();
                    dependency.setName(d.getName());
                    feature.getFeature().add(dependency);
                }
            }

            Collections.sort(feature.getBundle(), new Comparator<Bundle>() {

                public int compare(Bundle bundle, Bundle bundle1) {
                    return bundle.getLocation().compareTo(bundle1.getLocation());
                }
            });
            Collections.sort(feature.getFeature(), new Comparator<Dependency>() {
                public int compare(Dependency dependency, Dependency dependency1) {
                    return dependency.getName().compareTo(dependency1.getName());
                }
            });

            if (dependencyCache.exists()) {
                //filter dependencies file
                filter(dependencyCache, filteredDependencyCache);
                //read dependency types, convert to dependencies, compare.
                Features oldfeatures = readFeaturesFile(filteredDependencyCache);
                Feature oldFeature = oldfeatures.getFeature().get(0);

                List<Bundle> addedBundles = new ArrayList<Bundle>(feature.getBundle());
                List<Bundle> removedBundles = new ArrayList<Bundle>();
                for (Bundle test : oldFeature.getBundle()) {
                    boolean t1 = addedBundles.contains(test);
View Full Code Here

Examples of org.apache.karaf.features.internal.model.Features

    }

    protected void saveDependencyChanges(Collection<Bundle> addedBundles, Collection<Bundle> removedBundles, Collection<Dependency> addedDependencys, Collection<Dependency> removedDependencys, ObjectFactory objectFactory)
            throws Exception {
        File addedFile = new File(filteredDependencyCache.getParentFile(), "dependencies.added.xml");
        Features added = toFeatures(addedBundles, addedDependencys, objectFactory);
        writeDependencies(added, addedFile);

        File removedFile = new File(filteredDependencyCache.getParentFile(), "dependencies.removed.xml");
        Features removed = toFeatures(removedBundles, removedDependencys, objectFactory);
        writeDependencies(removed, removedFile);

        StringWriter out = new StringWriter();
        out.write(saveTreeListing());
View Full Code Here

Examples of org.apache.karaf.features.internal.model.Features

            getLog().warn(out.toString());
        }
    }

    private Features toFeatures(Collection<Bundle> addedBundles, Collection<Dependency> addedDependencys, ObjectFactory objectFactory) {
        Features features = objectFactory.createFeaturesRoot();
        Feature feature = objectFactory.createFeature();
        feature.getBundle().addAll(addedBundles);
        feature.getFeature().addAll(addedDependencys);
        features.getFeature().add(feature);
        return features;
    }
View Full Code Here

Examples of org.apache.karaf.features.internal.model.Features

                    String existingFeatureRepos = retrieveProperty(properties, FEATURES_REPOSITORIES);
                    if (!existingFeatureRepos.contains(uri.toString())) {
                        existingFeatureRepos = existingFeatureRepos + uri.toString();
                        properties.put(FEATURES_REPOSITORIES, existingFeatureRepos);
                    }
                    Features repo = readFeatures(uri);
                    for (String innerRepository : repo.getRepository()) {
                        String innerRepositoryPath = dependencyHelper.pathFromMaven(innerRepository);
                        File innerRepositoryTargetInSystemRepository = new File(system.resolve(innerRepositoryPath));
                        if (!innerRepositoryTargetInSystemRepository.exists()) {
                            File innerRepositorySourceFile = dependencyHelper.resolveById(innerRepository, getLog());
                            innerRepositoryTargetInSystemRepository.getParentFile().mkdirs();
                            copy(innerRepositorySourceFile, innerRepositoryTargetInSystemRepository);

                            // add metadata for snapshot
                            Artifact innerRepositoryArtifact = dependencyHelper.mvnToArtifact(innerRepository);
                            if (innerRepositoryArtifact.isSnapshot()) {
                                getLog().debug("Feature repository " + innerRepository + " is a SNAPSHOT, generate the maven-metadata-local.xml file");
                                File metadataTarget = new File(innerRepositoryTargetInSystemRepository.getParentFile(), "maven-metadata-local.xml");
                                try {
                                    MavenUtil.generateMavenMetadata(innerRepositoryArtifact, 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");
                                }
                            }
                        }
                    }
                    for (Feature feature : repo.getFeature()) {
                        featureSet.add(feature);
                        if (startupFeatures != null && startupFeatures.contains(feature.getName())) {
                            installFeature(feature, null);
                        } else if (bootFeatures != null && bootFeatures.contains(feature.getName())) {
                            localRepoFeatures.add(feature);
                            missingDependencies.addAll(feature.getDependencies());
                            String existingBootFeatures = retrieveProperty(properties, FEATURES_BOOT);
                            if (!existingBootFeatures.contains(feature.getName())) {
                                existingBootFeatures = existingBootFeatures + feature.getName();
                                properties.put(FEATURES_BOOT, existingBootFeatures);
                            }
                        } else if (installedFeatures != null && installedFeatures.contains(feature.getName())) {
                            localRepoFeatures.add(feature);
                            missingDependencies.addAll(feature.getDependencies());
                        }
                    }
                    if (addTransitiveFeatures) {
                        addMissingDependenciesToRepo();
                    }
                    FileOutputStream out = new FileOutputStream(featuresCfgFile);
                    try {
                        properties.save(out);
                    } finally {
                        out.close();
                    }
                }
            } else {
                getLog().info("Installing feature " + uri + " to system and startup.properties");
                Features features = readFeatures(uri);
                for (Feature feature : features.getFeature()) {
                    installFeature(feature, null);
                }
            }
        }
View Full Code Here

Examples of org.apache.karaf.features.internal.model.Features

                repoFile = new File(featuresPath);
            } else {
                repoFile = new File(uri);
            }
            InputStream in = new FileInputStream(repoFile);
            Features features;
            try {
                features = JaxbUtil.unmarshal(in, false);
            } finally {
                in.close();
            }
View Full Code Here

Examples of org.apache.karaf.features.internal.model.Features

    private List<Artifact> readResources(File featuresFile) throws MojoExecutionException {
        List<Artifact> resources = new ArrayList<Artifact>();
        try {
            InputStream in = new FileInputStream(featuresFile);
            try {
                Features features = JaxbUtil.unmarshal(in, false);
                for (Feature feature : features.getFeature()) {
                    for (BundleInfo bundle : feature.getBundles()) {
                        if (ignoreDependencyFlag || (!ignoreDependencyFlag && !bundle.isDependency())) {
                            resources.add(resourceToArtifact(bundle.getLocation(), false));
                        }
                    }
View Full Code Here

Examples of org.apache.karaf.features.internal.model.Features

    @Test
    public void testReadXml100() throws JAXBException, SAXException, ParserConfigurationException, XMLStreamException {

        InputStream in = getClass().getClassLoader().getResourceAsStream("input-features-1.0.0.xml");

        Features featuresRoot = JaxbUtil.unmarshal(in, false);

        assertEquals(featuresRoot.getRepository().size(), 1);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        JaxbUtil.marshal(featuresRoot, baos);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.