You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2015/01/27 11:10:49 UTC

karaf git commit: KARAF-3282 Improve bundle:classes command with "local" resources

Repository: karaf
Updated Branches:
  refs/heads/karaf-3.0.x e1c80ea29 -> c9ccd53bf


KARAF-3282 Improve bundle:classes command with "local" resources


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

Branch: refs/heads/karaf-3.0.x
Commit: c9ccd53bfb32f6e14f4ccc15875d635256e5cfb5
Parents: e1c80ea
Author: Jean-Baptiste Onofré <jb...@apache.org>
Authored: Tue Jan 27 11:10:22 2015 +0100
Committer: Jean-Baptiste Onofré <jb...@apache.org>
Committed: Tue Jan 27 11:10:22 2015 +0100

----------------------------------------------------------------------
 .../apache/karaf/bundle/command/Classes.java    | 28 +++++++++++++++-----
 1 file changed, 21 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/c9ccd53b/bundle/command/src/main/java/org/apache/karaf/bundle/command/Classes.java
----------------------------------------------------------------------
diff --git a/bundle/command/src/main/java/org/apache/karaf/bundle/command/Classes.java b/bundle/command/src/main/java/org/apache/karaf/bundle/command/Classes.java
index 40bd0a4..588f919 100644
--- a/bundle/command/src/main/java/org/apache/karaf/bundle/command/Classes.java
+++ b/bundle/command/src/main/java/org/apache/karaf/bundle/command/Classes.java
@@ -24,10 +24,14 @@ import org.osgi.framework.wiring.BundleWiring;
 import java.util.Collection;
 import java.util.List;
 
-@Command(scope = "bundle", name = "classes", description = "Displays a list of classes contained in the bundle")
+import static org.fusesource.jansi.Ansi.Attribute.INTENSITY_BOLD;
+import static org.fusesource.jansi.Ansi.Attribute.RESET;
+import static org.fusesource.jansi.Ansi.ansi;
+
+@Command(scope = "bundle", name = "classes", description = "Displays a list of classes/resources contained in the bundle")
 public class Classes extends BundlesCommand {
 
-    @Option(name = "-a", aliases={"--display-all-files"}, description="List all classes and files in the bundle", required = false, multiValued = false)
+    @Option(name = "-a", aliases = {"--display-all-files"}, description = "List all classes and files in the bundle", required = false, multiValued = false)
     boolean displayAllFiles;
 
     public Classes() {
@@ -42,15 +46,25 @@ public class Classes extends BundlesCommand {
 
     protected void printResources(Bundle bundle) {
         BundleWiring wiring = bundle.adapt(BundleWiring.class);
-        if (wiring != null){
+        if (wiring != null) {
             Collection<String> resources;
-            if (displayAllFiles){
+            if (displayAllFiles) {
                 resources = wiring.listResources("/", null, BundleWiring.LISTRESOURCES_RECURSE);
-            }else{
+            } else {
                 resources = wiring.listResources("/", "*class", BundleWiring.LISTRESOURCES_RECURSE);
             }
-            for (String resource:resources){
-                System.out.println(resource);
+            Collection<String> localresources;
+            if (displayAllFiles) {
+                localresources = wiring.listResources("/", null, BundleWiring.LISTRESOURCES_RECURSE | BundleWiring.LISTRESOURCES_LOCAL);
+            } else {
+                localresources = wiring.listResources("/", "*class", BundleWiring.LISTRESOURCES_RECURSE | BundleWiring.LISTRESOURCES_LOCAL);
+            }
+            for (String resource : resources) {
+                if (localresources.contains(resource)) {
+                    System.out.println(ansi().a(INTENSITY_BOLD).a(resource).a(RESET));
+                } else {
+                    System.out.println(resource);
+                }
             }
         } else {
             System.out.println("Bundle " + bundle.getBundleId() + " is not resolved.");