Github user geomacy commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/746#discussion_r126396417
--- Diff:
core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
---
@@ -792,28 +1027,58 @@ private String setFromItemIfUnset(String oldValue,
Map<?,?> item, String fieldAt
CatalogDo subCatalog = new CatalogDo(dto);
subCatalog.addToClasspath(urls.toArray(new String[0]));
- return scanAnnotationsInternal(mgmt, subCatalog, catalogMetadata);
+ return scanAnnotationsInternal(mgmt, subCatalog, catalogMetadata,
containingBundle);
}
- private Collection<CatalogItemDtoAbstract<?, ?>>
scanAnnotationsInternal(ManagementContext mgmt, CatalogDo subCatalog, Map<?, ?>
catalogMetadata) {
- // TODO this does java-scanning only;
- // the call when scanning bundles should use the CatalogItem
instead and use OSGi when loading for scanning
- // (or another scanning mechanism). see comments on
CatalogClasspathDo.load
+ @SuppressWarnings("unused") // keep during 0.12.0 until we are
decided we won't support this; search for this method name
+ // note that it breaks after rebind since we don't have the JAR -- see
notes below
+ private Collection<CatalogItemDtoAbstract<?, ?>>
scanAnnotationsInBundle(ManagementContext mgmt, ManagedBundle containingBundle)
{
+ CatalogDto dto = CatalogDto.newNamedInstance("Bundle
"+containingBundle.getVersionedName().toOsgiString()+" Scanned Catalog", "All
annotated Brooklyn entities detected in bundles",
"scanning-bundle-"+containingBundle.getVersionedName().toOsgiString());
+ CatalogDo subCatalog = new CatalogDo(dto);
+ // need access to a JAR to scan this
+ String url = null;
+ if (containingBundle instanceof BasicManagedBundle) {
+ File f =
((BasicManagedBundle)containingBundle).getTempLocalFileWhenJustUploaded();
+ if (f!=null) {
+ url = "file:"+f.getAbsolutePath();
+ }
+ }
+ // type.getSubPathName(), type, id+".jar",
com.google.common.io.Files.asByteSource(f), exceptionHandler);
+ if (url==null) {
+ url = containingBundle.getUrl();
+ }
+ if (url==null) {
+ // NOT available after persistence/rebind
+ // as shown by test in CatalogOsgiVersionMoreEntityRebindTest
+ throw new IllegalArgumentException("Error prepaing to scan
"+containingBundle.getVersionedName()+": no URL available");
--- End diff --
typo `prepaing`
---
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.
---