karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject karaf git commit: Increase number of retries for failed downloads Parse deprecated osgi.ee header Fix resolver heuristic to stabilise the resolver and avoid subsequent resolution to change the result. Remove mina-core which is not needed anymore since we
Date Thu, 05 Mar 2015 22:47:18 GMT
Repository: karaf
Updated Branches:
  refs/heads/master fb3187675 -> 7e2c59274


Increase number of retries for failed downloads
Parse deprecated osgi.ee header
Fix resolver heuristic to stabilise the resolver and avoid subsequent resolution to change
the result.
Remove mina-core which is not needed anymore since we require jdk 7.


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

Branch: refs/heads/master
Commit: 7e2c59274682fa024360a2de3fd0b40645945758
Parents: fb31876
Author: Guillaume Nodet <gnodet@gmail.com>
Authored: Thu Mar 5 21:48:51 2015 +0100
Committer: Guillaume Nodet <gnodet@gmail.com>
Committed: Thu Mar 5 23:47:09 2015 +0100

----------------------------------------------------------------------
 .../standard/src/main/feature/feature.xml       |   4 -
 .../impl/AbstractRetryableDownloadTask.java     |   4 +-
 .../internal/region/CandidateComparator.java    |   7 ++
 .../internal/resolver/ResourceBuilder.java      | 104 +++++++++++++++++++
 .../features/internal/service/Deployer.java     |   7 +-
 .../internal/service/FeaturesServiceImpl.java   |   6 ++
 6 files changed, 120 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/7e2c5927/assemblies/features/standard/src/main/feature/feature.xml
----------------------------------------------------------------------
diff --git a/assemblies/features/standard/src/main/feature/feature.xml b/assemblies/features/standard/src/main/feature/feature.xml
index 01fdb3f..c9b6e6d 100644
--- a/assemblies/features/standard/src/main/feature/feature.xml
+++ b/assemblies/features/standard/src/main/feature/feature.xml
@@ -418,10 +418,6 @@
         </config>
         <feature>shell</feature>
         <feature>jaas</feature>
-        <conditional>
-            <condition>req:osgi.ee;filter:="(&amp;(osgi.ee=JavaSE)(!(version>=1.7)))"</condition>
-            <bundle start="true" start-level="30">mvn:org.apache.mina/mina-core/${mina.version}</bundle>
-        </conditional>
         <bundle start="true" start-level="30">mvn:org.apache.sshd/sshd-core/${sshd.version}</bundle>
         <bundle start="true" start-level="30">mvn:org.apache.karaf.shell/org.apache.karaf.shell.ssh/${project.version}</bundle>
     </feature>

http://git-wip-us.apache.org/repos/asf/karaf/blob/7e2c5927/features/core/src/main/java/org/apache/karaf/features/internal/download/impl/AbstractRetryableDownloadTask.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/download/impl/AbstractRetryableDownloadTask.java
b/features/core/src/main/java/org/apache/karaf/features/internal/download/impl/AbstractRetryableDownloadTask.java
index f315e4b..ccde347 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/download/impl/AbstractRetryableDownloadTask.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/download/impl/AbstractRetryableDownloadTask.java
@@ -41,10 +41,10 @@ public abstract class AbstractRetryableDownloadTask extends AbstractDownloadTask
                 File file = download();
                 setFile(file);
             } catch (IOException e) {
-                if (++scheduleNbRun < 5) {
+                if (++scheduleNbRun < 9) {
                     long delay = (long)(scheduleDelay * 3 / 2 + Math.random() * scheduleDelay
/ 2);
                     LOGGER.debug("Error downloading " + url + ": " + e.getMessage() + ".
Retrying in approx " + delay + " ms.");
-                    executorService.schedule(this, scheduleDelay, TimeUnit.MILLISECONDS);
+                    executorService.schedule(this, delay, TimeUnit.MILLISECONDS);
                     scheduleDelay *= 2;
                 } else {
                     setException(new IOException("Error downloading " + url, e));

http://git-wip-us.apache.org/repos/asf/karaf/blob/7e2c5927/features/core/src/main/java/org/apache/karaf/features/internal/region/CandidateComparator.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/region/CandidateComparator.java
b/features/core/src/main/java/org/apache/karaf/features/internal/region/CandidateComparator.java
index dfbfd05..0bf271c 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/region/CandidateComparator.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/region/CandidateComparator.java
@@ -19,6 +19,7 @@ package org.apache.karaf.features.internal.region;
 import java.util.Comparator;
 import java.util.Set;
 
+import org.apache.felix.resolver.Util;
 import org.osgi.framework.Version;
 import org.osgi.framework.namespace.BundleNamespace;
 import org.osgi.framework.namespace.IdentityNamespace;
@@ -109,6 +110,12 @@ public class CandidateComparator implements Comparator<Capability>
{
                 c = compareVersions(v2, v1);
             }
         }
+        if (c == 0) {
+            // We just want to have a deterministic heuristic
+            String n1 = Util.getSymbolicName(cap1.getResource());
+            String n2 = Util.getSymbolicName(cap2.getResource());
+            c = n1.compareTo(n2);
+        }
         return c;
     }
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/7e2c5927/features/core/src/main/java/org/apache/karaf/features/internal/resolver/ResourceBuilder.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/resolver/ResourceBuilder.java
b/features/core/src/main/java/org/apache/karaf/features/internal/resolver/ResourceBuilder.java
index 7ae1736..47a0661 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/resolver/ResourceBuilder.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/resolver/ResourceBuilder.java
@@ -30,6 +30,7 @@ import org.apache.felix.utils.version.VersionTable;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
+import org.osgi.framework.namespace.ExecutionEnvironmentNamespace;
 import org.osgi.framework.namespace.IdentityNamespace;
 import org.osgi.framework.wiring.BundleRevision;
 import org.osgi.namespace.service.ServiceNamespace;
@@ -170,6 +171,12 @@ public final class ResourceBuilder {
         List<Requirement> requireReqs = convertRequireCapabilities(requireClauses,
resource);
 
         //
+        // Parse Bundle-RequiredExecutionEnvironment.
+        //
+        List<Requirement> breeReqs =
+                parseBreeHeader((String) headerMap.get(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT),
resource);
+
+        //
         // Parse Export-Package.
         //
 
@@ -733,6 +740,103 @@ public final class ResourceBuilder {
         return reqs;
     }
 
+    private static List<Requirement> parseBreeHeader(String header, Resource resource)
{
+        List<String> filters = new ArrayList<String>();
+        for (String entry : parseDelimitedString(header, ",")) {
+            List<String> names = parseDelimitedString(entry, "/");
+            List<String> left = parseDelimitedString(names.get(0), "-");
+
+            String lName = left.get(0);
+            Version lVer;
+            try {
+                lVer = Version.parseVersion(left.get(1));
+            } catch (Exception ex) {
+                // Version doesn't parse. Make it part of the name.
+                lName = names.get(0);
+                lVer = null;
+            }
+
+            String rName = null;
+            Version rVer = null;
+            if (names.size() > 1) {
+                List<String> right = parseDelimitedString(names.get(1), "-");
+                rName = right.get(0);
+                try {
+                    rVer = Version.parseVersion(right.get(1));
+                } catch (Exception ex) {
+                    rName = names.get(1);
+                    rVer = null;
+                }
+            }
+
+            String versionClause;
+            if (lVer != null) {
+                if ((rVer != null) && (!rVer.equals(lVer))) {
+                    // Both versions are defined, but different. Make each of them part of
the name
+                    lName = names.get(0);
+                    rName = names.get(1);
+                    versionClause = null;
+                } else {
+                    versionClause = getBreeVersionClause(lVer);
+                }
+            } else {
+                versionClause = getBreeVersionClause(rVer);
+            }
+
+            if ("J2SE".equals(lName)) {
+                // J2SE is not used in the Capability variant of BREE, use JavaSE here
+                // This can only happen with the lName part...
+                lName = "JavaSE";
+            }
+
+            String nameClause;
+            if (rName != null)
+                nameClause = "(" + ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE
+ "=" + lName + "/" + rName + ")";
+            else
+                nameClause = "(" + ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE
+ "=" + lName + ")";
+
+            String filter;
+            if (versionClause != null)
+                filter = "(&" + nameClause + versionClause + ")";
+            else
+                filter = nameClause;
+
+            filters.add(filter);
+        }
+
+        if (filters.size() == 0) {
+            return Collections.emptyList();
+        } else {
+            String reqFilter;
+            if (filters.size() == 1) {
+                reqFilter = filters.get(0);
+            } else {
+                // If there are more BREE filters, we need to or them together
+                StringBuilder sb = new StringBuilder("(|");
+                for (String f : filters) {
+                    sb.append(f);
+                }
+                sb.append(")");
+                reqFilter = sb.toString();
+            }
+
+            SimpleFilter sf = SimpleFilter.parse(reqFilter);
+            return Collections.<Requirement>singletonList(new RequirementImpl(
+                    resource,
+                    ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE,
+                    Collections.singletonMap(ExecutionEnvironmentNamespace.REQUIREMENT_FILTER_DIRECTIVE,
reqFilter),
+                    Collections.<String, Object>emptyMap(),
+                    sf));
+        }
+    }
+
+    private static String getBreeVersionClause(Version ver) {
+        if (ver == null)
+            return null;
+
+        return "(" + ExecutionEnvironmentNamespace.CAPABILITY_VERSION_ATTRIBUTE + "=" + ver
+ ")";
+    }
+
     private static List<ParsedHeaderClause> normalizeRequireClauses(List<ParsedHeaderClause>
clauses) {
         // Convert bundle version attribute to VersionRange type.
         for (ParsedHeaderClause clause : clauses) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/7e2c5927/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
b/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
index ab91533..ffa34ca 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
@@ -274,7 +274,7 @@ public class Deployer {
         for (Map.Entry<String, Set<String>> entry : delFeatures.entrySet()) {
             Map<String, String> map = stateFeatures.get(entry.getKey());
             if (map != null) {
-                map.entrySet().removeAll(entry.getValue());
+                map.keySet().removeAll(entry.getValue());
                 if (map.isEmpty()) {
                     stateFeatures.remove(entry.getKey());
                 }
@@ -944,11 +944,6 @@ public class Deployer {
                     if (!isBundle(wire.getProvider())) {
                         continue;
                     }
-                    // Ignore bundles that won't get deployed for some reason
-                    if (!resources.containsKey(wire.getProvider())
-                            && !(wire.getProvider() instanceof BundleRevision)) {
-                        continue;
-                    }
                     if (!wiredResources.containsKey(wire.getProvider())) {
                         wiredResources.put(wire.getProvider(), wire.getRequirement());
                     }

http://git-wip-us.apache.org/repos/asf/karaf/blob/7e2c5927/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 3fd8a39..b5ce5d5 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
@@ -77,6 +77,7 @@ import org.osgi.framework.ServiceRegistration;
 import org.osgi.framework.Version;
 import org.osgi.framework.hooks.resolver.ResolverHook;
 import org.osgi.framework.hooks.resolver.ResolverHookFactory;
+import org.osgi.framework.namespace.ExecutionEnvironmentNamespace;
 import org.osgi.framework.namespace.HostNamespace;
 import org.osgi.framework.startlevel.BundleStartLevel;
 import org.osgi.framework.startlevel.FrameworkStartLevel;
@@ -1180,6 +1181,11 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
             @Override
             public void filterMatches(BundleRequirement requirement, Collection<BundleCapability>
candidates) {
                 if (Thread.currentThread() == thread) {
+                    // osgi.ee capabilities are provided by the system bundle, so just ignore
those
+                    if (ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE
+                            .equals(requirement.getNamespace())) {
+                        return;
+                    }
                     Bundle sourceBundle = requirement.getRevision().getBundle();
                     Resource sourceResource = bndToRes.get(sourceBundle);
                     Set<Resource> wired = new HashSet<>();


Mime
View raw message