karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject [2/5] git commit: Clean some warnings and unused code in features/core
Date Mon, 19 May 2014 19:16:25 GMT
Clean some warnings and unused code in features/core


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

Branch: refs/heads/master
Commit: 1d60fca2132cc2b204ac43efb1a9fcc589e16e82
Parents: 49aeec2
Author: Guillaume Nodet <gnodet@gmail.com>
Authored: Mon May 19 11:17:50 2014 +0200
Committer: Guillaume Nodet <gnodet@gmail.com>
Committed: Mon May 19 21:16:05 2014 +0200

----------------------------------------------------------------------
 .../internal/resolver/ResourceUtils.java        |  4 +--
 .../internal/resolver/SimpleFilter.java         |  7 +++--
 .../internal/service/BootFeaturesInstaller.java | 29 ++------------------
 3 files changed, 9 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/1d60fca2/features/core/src/main/java/org/apache/karaf/features/internal/resolver/ResourceUtils.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/resolver/ResourceUtils.java
b/features/core/src/main/java/org/apache/karaf/features/internal/resolver/ResourceUtils.java
index d6cfe1d..d3f5527 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/resolver/ResourceUtils.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/resolver/ResourceUtils.java
@@ -79,8 +79,8 @@ public final class ResourceUtils {
     }
 
     public static void addIdentityRequirement(ResourceImpl resource, String name, String
type, String range) {
-        Map<String, String> dirs = new HashMap<String, String>();
-        Map<String, Object> attrs = new HashMap<String, Object>();
+        Map<String, String> dirs = new HashMap<>();
+        Map<String, Object> attrs = new HashMap<>();
         if (name != null) {
             attrs.put(IDENTITY_NAMESPACE, name);
         }

http://git-wip-us.apache.org/repos/asf/karaf/blob/1d60fca2/features/core/src/main/java/org/apache/karaf/features/internal/resolver/SimpleFilter.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/resolver/SimpleFilter.java
b/features/core/src/main/java/org/apache/karaf/features/internal/resolver/SimpleFilter.java
index 1e2a48c..2354519 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/resolver/SimpleFilter.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/resolver/SimpleFilter.java
@@ -57,8 +57,9 @@ public class SimpleFilter {
         return op;
     }
 
+    @SuppressWarnings("unchecked")
     public String toString() {
-        String s = null;
+        String s;
         switch (op) {
         case AND:
             s = "(&" + toString((List) value) + ")";
@@ -138,6 +139,7 @@ public class SimpleFilter {
         return o.toString();
     }
 
+    @SuppressWarnings("unchecked")
     public static SimpleFilter parse(String filter) {
         int idx = skipWhitespace(filter, 0);
 
@@ -446,11 +448,12 @@ public class SimpleFilter {
      * @param attrs Map of attributes to convert to a filter.
      * @return A filter corresponding to the attributes.
      */
+    @SuppressWarnings("unchecked")
     public static SimpleFilter convert(Map<String, Object> attrs) {
         // Rather than building a filter string to be parsed into a SimpleFilter,
         // we will just create the parsed SimpleFilter directly.
 
-        List<SimpleFilter> filters = new ArrayList<SimpleFilter>();
+        List<SimpleFilter> filters = new ArrayList<>();
 
         for (Entry<String, Object> entry : attrs.entrySet()) {
             if (entry.getValue() instanceof VersionRange) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/1d60fca2/features/core/src/main/java/org/apache/karaf/features/internal/service/BootFeaturesInstaller.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/BootFeaturesInstaller.java
b/features/core/src/main/java/org/apache/karaf/features/internal/service/BootFeaturesInstaller.java
index 81e6a3a..f8283dd 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/BootFeaturesInstaller.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/BootFeaturesInstaller.java
@@ -28,7 +28,6 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.karaf.features.BootFinished;
-import org.apache.karaf.features.Feature;
 import org.apache.karaf.features.FeaturesService;
 import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
@@ -36,8 +35,6 @@ import org.slf4j.LoggerFactory;
 
 public class BootFeaturesInstaller {
 
-    public static final String VERSION_PREFIX = "version=";
-
     private static final Logger LOGGER = LoggerFactory.getLogger(BootFeaturesInstaller.class);
 
     private final FeaturesServiceImpl featuresService;
@@ -115,32 +112,10 @@ public class BootFeaturesInstaller {
         }
     }
 
-    /**
-     * @param featureSt either feature name or <featurename>;version=<version>
-     * @return feature matching the feature string
-     * @throws Exception
-     */
-    private Feature getFeature(String featureSt) throws Exception {
-        String[] parts = featureSt.trim().split(";");
-        String featureName = parts[0];
-        String featureVersion = null;
-        for (String part : parts) {
-            // if the part starts with "version=" it contains the version info
-            if (part.startsWith(VERSION_PREFIX)) {
-                featureVersion = part.substring(VERSION_PREFIX.length());
-            }
-        }
-        if (featureVersion == null) {
-            // no version specified - use default version
-            featureVersion = org.apache.karaf.features.internal.model.Feature.DEFAULT_VERSION;
-        }
-        return featuresService.getFeature(featureName, featureVersion);
-    }
-
     protected List<Set<String>> parseBootFeatures(String bootFeatures) {
         Pattern pattern = Pattern.compile("(\\((.+))\\),|.+");
         Matcher matcher = pattern.matcher(bootFeatures);
-        List<Set<String>> result = new ArrayList<Set<String>>();
+        List<Set<String>> result = new ArrayList<>();
         while (matcher.find()) {
             String group = matcher.group(2) != null ? matcher.group(2) : matcher.group();
             result.add(parseFeatureList(group));
@@ -149,7 +124,7 @@ public class BootFeaturesInstaller {
     }
 
     protected Set<String> parseFeatureList(String group) {
-        HashSet<String> features = new HashSet<String>();
+        HashSet<String> features = new HashSet<>();
         for (String feature : Arrays.asList(group.trim().split("\\s*,\\s*"))) {
             if (feature.length() > 0) {
                 features.add(feature);


Mime
View raw message