You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2019/08/07 10:23:43 UTC

[sling-org-apache-sling-feature-analyser] branch master updated: SLING-8618 : Add method to scan a bundle

This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-analyser.git


The following commit(s) were added to refs/heads/master by this push:
     new 3075497  SLING-8618 : Add method to scan a bundle
3075497 is described below

commit 3075497940681682c01108a8feaaae30c4b372ec
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Aug 7 13:23:34 2019 +0300

    SLING-8618 : Add method to scan a bundle
---
 .../org/apache/sling/feature/scanner/Scanner.java  | 31 +++++++++++++++++-----
 .../apache/sling/feature/scanner/package-info.java |  2 +-
 2 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/src/main/java/org/apache/sling/feature/scanner/Scanner.java b/src/main/java/org/apache/sling/feature/scanner/Scanner.java
index 0a7e142..4f21a7c 100644
--- a/src/main/java/org/apache/sling/feature/scanner/Scanner.java
+++ b/src/main/java/org/apache/sling/feature/scanner/Scanner.java
@@ -109,11 +109,30 @@ public class Scanner {
      * Scan a bundle
      *
      * @param bundle The bundle artifact
+     * @return The bundle descriptor
+     * @throws IOException If something goes wrong or the provided artifact is not a
+     *                     bundle.
+     */
+    public BundleDescriptor scanBundle(final Artifact bundle) throws IOException {
+        return this.doScan(bundle, bundle.getStartOrder());
+    }
+
+    /**
+     * Scan a bundle
+     *
+     * @param bundle     The bundle artifact
      * @param startLevel The start level of the bundle
      * @return The bundle descriptor
-     * @throws IOException If something goes wrong or the provided artifact is not a bundle.
+     * @throws IOException If something goes wrong or the provided artifact is not a
+     *                     bundle.
+     * @deprecated Use {@link #scanBundle(Artifact)}
      */
+    @Deprecated
     public BundleDescriptor scan(final Artifact bundle, final int startLevel) throws IOException {
+        return this.doScan(bundle, startLevel);
+    }
+
+    private BundleDescriptor doScan(final Artifact bundle, final int startLevel) throws IOException {
         final String key = bundle.getId().toMvnId().concat(":").concat(String.valueOf(startLevel));
         BundleDescriptor desc = (BundleDescriptor) this.cache.get(key);
         if (desc == null) {
@@ -137,11 +156,9 @@ public class Scanner {
      */
     private void getBundleInfos(final Bundles bundles, final ContainerDescriptor desc)
     throws IOException {
-        for(final Map.Entry<Integer, List<Artifact>> entry : bundles.getBundlesByStartOrder().entrySet()) {
-            for(final Artifact bundle : entry.getValue() ) {
-                final BundleDescriptor bundleDesc = scan(bundle, entry.getKey());
-                desc.getBundleDescriptors().add(bundleDesc);
-            }
+        for (final Artifact bundle : bundles) {
+            final BundleDescriptor bundleDesc = scanBundle(bundle);
+            desc.getBundleDescriptors().add(bundleDesc);
         }
     }
 
@@ -178,7 +195,7 @@ public class Scanner {
 
     /**
      * Compact the container description
-     * 
+     *
      * @param desc The contaier description
      */
     private void compact(final ContainerDescriptor desc) {
diff --git a/src/main/java/org/apache/sling/feature/scanner/package-info.java b/src/main/java/org/apache/sling/feature/scanner/package-info.java
index d3a2684..7db7615 100644
--- a/src/main/java/org/apache/sling/feature/scanner/package-info.java
+++ b/src/main/java/org/apache/sling/feature/scanner/package-info.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-@org.osgi.annotation.versioning.Version("2.0.0")
+@org.osgi.annotation.versioning.Version("2.1.0")
 package org.apache.sling.feature.scanner;