You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2017/10/28 10:03:36 UTC

[2/4] brooklyn-server git commit: change RTypeSupplier to take filter

change RTypeSupplier to take filter

makes it more general. also stores mgmt not TR as mgmt has smarts around persistence whereas TR doesnt
(just in case this is ever persisted, it shouldn't be but passing mgmt is the standard way;
alternative would be to pass TR in constructor and make it a TR filtered view;
passing mgmt then converting to TR seems weird middle ground)


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

Branch: refs/heads/master
Commit: d5b4b576fd546c8b7573678fc7a9775d8bfb5b3d
Parents: b05b819
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Fri Oct 27 11:14:03 2017 +0100
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Fri Oct 27 11:57:28 2017 +0100

----------------------------------------------------------------------
 .../catalog/internal/CatalogInitialization.java     | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d5b4b576/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java
----------------------------------------------------------------------
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 225e3fd..f2a1f47 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
@@ -39,7 +39,6 @@ import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.api.mgmt.ha.ManagementNodeState;
 import org.apache.brooklyn.api.mgmt.rebind.RebindExceptionHandler;
 import org.apache.brooklyn.api.objs.BrooklynObjectType;
-import org.apache.brooklyn.api.typereg.BrooklynTypeRegistry;
 import org.apache.brooklyn.api.typereg.BrooklynTypeRegistry.RegisteredTypeKind;
 import org.apache.brooklyn.api.typereg.ManagedBundle;
 import org.apache.brooklyn.api.typereg.RegisteredType;
@@ -75,6 +74,7 @@ import org.slf4j.LoggerFactory;
 
 import com.google.common.annotations.Beta;
 import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Predicate;
 import com.google.common.base.Stopwatch;
 import com.google.common.base.Supplier;
 import com.google.common.collect.ImmutableList;
@@ -580,7 +580,7 @@ public class CatalogInitialization implements ManagementContextInjectable {
             if (bundle.isPresent()) {
                 CatalogUpgrades catalogUpgrades = BundleUpgradeParser.parseBundleManifestForCatalogUpgrades(
                         bundle.get(),
-                        new RegisteredTypesSupplier(managementContext, managedBundle));
+                        new RegisteredTypesSupplier(managementContext, RegisteredTypePredicates.containingBundle(managedBundle)));
                 catalogUpgradesBuilder.addAll(catalogUpgrades);
             } else {
                 rebindLogger.info("Managed bundle "+managedBundle.getId()+" not found by OSGi Manager; "
@@ -591,16 +591,16 @@ public class CatalogInitialization implements ManagementContextInjectable {
     }
 
     private static class RegisteredTypesSupplier implements Supplier<Iterable<RegisteredType>> {
-        private final BrooklynTypeRegistry typeRegistry;
-        private final ManagedBundle bundle;
+        private final ManagementContext mgmt;
+        private final Predicate<? super RegisteredType> filter;
         
-        RegisteredTypesSupplier(ManagementContext mgmt, ManagedBundle bundle) {
-            this.typeRegistry = mgmt.getTypeRegistry();
-            this.bundle = bundle;
+        RegisteredTypesSupplier(ManagementContext mgmt, Predicate<? super RegisteredType> predicate) {
+            this.mgmt = mgmt;
+            this.filter = predicate;
         }
         @Override
         public Iterable<RegisteredType> get() {
-            return typeRegistry.getMatching(RegisteredTypePredicates.containingBundle(bundle));
+            return mgmt.getTypeRegistry().getMatching(filter);
         }
     }