karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject karaf git commit: [KARAF-3627]Add bundle revision information to bundle:list command (cherry picked from commit bdd666603615d4049ea618e4f55ad125d93863a3)
Date Mon, 20 Apr 2015 09:36:45 GMT
Repository: karaf
Updated Branches:
  refs/heads/master 056239dca -> 2601b3307


[KARAF-3627]Add bundle revision information to bundle:list command
(cherry picked from commit bdd666603615d4049ea618e4f55ad125d93863a3)


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

Branch: refs/heads/master
Commit: 2601b3307d6c0bb344a85d0693ef48f98758c67a
Parents: 056239d
Author: Freeman Fang <freeman.fang@gmail.com>
Authored: Mon Apr 20 16:45:23 2015 +0800
Committer: Freeman Fang <freeman.fang@gmail.com>
Committed: Mon Apr 20 17:27:46 2015 +0800

----------------------------------------------------------------------
 .../org/apache/karaf/bundle/command/List.java    |  7 +++++++
 .../org/apache/karaf/bundle/core/BundleInfo.java |  1 +
 .../bundle/core/internal/BundleInfoImpl.java     | 19 +++++++++++++++++++
 3 files changed, 27 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/2601b330/bundle/core/src/main/java/org/apache/karaf/bundle/command/List.java
----------------------------------------------------------------------
diff --git a/bundle/core/src/main/java/org/apache/karaf/bundle/command/List.java b/bundle/core/src/main/java/org/apache/karaf/bundle/command/List.java
index 82119c0..4cf6562 100644
--- a/bundle/core/src/main/java/org/apache/karaf/bundle/command/List.java
+++ b/bundle/core/src/main/java/org/apache/karaf/bundle/command/List.java
@@ -43,6 +43,9 @@ public class List extends BundlesCommand {
 
     @Option(name = "-u", description = "Shows the update locations", required = false, multiValued
= false)
     boolean showUpdate;
+    
+    @Option(name = "-r", description = "Shows the bundle revisions", required = false, multiValued
= false)
+    boolean showRevisions;
 
     @Option(name = "-t", valueToShowInHelp = "", description = "Specifies the bundle threshold;
bundles with a start-level less than this value will not get printed out.", required = false,
multiValued = false)
     int bundleLevelThreshold = -1;
@@ -131,6 +134,8 @@ public class List extends BundlesCommand {
             msg = "Symbolic name";
         } else if (showUpdate) {
             msg = "Update location";
+        } else if (showRevisions) {
+            msg = "Revisions";
         }
         return msg;
     }
@@ -187,6 +192,8 @@ public class List extends BundlesCommand {
             return info.getSymbolicName() == null ? "<no symbolic name>" : info.getSymbolicName();
         } else if (showUpdate) {
             return info.getUpdateLocation();
+        } else if (showRevisions) {
+            return info.getRevisions();
         } else {
             String name = (info.getName() == null) ? info.getSymbolicName() : info.getName();
             return (name == null) ? info.getUpdateLocation() : name;

http://git-wip-us.apache.org/repos/asf/karaf/blob/2601b330/bundle/core/src/main/java/org/apache/karaf/bundle/core/BundleInfo.java
----------------------------------------------------------------------
diff --git a/bundle/core/src/main/java/org/apache/karaf/bundle/core/BundleInfo.java b/bundle/core/src/main/java/org/apache/karaf/bundle/core/BundleInfo.java
index cfeecd5..962e802 100644
--- a/bundle/core/src/main/java/org/apache/karaf/bundle/core/BundleInfo.java
+++ b/bundle/core/src/main/java/org/apache/karaf/bundle/core/BundleInfo.java
@@ -26,6 +26,7 @@ public interface BundleInfo {
     String getName();
     String getUpdateLocation();
     String getVersion();
+    String getRevisions();
     
     /**
      * Combined bundle state from OSGi and all BundleStateServices

http://git-wip-us.apache.org/repos/asf/karaf/blob/2601b330/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundleInfoImpl.java
----------------------------------------------------------------------
diff --git a/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundleInfoImpl.java
b/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundleInfoImpl.java
index bc6b21f..7fd811c 100644
--- a/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundleInfoImpl.java
+++ b/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundleInfoImpl.java
@@ -37,6 +37,7 @@ public class BundleInfoImpl implements BundleInfo {
     private String symbolicName;
     private String updateLocation;
     private String version;
+    private String revisions;
     private long bundleId;
     private BundleState state;
     private boolean isFragment;
@@ -62,6 +63,7 @@ public class BundleInfoImpl implements BundleInfo {
         String locationFromHeader = (String)bundle.getHeaders().get(Constants.BUNDLE_UPDATELOCATION);
         this.updateLocation = locationFromHeader != null ? locationFromHeader : bundle.getLocation();
         this.version = (String)bundle.getHeaders().get(Constants.BUNDLE_VERSION);
+        this.revisions = populateRevisions(bundle);
         this.bundleId = bundle.getBundleId();
         this.state = (extState != BundleState.Unknown) ? extState : getBundleState(bundle);
         populateFragementInfos(bundle);
@@ -82,6 +84,18 @@ public class BundleInfoImpl implements BundleInfo {
             }
         }
     }
+    
+    private String populateRevisions(Bundle bundle) {
+        String ret = "";
+        BundleRevisions revisions = bundle.adapt(BundleRevisions.class);
+        if (revisions == null) {
+            return ret;
+        }
+        for (BundleRevision revision : revisions.getRevisions()) {
+            ret = ret + "[" + revision + "]" + " ";
+        }
+        return ret;
+    }
 
     private void getFragments(BundleRevision revision) {
         List<BundleWire> wires = revision.getWiring().getProvidedWires(BundleRevision.HOST_NAMESPACE);
@@ -160,4 +174,9 @@ public class BundleInfoImpl implements BundleInfo {
         return this.fragmentHosts;
     }
 
+    @Override
+    public String getRevisions() {
+        return this.revisions;
+    }
+
 }


Mime
View raw message