Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id F0AB0200CAD for ; Mon, 15 May 2017 15:12:03 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id EF609160BC1; Mon, 15 May 2017 13:12:03 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 75BB1160BD3 for ; Mon, 15 May 2017 15:12:02 +0200 (CEST) Received: (qmail 40831 invoked by uid 500); 15 May 2017 13:12:01 -0000 Mailing-List: contact commits-help@karaf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@karaf.apache.org Delivered-To: mailing list commits@karaf.apache.org Received: (qmail 40569 invoked by uid 99); 15 May 2017 13:12:01 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 May 2017 13:12:01 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 518E3E10F3; Mon, 15 May 2017 13:12:01 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: gnodet@apache.org To: commits@karaf.apache.org Date: Mon, 15 May 2017 13:12:08 -0000 Message-Id: In-Reply-To: <768545f3f8354b969724fa4c18da6beb@git.apache.org> References: <768545f3f8354b969724fa4c18da6beb@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [08/11] karaf git commit: Only parse blacklisting clauses once when loading repositories archived-at: Mon, 15 May 2017 13:12:04 -0000 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 Authored: Mon May 15 14:34:25 2017 +0200 Committer: Guillaume Nodet 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 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> map = new HashMap<>(); + // Load blacklist + Set blacklistStrings = Blacklist.loadBlacklist(blacklisted); + Clause[] blacklist = Parser.parseClauses(blacklistStrings.toArray(new String[blacklistStrings.size()])); // Two phase load: // * first load dependent repositories Set 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 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() {