karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject [08/11] karaf git commit: Only parse blacklisting clauses once when loading repositories
Date Mon, 15 May 2017 13:12:08 GMT
Only parse blacklisting clauses once when loading repositories

Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/efa6dc7a
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/efa6dc7a
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/efa6dc7a

Branch: refs/heads/master
Commit: efa6dc7ab9b138fa23e2d41698bf1690ed28ccac
Parents: 6abc7da
Author: Guillaume Nodet <gnodet@apache.org>
Authored: Mon May 15 14:34:25 2017 +0200
Committer: Guillaume Nodet <gnodet@apache.org>
Committed: Mon May 15 14:34:25 2017 +0200

----------------------------------------------------------------------
 .../karaf/features/internal/service/Blacklist.java   |  6 ++----
 .../internal/service/FeaturesServiceImpl.java        |  7 ++++++-
 .../features/internal/service/RepositoryImpl.java    | 15 ++++++++++++---
 3 files changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/efa6dc7a/features/core/src/main/java/org/apache/karaf/features/internal/service/Blacklist.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/Blacklist.java
b/features/core/src/main/java/org/apache/karaf/features/internal/service/Blacklist.java
index 22610b7..0d804a7 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/Blacklist.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/Blacklist.java
@@ -57,10 +57,8 @@ public class Blacklist {
     }
 
     public static void blacklist(Features features, Collection<String> blacklist) {
-        if (!blacklist.isEmpty()) {
-            Clause[] clauses = Parser.parseClauses(blacklist.toArray(new String[blacklist.size()]));
-            blacklist(features, clauses);
-        }
+        Clause[] clauses = Parser.parseClauses(blacklist.toArray(new String[blacklist.size()]));
+        blacklist(features, clauses);
     }
 
     public static void blacklist(Features features, Clause[] clauses) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/efa6dc7a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
index d3640f9..6991e17 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
@@ -49,6 +49,8 @@ import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
+import org.apache.felix.utils.manifest.Clause;
+import org.apache.felix.utils.manifest.Parser;
 import org.apache.felix.utils.version.VersionCleaner;
 import org.apache.felix.utils.version.VersionRange;
 import org.apache.felix.utils.version.VersionTable;
@@ -721,6 +723,9 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
         }
         //the outer map's key is feature name, the inner map's key is feature version
         Map<String, Map<String, Feature>> map = new HashMap<>();
+        // Load blacklist
+        Set<String> blacklistStrings = Blacklist.loadBlacklist(blacklisted);
+        Clause[] blacklist = Parser.parseClauses(blacklistStrings.toArray(new String[blacklistStrings.size()]));
         // Two phase load:
         // * first load dependent repositories
         Set<String> loaded = new HashSet<>();
@@ -733,7 +738,7 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
             }
             try {
                 if (repo == null) {
-                    RepositoryImpl rep = new RepositoryImpl(URI.create(uri), blacklisted);
+                    RepositoryImpl rep = new RepositoryImpl(URI.create(uri), blacklist);
                     rep.load();
                     repo = rep;
                     synchronized (lock) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/efa6dc7a/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryImpl.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryImpl.java
b/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryImpl.java
index 9b176bb..0cd0407 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryImpl.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryImpl.java
@@ -21,7 +21,10 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InterruptedIOException;
 import java.net.URI;
+import java.util.Set;
 
+import org.apache.felix.utils.manifest.Clause;
+import org.apache.felix.utils.manifest.Parser;
 import org.apache.karaf.features.Repository;
 import org.apache.karaf.features.internal.model.Features;
 import org.apache.karaf.features.internal.model.JaxbUtil;
@@ -32,16 +35,22 @@ import org.apache.karaf.features.internal.model.JaxbUtil;
 public class RepositoryImpl implements Repository {
 
     private final URI uri;
-    private final String blacklisted;
+    private final Clause[] blacklisted;
     private Features features;
 
     public RepositoryImpl(URI uri) {
-        this(uri, null);
+        this(uri, (Clause[]) null);
     }
 
     public RepositoryImpl(URI uri, String blacklisted) {
         this.uri = uri;
-        this.blacklisted = blacklisted;
+        Set<String> blacklistStrings = Blacklist.loadBlacklist(blacklisted);
+        this.blacklisted = Parser.parseClauses(blacklistStrings.toArray(new String[blacklistStrings.size()]));
+    }
+
+    public RepositoryImpl(URI uri, Clause[] blacklisted) {
+        this.uri = uri;
+        this.blacklisted = blacklisted != null ? blacklisted : new Clause[0];
     }
 
     public URI getURI() {


Mime
View raw message