brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [01/23] incubator-brooklyn git commit: yaml catalog supports scanning, experimental, and default
Date Fri, 22 May 2015 09:04:46 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 776ad43d3 -> 321d88790


yaml catalog supports scanning, experimental, and default

this restores catalog scanning as the default, based on brooklyn/default.catalog.bom in the
cli project;
there are some limitations on what can be scanned, described in the doc.
some of the tests configure other catalogs (with core's brooklyn/empty.catalog.bom used in
many)


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

Branch: refs/heads/master
Commit: 1b080fb524c1a60ba6d5a8fe917b864e7e8e4cb7
Parents: 0b9bc3b
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Wed Apr 29 13:27:09 2015 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Fri May 8 18:22:21 2015 +0100

----------------------------------------------------------------------
 .../java/brooklyn/catalog/BrooklynCatalog.java  |  3 +-
 .../catalog/internal/BasicBrooklynCatalog.java  | 58 +++++++++++++++++---
 .../brooklyn/catalog/internal/CatalogDo.java    | 26 +++++++--
 .../catalog/internal/CatalogInitialization.java | 47 +++++++++-------
 .../main/resources/brooklyn/empty.catalog.bom   |  2 +-
 .../catalog/internal/CatalogScanTest.java       |  6 +-
 .../test/resources/brooklyn/default.catalog.bom | 19 +++++++
 docs/guide/ops/catalog/index.md                 |  5 ++
 .../main/resources/brooklyn/default.catalog.bom | 19 +++++++
 .../brooklyn/rest/BrooklynRestApiLauncher.java  |  7 ++-
 .../BrooklynRestApiLauncherTestFixture.java     |  4 +-
 .../util/BrooklynRestResourceUtilsTest.java     |  5 +-
 .../resources/brooklyn/scanning.catalog.bom     | 19 +++++++
 13 files changed, 180 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1b080fb5/api/src/main/java/brooklyn/catalog/BrooklynCatalog.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/brooklyn/catalog/BrooklynCatalog.java b/api/src/main/java/brooklyn/catalog/BrooklynCatalog.java
index 5b11cc6..7c36c0e 100644
--- a/api/src/main/java/brooklyn/catalog/BrooklynCatalog.java
+++ b/api/src/main/java/brooklyn/catalog/BrooklynCatalog.java
@@ -129,8 +129,9 @@ public interface BrooklynCatalog {
      * adds an item to the 'manual' catalog;
      * this does not update the classpath or have a record to the java Class
      *
-     * @deprecated since 0.7.0 Construct catalogs with OSGi bundles instead
+     * @deprecated since 0.7.0 Construct catalogs with yaml (referencing OSGi bundles) instead
      */
+    // TODO maybe this should stay on the API? -AH Apr 2015 
     @Deprecated
     void addItem(CatalogItem<?,?> item);
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1b080fb5/core/src/main/java/brooklyn/catalog/internal/BasicBrooklynCatalog.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/catalog/internal/BasicBrooklynCatalog.java b/core/src/main/java/brooklyn/catalog/internal/BasicBrooklynCatalog.java
index 9d68465..f1d5a3c 100644
--- a/core/src/main/java/brooklyn/catalog/internal/BasicBrooklynCatalog.java
+++ b/core/src/main/java/brooklyn/catalog/internal/BasicBrooklynCatalog.java
@@ -45,6 +45,7 @@ import brooklyn.catalog.CatalogItem;
 import brooklyn.catalog.CatalogItem.CatalogBundle;
 import brooklyn.catalog.CatalogItem.CatalogItemType;
 import brooklyn.catalog.CatalogPredicates;
+import brooklyn.catalog.internal.CatalogClasspathDo.CatalogScanningModes;
 import brooklyn.config.BrooklynServerConfig;
 import brooklyn.location.Location;
 import brooklyn.location.LocationSpec;
@@ -74,11 +75,14 @@ import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
+import com.google.common.collect.Collections2;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSortedSet;
 import com.google.common.collect.Iterables;
 
+/* TODO the complex tree-structured catalogs are only useful when we are relying on those
separate catalog classloaders
+ * to isolate classpaths. with osgi everything is just put into the "manual additions" catalog.
*/
 public class BasicBrooklynCatalog implements BrooklynCatalog {
     private static final String POLICIES_KEY = "brooklyn.policies";
     private static final String LOCATIONS_KEY = "brooklyn.locations";
@@ -185,12 +189,7 @@ public class BasicBrooklynCatalog implements BrooklynCatalog {
             return null;
         }
 
-        String versionedId = CatalogUtils.getVersionedId(symbolicName, fixedVersionId);
-        CatalogItemDo<?, ?> item = null;
-        //TODO should remove "manual additions" bucket; just have one map a la osgi
-        if (manualAdditionsCatalog!=null) item = manualAdditionsCatalog.getIdCache().get(versionedId);
-        if (item == null) item = catalog.getIdCache().get(versionedId);
-        return item;
+        return catalog.getIdCache().get( CatalogUtils.getVersionedId(symbolicName, fixedVersionId)
);
     }
     
     private String getFixedVersionId(String symbolicName, String version) {
@@ -596,7 +595,22 @@ public class BasicBrooklynCatalog implements BrooklynCatalog {
         Collection<CatalogBundle> libraryBundles = CatalogItemDtoAbstract.parseLibraries(librariesCombined);
 
         // TODO as this may take a while if downloading, the REST call should be async
+        // (this load is required for the scan below and I think also for yaml resolution)
         CatalogUtils.installLibraries(mgmt, libraryBundlesNew);
+
+        Boolean scanJavaAnnotations = getFirstAs(itemMetadata, Boolean.class, "scanJavaAnnotations",
"scan_java_annotations").orNull();
+        if (scanJavaAnnotations==null || !scanJavaAnnotations) {
+            // don't scan
+        } else {
+            // scan for annotations: if libraries here, scan them; if inherited libraries
error; else scan classpath
+            if (!libraryBundlesNew.isEmpty()) {
+                result.addAll(scanAnnotations(mgmt, libraryBundlesNew));
+            } else if (libraryBundles.isEmpty()) {
+                result.addAll(scanAnnotations(mgmt, null));
+            } else {
+                throw new IllegalStateException("Cannot scan catalog node no local bundles,
and with inherited bundles we will not scan the classpath");
+            }
+        }
         
         Object items = catalogMetadata.remove("items");
         Object item = catalogMetadata.remove("item");
@@ -749,7 +763,36 @@ public class BasicBrooklynCatalog implements BrooklynCatalog {
         return oldValue;
     }
 
-    
+    /** scans the given libraries for annotated items, or if null scans the local classpath
*/ 
+    private Collection<CatalogItemDtoAbstract<?, ?>> scanAnnotations(ManagementContext
mgmt, Collection<CatalogBundle> libraries) {
+//        CatalogDto dto = CatalogDto.newDefaultLocalScanningDto(CatalogClasspathDo.CatalogScanningModes.ANNOTATIONS);
+        CatalogDto dto;
+        String[] urls = null;
+        if (libraries==null) {
+            dto = CatalogDto.newNamedInstance("Local Scanned Catalog", "All annotated Brooklyn
entities detected in the classpath", "scanning-local-classpath");
+        } else {
+            dto = CatalogDto.newNamedInstance("Bundles Scanned Catalog", "All annotated Brooklyn
entities detected in the classpath", "scanning-bundles-classpath-"+libraries.hashCode());
+            urls = new String[libraries.size()];
+            int i=0;
+            for (CatalogBundle b: libraries)
+                urls[i++] = b.getUrl();
+        }
+        CatalogDo subCatalog = new CatalogDo(dto);
+        subCatalog.mgmt = mgmt;
+        if (urls!=null) {
+            subCatalog.addToClasspath(urls);
+        } // else use local classpath
+        subCatalog.setClasspathScanForEntities(CatalogScanningModes.ANNOTATIONS);
+        subCatalog.load();
+        // TODO apply metadata?  (extract YAML from the items returned)
+        // also see doc .../catalog/index.md which says we might not apply metadata
+        @SuppressWarnings({ "unchecked", "rawtypes" })
+        Collection<CatalogItemDtoAbstract<?, ?>> result = (Collection<CatalogItemDtoAbstract<?,
?>>)(Collection)Collections2.transform(
+                (Collection<CatalogItemDo<Object,Object>>)(Collection)subCatalog.getIdCache().values(),

+                itemDoToDto());
+        return result;
+    }
+
     private class PlanInterpreterGuessingType {
 
         final String id;
@@ -1084,6 +1127,7 @@ public class BasicBrooklynCatalog implements BrooklynCatalog {
         return new Function<CatalogItemDo<T,SpecT>, CatalogItem<T,SpecT>>()
{
             @Override
             public CatalogItem<T,SpecT> apply(@Nullable CatalogItemDo<T,SpecT>
item) {
+                if (item==null) return null;
                 return item.getDto();
             }
         };

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1b080fb5/core/src/main/java/brooklyn/catalog/internal/CatalogDo.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/catalog/internal/CatalogDo.java b/core/src/main/java/brooklyn/catalog/internal/CatalogDo.java
index 0efe85c..2142ce9 100644
--- a/core/src/main/java/brooklyn/catalog/internal/CatalogDo.java
+++ b/core/src/main/java/brooklyn/catalog/internal/CatalogDo.java
@@ -208,19 +208,28 @@ public class CatalogDo {
                 child.clearCache(true);
             }
         }
+        clearParentCache();
+    }
+    protected void clearParentCache() {
+        if (this.parent!=null)
+            this.parent.clearCache(false);
     }
     
     /**
      * Adds the given entry to the catalog, with no enrichment.
      * Callers may prefer {@link CatalogClasspathDo#addCatalogEntry(CatalogItemDtoAbstract,
Class)}
      */
-    @SuppressWarnings({ "unchecked", "rawtypes" })
     public synchronized void addEntry(CatalogItemDtoAbstract<?,?> entry) {
         dto.addEntry(entry);
+        
+        // could do clearCache(false); but this is slightly more efficient...
         if (cacheById != null) {
+            @SuppressWarnings({ "unchecked", "rawtypes" })
             CatalogItemDo<?, ?> cdo = new CatalogItemDo(this, entry);
             cacheById.put(entry.getId(), cdo);
-        }
+        }        
+        clearParentCache();
+        
         if (mgmt != null) {
             mgmt.getRebindManager().getChangeListener().onManaged(entry);
         }
@@ -231,12 +240,19 @@ public class CatalogDo {
      */
     public synchronized void deleteEntry(CatalogItemDtoAbstract<?, ?> entry) {
         dto.removeEntry(entry);
+        
+        // could do clearCache(false); but this is slightly more efficient...
         if (cacheById != null) {
             cacheById.remove(entry.getId());
         }
+        clearParentCache();
+        
         if (mgmt != null) {
             // TODO: Can the entry be in more than one catalogue? The management context
has no notion of
             // catalogue hierarchy so this will effectively remove it from all catalogues.
+            // (YES- we're assuming ID's are unique across all catalogues; if not, things
get out of sync;
+            // however see note at top of BasicBrooklynCatalog --
+            // manualCatalog and OSGi is used for everything now except legacy XML trees)
             mgmt.getRebindManager().getChangeListener().onUnmanaged(entry);
         }
     }
@@ -254,8 +270,10 @@ public class CatalogDo {
     public synchronized void addToClasspath(String ...urls) {
         if (dto.classpath == null)
             dto.classpath = new CatalogClasspathDto();
-        for (String url: urls)
-            dto.classpath.addEntry(url);
+        for (String url: urls) {
+            if (url!=null)
+                dto.classpath.addEntry(url);
+        }
         if (isLoaded())
             throw new IllegalStateException("dynamic classpath entry value update not supported");
         // easy enough to add, just support unload+reload (and can also allow dynamic setScan
below)

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1b080fb5/core/src/main/java/brooklyn/catalog/internal/CatalogInitialization.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/catalog/internal/CatalogInitialization.java b/core/src/main/java/brooklyn/catalog/internal/CatalogInitialization.java
index db7343a..15d5d76 100644
--- a/core/src/main/java/brooklyn/catalog/internal/CatalogInitialization.java
+++ b/core/src/main/java/brooklyn/catalog/internal/CatalogInitialization.java
@@ -38,7 +38,6 @@ import brooklyn.util.flags.TypeCoercions;
 import brooklyn.util.guava.Maybe;
 import brooklyn.util.net.Urls;
 import brooklyn.util.text.Strings;
-import brooklyn.util.yaml.Yamls;
 
 import com.google.common.annotations.Beta;
 import com.google.common.base.Function;
@@ -189,15 +188,18 @@ public class CatalogInitialization {
             return;
         }
 
-        // TODO scan for default.catalog.bom files and add all of them
+        // otherwise look for for classpath:/brooklyn/default.catalog.bom --
+        // there is one on the classpath which says to scan, and provides a few templates;
+        // if one is supplied by user in the conf/ dir that will override the item from the
classpath
+        // (TBD - we might want to scan for all such bom's?)
         
-//        // TODO optionally scan for classpath items
-//        // retry, either an error, or was blank
-//        dto = CatalogDto.newDefaultLocalScanningDto(CatalogClasspathDo.CatalogScanningModes.ANNOTATIONS);
-//        if (log.isDebugEnabled()) {
-//            log.debug("Loaded default (local classpath) catalog: " + catalogDo);
-//        }
+        catalogUrl = "classpath:/brooklyn/default.catalog.bom";
+        if (new ResourceUtils(this).doesUrlExist(catalogUrl)) {
+            populateInitialFromUri(catalog, managementContext, catalogUrl, PopulateMode.YAML);
+            return;
+        }
         
+        log.info("No catalog found on classpath or specified; catalog will not be initialized.");
         return;
     }
     
@@ -228,17 +230,7 @@ public class CatalogInitialization {
         
         if (result==null && contents!=null && (mode==PopulateMode.XML ||
mode==PopulateMode.AUTODETECT)) {
             // then try XML
-            CatalogDto dto = null;
-            try {
-                dto = CatalogDto.newDtoFromXmlContents(contents, catalogUrl);
-                problem = null;
-            } catch (Exception e) {
-                Exceptions.propagateIfFatal(e);
-                if (problem==null) problem = e;
-            }
-            if (dto!=null) {
-                catalog.reset(dto);
-            }
+            problem = populateInitialFromUriXml(catalog, catalogUrl, problem, contents);
         }
         
         if (result!=null) {
@@ -251,6 +243,23 @@ public class CatalogInitialization {
 
     }
 
+    // deprecated XML format
+    @SuppressWarnings("deprecation")
+    private Exception populateInitialFromUriXml(BasicBrooklynCatalog catalog, String catalogUrl,
Exception problem, String contents) {
+        CatalogDto dto = null;
+        try {
+            dto = CatalogDto.newDtoFromXmlContents(contents, catalogUrl);
+            problem = null;
+        } catch (Exception e) {
+            Exceptions.propagateIfFatal(e);
+            if (problem==null) problem = e;
+        }
+        if (dto!=null) {
+            catalog.reset(dto);
+        }
+        return problem;
+    }
+
     protected void populateAdditions(BasicBrooklynCatalog catalog, ManagementContext mgmt)
{
         if (Strings.isNonBlank(additionsUri)) {
             if (disallowLocal) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1b080fb5/core/src/main/resources/brooklyn/empty.catalog.bom
----------------------------------------------------------------------
diff --git a/core/src/main/resources/brooklyn/empty.catalog.bom b/core/src/main/resources/brooklyn/empty.catalog.bom
index 401d2fa..58cfb1b 100644
--- a/core/src/main/resources/brooklyn/empty.catalog.bom
+++ b/core/src/main/resources/brooklyn/empty.catalog.bom
@@ -15,4 +15,4 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-brooklyn.catalog: {}
+brooklyn.catalog: {}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1b080fb5/core/src/test/java/brooklyn/catalog/internal/CatalogScanTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/catalog/internal/CatalogScanTest.java b/core/src/test/java/brooklyn/catalog/internal/CatalogScanTest.java
index 949877f..07c40af 100644
--- a/core/src/test/java/brooklyn/catalog/internal/CatalogScanTest.java
+++ b/core/src/test/java/brooklyn/catalog/internal/CatalogScanTest.java
@@ -162,13 +162,13 @@ public class CatalogScanTest {
     
     @Test
     public void testAnnotationIsDefault() {
-        loadAnnotationsOnlyCatalog();
         loadTheDefaultCatalog();
+        int numInDefault = Iterables.size(defaultCatalog.getCatalogItems(Predicates.alwaysTrue()));
         
+        loadAnnotationsOnlyCatalog();
         int numFromAnnots = Iterables.size(annotsCatalog.getCatalogItems(Predicates.alwaysTrue()));
-        int numInDefault = Iterables.size(defaultCatalog.getCatalogItems(Predicates.alwaysTrue()));
         
-        Assert.assertEquals(numFromAnnots, numInDefault);
+        Assert.assertEquals(numInDefault, numFromAnnots);
     }
 
     // a simple test asserting no errors when listing the real catalog, and listing them
for reference

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1b080fb5/core/src/test/resources/brooklyn/default.catalog.bom
----------------------------------------------------------------------
diff --git a/core/src/test/resources/brooklyn/default.catalog.bom b/core/src/test/resources/brooklyn/default.catalog.bom
new file mode 100644
index 0000000..cddb832
--- /dev/null
+++ b/core/src/test/resources/brooklyn/default.catalog.bom
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#    
+#   http://www.apache.org/licenses/LICENSE-2.0
+#    
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+brooklyn.catalog:
+  scanJavaAnnotations: true

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1b080fb5/docs/guide/ops/catalog/index.md
----------------------------------------------------------------------
diff --git a/docs/guide/ops/catalog/index.md b/docs/guide/ops/catalog/index.md
index 8477204..dcedcd8 100644
--- a/docs/guide/ops/catalog/index.md
+++ b/docs/guide/ops/catalog/index.md
@@ -103,6 +103,11 @@ The following optional catalog metadata is supported:
   (to prevent requiring all OSGi bundles to be loaded at launch).
   Icons are instead typically installed either at the server from which the OSGi bundles
or catalog items are supplied 
   or in the `conf` folder of the Brooklyn distro.
+- `scanJavaAnnotations` [experimental]: if provided (as `true`), this will scan any locally
provided
+  libraries for types annotated `@Catalog` and extract metadata to include them as catalog
items.
+  If no libraries are specified this will scan the default classpath.
+  This feature is experimental and may change or be removed.
+  Also note that other metadata (such as versions, etc) may not be applied.
 - `brooklyn.libraries`: a list of pointers to OSGi bundles required for the catalog item.
   This can be omitted if blueprints are pure YAML and everything required is included in
the classpath and catalog.
   Where custom Java code or bundled resources is needed, however, OSGi JARs supply

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1b080fb5/usage/cli/src/main/resources/brooklyn/default.catalog.bom
----------------------------------------------------------------------
diff --git a/usage/cli/src/main/resources/brooklyn/default.catalog.bom b/usage/cli/src/main/resources/brooklyn/default.catalog.bom
new file mode 100644
index 0000000..cddb832
--- /dev/null
+++ b/usage/cli/src/main/resources/brooklyn/default.catalog.bom
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#    
+#   http://www.apache.org/licenses/LICENSE-2.0
+#    
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+brooklyn.catalog:
+  scanJavaAnnotations: true

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1b080fb5/usage/rest-server/src/test/java/brooklyn/rest/BrooklynRestApiLauncher.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/BrooklynRestApiLauncher.java b/usage/rest-server/src/test/java/brooklyn/rest/BrooklynRestApiLauncher.java
index f189815..dff7925 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/BrooklynRestApiLauncher.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/BrooklynRestApiLauncher.java
@@ -87,6 +87,7 @@ public class BrooklynRestApiLauncher {
 
     private static final Logger log = LoggerFactory.getLogger(BrooklynRestApiLauncher.class);
     final static int FAVOURITE_PORT = 8081;
+    public static final String SCANNING_CATALOG_BOM_URL = "classpath://brooklyn/scanning.catalog.bom";
 
     enum StartMode {
         FILTER, SERVLET, WEB_XML
@@ -200,10 +201,12 @@ public class BrooklynRestApiLauncher {
         }
 
         if (forceUseOfDefaultCatalogWithJavaClassPath) {
-            // don't use any catalog.xml which is set
-            ((BrooklynProperties) mgmt.getConfig()).put(BrooklynServerConfig.BROOKLYN_CATALOG_URL,
ManagementContextInternal.EMPTY_CATALOG_URL);
             // sets URLs for a surefire
+            ((BrooklynProperties) mgmt.getConfig()).put(BrooklynServerConfig.BROOKLYN_CATALOG_URL,
SCANNING_CATALOG_BOM_URL);
             ((LocalManagementContext) mgmt).setBaseClassPathForScanning(ClasspathHelper.forJavaClassPath());
+        } else {
+            // don't use any catalog.xml which is set
+            ((BrooklynProperties) mgmt.getConfig()).put(BrooklynServerConfig.BROOKLYN_CATALOG_URL,
ManagementContextInternal.EMPTY_CATALOG_URL);
         }
 
         return startServer(mgmt, context, summary, disableHighAvailability);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1b080fb5/usage/rest-server/src/test/java/brooklyn/rest/BrooklynRestApiLauncherTestFixture.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/BrooklynRestApiLauncherTestFixture.java
b/usage/rest-server/src/test/java/brooklyn/rest/BrooklynRestApiLauncherTestFixture.java
index 86be4c7..1778786 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/BrooklynRestApiLauncherTestFixture.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/BrooklynRestApiLauncherTestFixture.java
@@ -82,8 +82,10 @@ public abstract class BrooklynRestApiLauncherTestFixture {
     }
 
     public static void forceUseOfDefaultCatalogWithJavaClassPath(ManagementContext manager)
{
+        // TODO duplication with BrooklynRestApiLauncher ?
+        
         // don't use any catalog.xml which is set
-        ((BrooklynProperties)manager.getConfig()).put(BrooklynServerConfig.BROOKLYN_CATALOG_URL,
ManagementContextInternal.EMPTY_CATALOG_URL);
+        ((BrooklynProperties)manager.getConfig()).put(BrooklynServerConfig.BROOKLYN_CATALOG_URL,
BrooklynRestApiLauncher.SCANNING_CATALOG_BOM_URL);
         // sets URLs for a surefire
         ((LocalManagementContext)manager).setBaseClassPathForScanning(ClasspathHelper.forJavaClassPath());
         // this also works

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1b080fb5/usage/rest-server/src/test/java/brooklyn/rest/util/BrooklynRestResourceUtilsTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/util/BrooklynRestResourceUtilsTest.java
b/usage/rest-server/src/test/java/brooklyn/rest/util/BrooklynRestResourceUtilsTest.java
index 833a87a..5922fcb 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/util/BrooklynRestResourceUtilsTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/util/BrooklynRestResourceUtilsTest.java
@@ -44,6 +44,7 @@ import brooklyn.policy.Policy;
 import brooklyn.policy.basic.AbstractPolicy;
 import brooklyn.rest.domain.ApplicationSpec;
 import brooklyn.rest.domain.EntitySpec;
+import brooklyn.test.entity.LocalManagementContextForTests;
 import brooklyn.test.entity.TestEntityImpl;
 import brooklyn.util.collections.MutableMap;
 
@@ -58,7 +59,7 @@ public class BrooklynRestResourceUtilsTest {
 
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
-        managementContext = new LocalManagementContext();
+        managementContext = LocalManagementContextForTests.newInstance();
         util = new BrooklynRestResourceUtils(managementContext);
     }
     
@@ -114,7 +115,7 @@ public class BrooklynRestResourceUtilsTest {
             .javaType(SampleNoOpApplication.class.getName())
             .build();
         managementContext.getCatalog().addItem(item);
-
+        
         ApplicationSpec spec = ApplicationSpec.builder()
                 .name("myname")
                 .type(type)

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1b080fb5/usage/rest-server/src/test/resources/brooklyn/scanning.catalog.bom
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/resources/brooklyn/scanning.catalog.bom b/usage/rest-server/src/test/resources/brooklyn/scanning.catalog.bom
new file mode 100644
index 0000000..cddb832
--- /dev/null
+++ b/usage/rest-server/src/test/resources/brooklyn/scanning.catalog.bom
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#    
+#   http://www.apache.org/licenses/LICENSE-2.0
+#    
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+brooklyn.catalog:
+  scanJavaAnnotations: true


Mime
View raw message