karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject karaf git commit: [KARAF-4870] Store the wiring in the output file when using "feature:install --store"
Date Wed, 30 Nov 2016 10:42:01 GMT
Repository: karaf
Updated Branches:
  refs/heads/master 3d26b59d3 -> c7806957e


[KARAF-4870] Store the wiring in the output file when using "feature:install --store"

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

Branch: refs/heads/master
Commit: c7806957e042fe90087a52b4d19ff7c31e9c5950
Parents: 3d26b59
Author: Guillaume Nodet <gnodet@apache.org>
Authored: Wed Nov 30 11:41:48 2016 +0100
Committer: Guillaume Nodet <gnodet@apache.org>
Committed: Wed Nov 30 11:41:48 2016 +0100

----------------------------------------------------------------------
 .../internal/region/SubsystemResolver.java      | 33 ++++++++++++++++++++
 .../internal/service/FeaturesServiceImpl.java   |  9 ++----
 2 files changed, 36 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/c7806957/features/core/src/main/java/org/apache/karaf/features/internal/region/SubsystemResolver.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/region/SubsystemResolver.java
b/features/core/src/main/java/org/apache/karaf/features/internal/region/SubsystemResolver.java
index 870236d..12d66d6 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/region/SubsystemResolver.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/region/SubsystemResolver.java
@@ -201,7 +201,9 @@ public class SubsystemResolver {
             try {
                 wiring = resolver.resolve(context);
                 json.put("success", "true");
+                json.put("wiring", toJson(wiring));
             } catch (Exception e) {
+                json.put("success", "false");
                 json.put("exception", e.toString());
                 throw e;
             } finally {
@@ -235,6 +237,37 @@ public class SubsystemResolver {
         return wiring;
     }
 
+    private Object toJson(Map<Resource, List<Wire>> wiring) {
+        Map<String, List<Map<String, Object>>> wires = new HashMap<>();
+        for (Map.Entry<Resource, List<Wire>> reswiring : wiring.entrySet()) {
+            Resource resource = reswiring.getKey();
+            String id = toString(resource);
+            List<Map<String, Object>> reswires = new ArrayList<>();
+            for (Wire w : reswiring.getValue()) {
+                Map<String, Object> rw = new LinkedHashMap<>();
+                rw.put("requirement", toString(w.getRequirement()));
+                rw.put("capability", toString(w.getCapability()));
+                rw.put("requirer", toString(w.getRequirer()));
+                rw.put("provider", toString(w.getProvider()));
+                reswires.add(rw);
+            }
+            wires.put(id, reswires);
+        }
+        return wires;
+    }
+
+    private String toString(Resource r) {
+        return toString(r.getCapabilities(IDENTITY_NAMESPACE).get(0));
+    }
+
+    private String toString(Requirement r) {
+        return BaseClause.toString(null, r.getNamespace(), r.getAttributes(), r.getDirectives());
+    }
+
+    private String toString(Capability c) {
+        return BaseClause.toString(null, c.getNamespace(), c.getAttributes(), c.getDirectives());
+    }
+
     private Object toJson(Repository repository) {
         Requirement req = new RequirementImpl(
                 null,

http://git-wip-us.apache.org/repos/asf/karaf/blob/c7806957/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 08f26c5..eeb692e 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
@@ -1065,12 +1065,9 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
         try {
             final String outputFile = this.outputFile.get();
             this.outputFile.set(null);
-            executor.submit(new Callable<Object>() {
-                @Override
-                public Object call() throws Exception {
-                    doProvision(requirements, stateChanges, state, options, outputFile);
-                    return null;
-                }
+            executor.submit(() -> {
+                doProvision(requirements, stateChanges, state, options, outputFile);
+                return null;
             }).get();
         } catch (ExecutionException e) {
             Throwable t = e.getCause();


Mime
View raw message