karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject [2/2] karaf git commit: Small refactoring
Date Tue, 09 May 2017 12:48:50 GMT
Small refactoring


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

Branch: refs/heads/master
Commit: ca2a0a71e21ffd7cf370bd58957256a8b93007a5
Parents: c7996ae
Author: Christian Schneider <chris@die-schneider.net>
Authored: Tue May 9 14:47:21 2017 +0200
Committer: Christian Schneider <chris@die-schneider.net>
Committed: Tue May 9 14:47:21 2017 +0200

----------------------------------------------------------------------
 .../karaf/features/extension/BundleWires.java   | 26 +++++++++++++-------
 1 file changed, 17 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/ca2a0a71/features/extension/src/main/java/org/apache/karaf/features/extension/BundleWires.java
----------------------------------------------------------------------
diff --git a/features/extension/src/main/java/org/apache/karaf/features/extension/BundleWires.java
b/features/extension/src/main/java/org/apache/karaf/features/extension/BundleWires.java
index 51ff8b1..1690851 100644
--- a/features/extension/src/main/java/org/apache/karaf/features/extension/BundleWires.java
+++ b/features/extension/src/main/java/org/apache/karaf/features/extension/BundleWires.java
@@ -48,7 +48,9 @@ class BundleWires {
     BundleWires(Bundle bundle) {
         this.bundleId = bundle.getBundleId();
         for (BundleWire wire : bundle.adapt(BundleWiring.class).getRequiredWires(null)) {
-            this.wiring.put(getRequirementId(wire.getRequirement()), getCapabilityId(wire.getCapability()));
+            String requirementId = getRequirementId(wire.getRequirement());
+            String capabilityId = getCapabilityId(wire.getCapability());
+            this.wiring.put(requirementId, capabilityId);
         }
     }
 
@@ -92,14 +94,20 @@ class BundleWires {
     }
 
     long getFragmentHost() {
-        return wiring.entrySet().stream().filter(e -> e.getKey().startsWith(HostNamespace.HOST_NAMESPACE))
-            .map(Map.Entry::getValue).mapToLong(s -> {
-                int idx = s.indexOf(';');
-                if (idx > 0) {
-                    s = s.substring(0, idx);
-                }
-                return Long.parseLong(s.trim());
-            }).findFirst().orElse(-1);
+        return wiring.entrySet().stream() //
+            .filter(e -> e.getKey().startsWith(HostNamespace.HOST_NAMESPACE)) //
+            .map(Map.Entry::getValue) //
+            .mapToLong(s -> getBundleId(s)) //
+            .findFirst() //
+            .orElse(-1);
+    }
+    
+    private long getBundleId(String value) {
+        int idx = value.indexOf(';');
+        if (idx > 0) {
+            value = value.substring(0, idx);
+        }
+        return Long.parseLong(value.trim());
     }
 
     void filterMatches(BundleRequirement requirement, Collection<BundleCapability>
candidates) {


Mime
View raw message