Github user geomacy commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/100#discussion_r59170691
--- Diff:
core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogBomScanner.java
---
@@ -100,54 +103,75 @@ public ManagementContext getManagementContext() {
return managementContext;
}
+ /**
+ * Scans the bundle being added for a catalog.bom file and adds
any entries in it to the catalog.
+ *
+ * @param bundle The bundle being added to the bundle context.
+ * @param bundleEvent The event of the addition.
+ *
+ * @return The items added to the catalog; these will be tracked
by the {@link BundleTracker} mechanism
+ * and supplied to the {@link #removedBundle(Bundle,
BundleEvent, Iterable)} method.
+ */
@Override
- public Long addingBundle(Bundle bundle, BundleEvent bundleEvent) {
-
- final BundleContext bundleContext =
FrameworkUtil.getBundle(CatalogBomScanner.class).getBundleContext();
- if (bundleContext == null) {
- LOG.info("Bundle context not yet established for bundle {}
{} {}", bundleIds(bundle));
- return null;
- }
-
- scanForCatalog(bundle);
-
- return bundle.getBundleId();
+ public Iterable<? extends CatalogItem<?, ?>> addingBundle(Bundle
bundle, BundleEvent bundleEvent) {
+ return scanForCatalog(bundle);
}
- @Override
- public void modifiedBundle(Bundle bundle, BundleEvent event, Long
bundleId) {
- sanityCheck(bundle, bundleId);
- LOG.info("Modified bundle {} {} {}", bundleIds(bundle));
- }
@Override
- public void removedBundle(Bundle bundle, BundleEvent bundleEvent,
Long bundleId) {
- sanityCheck(bundle, bundleId);
- LOG.info("Unloading catalog BOM from {} {} {}",
bundleIds(bundle));
+ public void removedBundle(Bundle bundle, BundleEvent bundleEvent,
Iterable<? extends CatalogItem<?, ?>> items) {
+ if (!items.iterator().hasNext()) {
+ return;
+ }
+ LOG.debug("Unloading catalog BOM entries from {} {} {}",
bundleIds(bundle));
+ final BrooklynCatalog catalog =
getManagementContext().getCatalog();
+ for (CatalogItem<?, ?> item : items) {
+ LOG.debug("Unloading {} {} from catalog",
item.getSymbolicName(), item.getVersion());
+
+ try {
+ catalog.deleteCatalogItem(item.getSymbolicName(),
item.getVersion());
+ } catch (Exception e) {
+ // Gobble exception to avoid possibility of causing
problems stopping bundle.
--- End diff --
done in 1844634
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---