karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject [karaf] 02/02: [KARAF-5548] Improve the find-class command to support package names
Date Mon, 18 Dec 2017 09:36:15 GMT
This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf.git

commit 373ee033a5dceee604cca5f4b3ff7a7c6a5c52f7
Author: Guillaume Nodet <gnodet@gmail.com>
AuthorDate: Mon Dec 18 09:17:48 2017 +0100

    [KARAF-5548] Improve the find-class command to support package names
---
 .../java/org/apache/karaf/bundle/command/FindClass.java  | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/bundle/core/src/main/java/org/apache/karaf/bundle/command/FindClass.java b/bundle/core/src/main/java/org/apache/karaf/bundle/command/FindClass.java
index 4a9fc75..bcb8c14 100644
--- a/bundle/core/src/main/java/org/apache/karaf/bundle/command/FindClass.java
+++ b/bundle/core/src/main/java/org/apache/karaf/bundle/command/FindClass.java
@@ -47,11 +47,23 @@ public class FindClass implements Action {
 
     protected void findResource() {
         Bundle[] bundles = bundleContext.getBundles();
-        String filter = "*" + className + "*";
+        String path;
+        String filter;
+        int idx = className.lastIndexOf('.');
+        if (idx >= 0) {
+            path = className.substring(0, idx).replace('.', '/');
+            if (path.isEmpty() || path.charAt(0) != '/') {
+                path = "/" + path;
+            }
+            filter = className.substring(idx + 1) + ".class";
+        } else {
+            path = "/";
+            filter = "*" + className + "*";
+        }
         for (Bundle bundle:bundles){
             BundleWiring wiring = bundle.adapt(BundleWiring.class);
             if (wiring != null){
-                Collection<String> resources = wiring.listResources("/", filter, BundleWiring.LISTRESOURCES_RECURSE);
+                Collection<String> resources = wiring.listResources(path, filter, BundleWiring.LISTRESOURCES_RECURSE);
                 if (resources.size() > 0){
                     String title = ShellUtil.getBundleName(bundle);
                     System.out.println("\n" + title);

-- 
To stop receiving notification emails like this one, please contact
"commits@karaf.apache.org" <commits@karaf.apache.org>.

Mime
View raw message