You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2019/01/16 16:40:30 UTC

[brooklyn-server] 18/31: Extract scanManagedBundles() and scanAllBundles()

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

aledsage pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git

commit ef42313efc3b4d88beb540bacef82f9f7e3fc71e
Author: Paul Campbell <pc...@kemitix.net>
AuthorDate: Tue Oct 23 17:16:39 2018 +0100

    Extract scanManagedBundles() and scanAllBundles()
---
 .../core/catalog/internal/CatalogInitialization.java  | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java
index b355b97..da7f1f6 100644
--- a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java
+++ b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java
@@ -614,11 +614,16 @@ public class CatalogInitialization implements ManagementContextInjectable {
             // Can't find any bundles to tell if there are upgrades. Could be running tests; do no filtering.
             return CatalogUpgrades.EMPTY;
         }
-        
-        CatalogUpgrades.Builder catalogUpgradesBuilder = CatalogUpgrades.builder();
-        Collection<ManagedBundle> managedBundles = osgiManager.get().getManagedBundles().values();
+        final CatalogUpgrades.Builder catalogUpgradesBuilder = CatalogUpgrades.builder();
+        scanManagedBundles(osgiManager.get(), catalogUpgradesBuilder, rebindLogger);
+        scanAllBundles(osgiManager.get(), catalogUpgradesBuilder);
+        return catalogUpgradesBuilder.build();
+    }
+
+    private void scanManagedBundles(OsgiManager osgiManager, CatalogUpgrades.Builder catalogUpgradesBuilder, RebindLogger rebindLogger) {
+        Collection<ManagedBundle> managedBundles = osgiManager.getManagedBundles().values();
         for (ManagedBundle managedBundle : managedBundles) {
-            Maybe<Bundle> bundle = osgiManager.get().findBundle(managedBundle);
+            Maybe<Bundle> bundle = osgiManager.findBundle(managedBundle);
             if (bundle.isPresent()) {
                 CatalogUpgrades catalogUpgrades = BundleUpgradeParser.parseBundleManifestForCatalogUpgrades(
                         bundle.get(),
@@ -629,8 +634,10 @@ public class CatalogInitialization implements ManagementContextInjectable {
                         + "ignoring when calculating persisted state catalog upgrades");
             }
         }
+    }
 
-        for (Bundle bundle : osgiManager.get().getFramework().getBundleContext().getBundles()) {
+    private void scanAllBundles(OsgiManager osgiManager, CatalogUpgrades.Builder catalogUpgradesBuilder) {
+        for (Bundle bundle : osgiManager.getFramework().getBundleContext().getBundles()) {
             final RegisteredTypesSupplier typeSupplier =
                     new RegisteredTypesSupplier(managementContext,
                             RegisteredTypePredicates.containingBundle(bundle.getSymbolicName()));
@@ -638,8 +645,6 @@ public class CatalogInitialization implements ManagementContextInjectable {
                     BundleUpgradeParser.parseBundleManifestForCatalogUpgrades(bundle, typeSupplier);
             catalogUpgradesBuilder.addAll(catalogUpgrades);
         }
-
-        return catalogUpgradesBuilder.build();
     }
 
     private static class RegisteredTypesSupplier implements Supplier<Iterable<RegisteredType>> {