Search in sources :

Example 6 with Features

use of org.apache.karaf.features.internal.model.Features in project karaf by apache.

the class FeaturesValidationTest method testNs10Unmarshall.

@Test
public void testNs10Unmarshall() throws Exception {
    URL url = getClass().getResource("f02.xml");
    Features features = JaxbUtil.unmarshal(url.toExternalForm(), true);
    assertNotNull(features);
}
Also used : Features(org.apache.karaf.features.internal.model.Features) URL(java.net.URL) Test(org.junit.Test)

Example 7 with Features

use of org.apache.karaf.features.internal.model.Features in project karaf by apache.

the class BlacklistTest method testBlacklistFeatureWithoutVersion.

@Test
public void testBlacklistFeatureWithoutVersion() {
    URL url = getClass().getResource("f02.xml");
    Features features = JaxbUtil.unmarshal(url.toExternalForm(), true);
    List<String> blacklist = new ArrayList<>();
    blacklist.add("spring");
    Blacklist.blacklist(features, blacklist);
    for (Feature feature : features.getFeature()) {
        assertFalse(feature.getId().startsWith("spring/"));
    }
}
Also used : ArrayList(java.util.ArrayList) Features(org.apache.karaf.features.internal.model.Features) Feature(org.apache.karaf.features.internal.model.Feature) URL(java.net.URL) Test(org.junit.Test)

Example 8 with Features

use of org.apache.karaf.features.internal.model.Features in project karaf by apache.

the class BlacklistTest method testBlacklistBundle.

@Test
public void testBlacklistBundle() {
    URL url = getClass().getResource("f02.xml");
    Features features = JaxbUtil.unmarshal(url.toExternalForm(), true);
    List<String> blacklist = new ArrayList<>();
    blacklist.add("mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jasypt/1.7_1");
    Blacklist.blacklist(features, blacklist);
    for (Feature feature : features.getFeature()) {
        for (Bundle bundle : feature.getBundle()) {
            assertNotEquals("mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jasypt/1.7_1", bundle.getLocation());
        }
    }
}
Also used : Bundle(org.apache.karaf.features.internal.model.Bundle) ArrayList(java.util.ArrayList) Features(org.apache.karaf.features.internal.model.Features) Feature(org.apache.karaf.features.internal.model.Feature) URL(java.net.URL) Test(org.junit.Test)

Example 9 with Features

use of org.apache.karaf.features.internal.model.Features in project karaf by apache.

the class BlacklistTest method testBlacklistFeatureWithVersion.

@Test
public void testBlacklistFeatureWithVersion() {
    URL url = getClass().getResource("f02.xml");
    Features features = JaxbUtil.unmarshal(url.toExternalForm(), true);
    List<String> blacklist = new ArrayList<>();
    blacklist.add("spring;range=2.5.6.SEC02");
    Blacklist.blacklist(features, blacklist);
    for (Feature feature : features.getFeature()) {
        assertNotEquals("spring/2.5.6.SEC02", feature.getId());
    }
}
Also used : ArrayList(java.util.ArrayList) Features(org.apache.karaf.features.internal.model.Features) Feature(org.apache.karaf.features.internal.model.Feature) URL(java.net.URL) Test(org.junit.Test)

Example 10 with Features

use of org.apache.karaf.features.internal.model.Features in project karaf by apache.

the class FeaturesServiceImpl method computeFeaturesToAdd.

private Set<FeatureReq> computeFeaturesToAdd(EnumSet<Option> options, Set<FeatureReq> toInstall) throws Exception {
    Map<String, Map<String, Feature>> allFeatures = getFeatureCache();
    Feature[] installedFeatures = listInstalledFeatures();
    Set<FeatureReq> toAdd = new HashSet<>();
    for (FeatureReq featureReq : toInstall) {
        Collection<Feature> matching = featureReq.getMatchingFeatures(allFeatures).collect(toSet());
        for (Feature f : matching) {
            toAdd.add(new FeatureReq(f));
            Arrays.stream(installedFeatures).filter(fi -> isSameFeature(f, fi)).forEach(this::logInstalledOrUpdated);
        }
        if (matching.isEmpty() && !options.contains(Option.NoFailOnFeatureNotFound)) {
            throw new IllegalArgumentException("No matching features for " + featureReq);
        }
    }
    return toAdd;
}
Also used : Arrays(java.util.Arrays) Enumeration(java.util.Enumeration) LoggerFactory(org.slf4j.LoggerFactory) FeaturesService(org.apache.karaf.features.FeaturesService) CopyOnWriteArrayIdentityList(org.apache.karaf.util.collections.CopyOnWriteArrayIdentityList) FeaturesListener(org.apache.karaf.features.FeaturesListener) StateStorage.toStringStringSetMap(org.apache.karaf.features.internal.service.StateStorage.toStringStringSetMap) JaxbUtil(org.apache.karaf.features.internal.model.JaxbUtil) Map(java.util.Map) URI(java.net.URI) Bundle(org.osgi.framework.Bundle) EnumSet(java.util.EnumSet) BundleException(org.osgi.framework.BundleException) Collectors.toSet(java.util.stream.Collectors.toSet) MavenResolver(org.ops4j.pax.url.mvn.MavenResolver) BundleInfo(org.apache.karaf.features.BundleInfo) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) Predicate(java.util.function.Predicate) MapUtils(org.apache.karaf.features.internal.util.MapUtils) Collection(java.util.Collection) Feature(org.apache.karaf.features.Feature) Set(java.util.Set) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) Collectors(java.util.stream.Collectors) JAXBException(javax.xml.bind.JAXBException) Executors(java.util.concurrent.Executors) ThreadUtils(org.apache.karaf.util.ThreadUtils) List(java.util.List) Stream(java.util.stream.Stream) Wire(org.osgi.resource.Wire) ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin) Queue(java.util.Queue) DownloadManager(org.apache.karaf.features.internal.download.DownloadManager) Features(org.apache.karaf.features.internal.model.Features) FrameworkInfo(org.apache.karaf.features.internal.service.BundleInstallSupport.FrameworkInfo) Dictionary(java.util.Dictionary) DownloadManagers(org.apache.karaf.features.internal.download.DownloadManagers) JsonWriter(org.apache.karaf.util.json.JsonWriter) DigraphHelper(org.apache.karaf.features.internal.region.DigraphHelper) HashMap(java.util.HashMap) Function(java.util.function.Function) TreeSet(java.util.TreeSet) FeatureEvent(org.apache.karaf.features.FeatureEvent) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Configuration(org.osgi.service.cm.Configuration) MavenResolvers(org.ops4j.pax.url.mvn.MavenResolvers) VersionCleaner(org.apache.felix.utils.version.VersionCleaner) Hashtable(java.util.Hashtable) LinkedHashSet(java.util.LinkedHashSet) ExecutorService(java.util.concurrent.ExecutorService) DeploymentListener(org.apache.karaf.features.DeploymentListener) Collections.emptyMap(java.util.Collections.emptyMap) Logger(org.slf4j.Logger) Resource(org.osgi.resource.Resource) StringWriter(java.io.StringWriter) FeatureState(org.apache.karaf.features.FeatureState) FileOutputStream(java.io.FileOutputStream) Repository(org.apache.karaf.features.Repository) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) Resolver(org.osgi.service.resolver.Resolver) File(java.io.File) RepositoryEvent(org.apache.karaf.features.RepositoryEvent) DEFAULT_VERSION(org.apache.karaf.features.internal.model.Feature.DEFAULT_VERSION) ExecutionException(java.util.concurrent.ExecutionException) JsonReader(org.apache.karaf.util.json.JsonReader) VERSION_SEPARATOR(org.apache.karaf.features.internal.model.Feature.VERSION_SEPARATOR) TreeMap(java.util.TreeMap) RegionDigraph(org.eclipse.equinox.region.RegionDigraph) StringJoiner(java.util.StringJoiner) DeploymentEvent(org.apache.karaf.features.DeploymentEvent) ArrayDeque(java.util.ArrayDeque) Collections(java.util.Collections) InputStream(java.io.InputStream) StateStorage.toStringStringSetMap(org.apache.karaf.features.internal.service.StateStorage.toStringStringSetMap) Map(java.util.Map) HashMap(java.util.HashMap) Collections.emptyMap(java.util.Collections.emptyMap) TreeMap(java.util.TreeMap) Feature(org.apache.karaf.features.Feature) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

Features (org.apache.karaf.features.internal.model.Features)37 Feature (org.apache.karaf.features.internal.model.Feature)21 ArrayList (java.util.ArrayList)14 HashMap (java.util.HashMap)14 File (java.io.File)12 LinkedHashMap (java.util.LinkedHashMap)12 IOException (java.io.IOException)11 LinkedHashSet (java.util.LinkedHashSet)11 URL (java.net.URL)10 HashSet (java.util.HashSet)10 ConfigFile (org.apache.karaf.features.internal.model.ConfigFile)10 Test (org.junit.Test)10 Map (java.util.Map)9 TreeMap (java.util.TreeMap)9 Downloader (org.apache.karaf.features.internal.download.Downloader)8 InputStream (java.io.InputStream)7 List (java.util.List)7 Bundle (org.apache.karaf.features.internal.model.Bundle)7 Conditional (org.apache.karaf.features.internal.model.Conditional)7 Dependency (org.apache.karaf.features.internal.model.Dependency)7