You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gg...@apache.org on 2018/02/01 18:08:09 UTC

[karaf] branch master updated: [KARAF-5591] Do not consider blacklisted feature dependencies and conditionals

This is an automated email from the ASF dual-hosted git repository.

ggrzybek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/master by this push:
     new 0cde0aa  [KARAF-5591] Do not consider blacklisted feature dependencies and conditionals
0cde0aa is described below

commit 0cde0aabdce7474ed4a69f0013f89296b6dd5247
Author: Grzegorz Grzybek <gg...@redhat.com>
AuthorDate: Thu Feb 1 16:50:31 2018 +0100

    [KARAF-5591] Do not consider blacklisted feature dependencies and conditionals
---
 .../java/org/apache/karaf/features/Conditional.java     |  2 +-
 .../main/java/org/apache/karaf/features/Dependency.java |  2 +-
 .../karaf/features/internal/model/Conditional.java      | 15 ++++++++++++++-
 .../karaf/features/internal/model/Dependency.java       | 15 +++++++++++++--
 .../karaf/features/internal/region/Subsystem.java       | 17 ++++++++++++++---
 .../internal/service/FeaturesProcessorImpl.java         | 14 ++++++++++++++
 .../java/org/apache/karaf/profile/assembly/Builder.java |  6 ++++++
 7 files changed, 63 insertions(+), 8 deletions(-)

diff --git a/features/core/src/main/java/org/apache/karaf/features/Conditional.java b/features/core/src/main/java/org/apache/karaf/features/Conditional.java
index 26463f2..b4e4362 100644
--- a/features/core/src/main/java/org/apache/karaf/features/Conditional.java
+++ b/features/core/src/main/java/org/apache/karaf/features/Conditional.java
@@ -18,7 +18,7 @@ package org.apache.karaf.features;
 
 import java.util.List;
 
-public interface Conditional {
+public interface Conditional extends Blacklisting {
 
     List<String> getCondition();
 
diff --git a/features/core/src/main/java/org/apache/karaf/features/Dependency.java b/features/core/src/main/java/org/apache/karaf/features/Dependency.java
index 3f8fda8..aea3be8 100644
--- a/features/core/src/main/java/org/apache/karaf/features/Dependency.java
+++ b/features/core/src/main/java/org/apache/karaf/features/Dependency.java
@@ -17,7 +17,7 @@
 
 package org.apache.karaf.features;
 
-public interface Dependency {
+public interface Dependency extends Blacklisting {
 
     String getName();
 
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/model/Conditional.java b/features/core/src/main/java/org/apache/karaf/features/internal/model/Conditional.java
index d9fc5ce..8bbde76 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/model/Conditional.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/model/Conditional.java
@@ -25,6 +25,7 @@ import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
 
+import org.apache.karaf.features.Blacklisting;
 import org.apache.karaf.features.Feature;
 
 @XmlAccessorType(XmlAccessType.FIELD)
@@ -45,6 +46,9 @@ public class Conditional extends Content implements org.apache.karaf.features.Co
     @XmlTransient
     protected Feature owner;
 
+    @XmlTransient
+    private boolean blacklisted;
+
     public Feature getOwner() {
         return owner;
     }
@@ -76,7 +80,16 @@ public class Conditional extends Content implements org.apache.karaf.features.Co
         return f;
     }
 
-    private String getConditionId() {
+    @Override
+    public boolean isBlacklisted() {
+        return blacklisted;
+    }
+
+    public void setBlacklisted(boolean blacklisted) {
+        this.blacklisted = blacklisted;
+    }
+
+    public String getConditionId() {
         StringBuffer sb = new StringBuffer();
         for (String cond : getCondition()) {
             if (sb.length() > 0) {
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/model/Dependency.java b/features/core/src/main/java/org/apache/karaf/features/internal/model/Dependency.java
index f004204..cfc3c56 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/model/Dependency.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/model/Dependency.java
@@ -19,10 +19,10 @@ package org.apache.karaf.features.internal.model;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlValue;
 
-
 /**
  * <p>Dependency of feature.</p>
  * <p>Java class for dependency complex type.</p>
@@ -50,6 +50,9 @@ public class Dependency implements org.apache.karaf.features.Dependency {
     @XmlAttribute
     protected Boolean dependency;
 
+    @XmlTransient
+    private boolean blacklisted;
+
     public Dependency() {
         // Nothing to do
     }
@@ -131,6 +134,15 @@ public class Dependency implements org.apache.karaf.features.Dependency {
         this.dependency = dependency;
     }
 
+    @Override
+    public boolean isBlacklisted() {
+        return blacklisted;
+    }
+
+    public void setBlacklisted(boolean blacklisted) {
+        this.blacklisted = blacklisted;
+    }
+
     public String toString() {
         return getName() + Feature.VERSION_SEPARATOR + getVersion();
     }
@@ -146,7 +158,6 @@ public class Dependency implements org.apache.karaf.features.Dependency {
         if (dependency != null ? !dependency.equals(that.dependency) : that.dependency != null) return false;
         if (name != null ? !name.equals(that.name) : that.name != null) return false;
         return version != null ? version.equals(that.version) : that.version == null;
-
     }
 
     @Override
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/region/Subsystem.java b/features/core/src/main/java/org/apache/karaf/features/internal/region/Subsystem.java
index d1f6857..897c8f9 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/region/Subsystem.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/region/Subsystem.java
@@ -340,6 +340,9 @@ public class Subsystem extends ResourceImpl {
             // each dependant feature becomes a non-mandatory (why?) requirement of first parent that
             // accepts dependencies
             for (Dependency dep : feature.getDependencies()) {
+                if (dep.isBlacklisted()) {
+                    continue;
+                }
                 Subsystem ss = this;
                 while (!ss.isAcceptDependencies()) {
                     ss = ss.getParent();
@@ -348,6 +351,9 @@ public class Subsystem extends ResourceImpl {
             }
             // each conditional feature becomes a child subsystem of this feature's subsystem
             for (Conditional cond : feature.getConditional()) {
+                if (cond.isBlacklisted()) {
+                    continue;
+                }
                 Feature fcond = cond.asFeature();
                 String ssName = this.name + "#" + (fcond.hasVersion() ? fcond.getName() + "-" + fcond.getVersion() : fcond.getName());
                 Subsystem fs = getChild(ssName);
@@ -451,9 +457,11 @@ public class Subsystem extends ResourceImpl {
         final Downloader downloader = manager.createDownloader();
         if (feature != null) {
             for (Conditional cond : feature.getConditional()) {
-                for (final BundleInfo bi : cond.getBundles()) {
-                    // bundles from conditional features will be added as non-mandatory requirements
-                    infos.put(bi, cond);
+                if (!cond.isBlacklisted()) {
+                    for (final BundleInfo bi : cond.getBundles()) {
+                        // bundles from conditional features will be added as non-mandatory requirements
+                        infos.put(bi, cond);
+                    }
                 }
             }
             for (BundleInfo bi : feature.getBundles()) {
@@ -537,6 +545,9 @@ public class Subsystem extends ResourceImpl {
             // Add conditionals
             Map<Conditional, Resource> resConds = new HashMap<>();
             for (Conditional cond : feature.getConditional()) {
+                if (cond.isBlacklisted()) {
+                    continue;
+                }
                 FeatureResource resCond = FeatureResource.build(feature, cond, featureResolutionRange, bundles);
                 // feature's subsystem will optionally require conditional feature resource
                 addIdentityRequirement(this, resCond, false);
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesProcessorImpl.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesProcessorImpl.java
index bf6033b..518401e 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesProcessorImpl.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesProcessorImpl.java
@@ -32,6 +32,7 @@ import org.apache.karaf.features.FeaturePattern;
 import org.apache.karaf.features.LocationPattern;
 import org.apache.karaf.features.internal.model.Bundle;
 import org.apache.karaf.features.internal.model.Conditional;
+import org.apache.karaf.features.internal.model.Dependency;
 import org.apache.karaf.features.internal.model.Feature;
 import org.apache.karaf.features.internal.model.Features;
 import org.apache.karaf.features.internal.model.processing.BundleReplacements;
@@ -152,6 +153,19 @@ public class FeaturesProcessorImpl implements FeaturesProcessor {
             boolean allBlacklisted = features.isBlacklisted();
             feature.setBlacklisted(allBlacklisted || isFeatureBlacklisted(feature));
 
+            // blacklisting feature's dependencies and conditionals
+            for (Conditional conditional : feature.getConditional()) {
+                boolean isConditionBlacklisted = false;
+                for (String cond : conditional.getCondition()) {
+                    isConditionBlacklisted |= isFeatureBlacklisted(new Feature(cond));
+                }
+                conditional.setBlacklisted(feature.isBlacklisted() || isConditionBlacklisted);
+            }
+
+            for (Dependency dep : feature.getFeature()) {
+                dep.setBlacklisted(feature.isBlacklisted() || isFeatureBlacklisted(new Feature(dep.getName(), dep.getVersion())));
+            }
+
             // override dependency flag (null - don't touch, false - change to false, true - change to true)
             Boolean dependency = null;
             for (OverrideBundleDependency.OverrideFeatureDependency overrideFeatureDependency : getInstructions().getOverrideBundleDependency().getFeatures()) {
diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
index c9a3982..5b9a6c4 100644
--- a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
+++ b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
@@ -1537,6 +1537,9 @@ public class Builder {
                 installer.installArtifact(configFile.getLocation().trim());
             }
             for (Conditional cond : feature.getConditional()) {
+                if (cond.isBlacklisted()) {
+                    LOGGER.info("   Conditionial " + cond.getConditionId() + " is blacklisted, ignoring");
+                }
                 for (Bundle bundle : cond.getBundle()) {
                     if (!ignoreDependencyFlag || !bundle.isDependency()) {
                         installer.installArtifact(bundle);
@@ -1614,6 +1617,9 @@ public class Builder {
                 }
             }
             for (Conditional cond : feature.getConditional()) {
+                if (cond.isBlacklisted()) {
+                    LOGGER.info("   Conditionial " + cond.getConditionId() + " is blacklisted, ignoring");
+                }
                 for (Bundle bundle : cond.getBundle()) {
                     if (!ignoreDependencyFlag || !bundle.isDependency()) {
                         bundleInfos.add(bundle);

-- 
To stop receiving notification emails like this one, please contact
ggrzybek@apache.org.