brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [15/45] git commit: BROOKLYN-13: adds BrooklynCatalog.addItem(yaml)
Date Fri, 04 Jul 2014 09:50:57 GMT
BROOKLYN-13: adds BrooklynCatalog.addItem(yaml)

- not yet implemented in BasicBrooklynCatalog, as can’t yet parse yaml


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

Branch: refs/heads/master
Commit: 195410954dd0ece53bc941c93662591470e13272
Parents: 30093bb
Author: Aled Sage <aled.sage@gmail.com>
Authored: Tue Jul 1 13:59:49 2014 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Tue Jul 1 14:17:19 2014 +0100

----------------------------------------------------------------------
 .../main/java/brooklyn/catalog/BrooklynCatalog.java  |  8 ++++++++
 .../catalog/internal/BasicBrooklynCatalog.java       | 15 +++++++++++++++
 2 files changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/19541095/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 29fd1c8..0bbd9d3 100644
--- a/api/src/main/java/brooklyn/catalog/BrooklynCatalog.java
+++ b/api/src/main/java/brooklyn/catalog/BrooklynCatalog.java
@@ -26,6 +26,14 @@ public interface BrooklynCatalog {
     <T> Class<? extends T> loadClass(CatalogItem<T> item);
     <T> Class<? extends T> loadClassByType(String typeName, Class<T> typeClass);
 
+    
+    /**
+     * Adds an item (represented in yaml) to the catalog.
+     * 
+     * @throws IllegalArgumentException if the yaml was invalid
+     */
+    CatalogItem<?> addItem(String yaml);
+    
     /**
      * adds an item to the 'manual' catalog;
      * this does not update the classpath or have a record to the java Class

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/19541095/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 d6b5ff0..f3547dd 100644
--- a/core/src/main/java/brooklyn/catalog/internal/BasicBrooklynCatalog.java
+++ b/core/src/main/java/brooklyn/catalog/internal/BasicBrooklynCatalog.java
@@ -116,6 +116,21 @@ public class BasicBrooklynCatalog implements BrooklynCatalog {
         throw new IllegalStateException("Cannot unwrap catalog item '"+item+"' (type "+item.getClass()+")
to restore DTO");
     }
 
+    private <T> CatalogItemDtoAbstract<T> getAbstractCatalogItem(String yaml)
{
+        // FIXME Need to parse yaml to extract CatalogItem info
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public CatalogItem<?> addItem(String yaml) {
+        log.debug("Adding manual catalog item to "+mgmt+": "+yaml);
+        Preconditions.checkNotNull(yaml, "yaml");
+        if (manualAdditionsCatalog==null) loadManualAdditionsCatalog();
+        CatalogItemDtoAbstract<Object> itemDto = getAbstractCatalogItem(yaml);
+        manualAdditionsCatalog.addEntry(itemDto);
+        return itemDto;
+    }
+
     @Override
     public void addItem(CatalogItem<?> item) {
         log.debug("Adding manual catalog item to "+mgmt+": "+item);


Mime
View raw message