brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [3/4] incubator-brooklyn git commit: code review comments on pluggable yaml -- tidy-up of generics and javadoc mainly
Date Wed, 19 Aug 2015 14:35:35 GMT
code review comments on pluggable yaml -- tidy-up of generics and javadoc mainly


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

Branch: refs/heads/master
Commit: a47d5aaa5e4b8794f81e547c29742db3b751e71e
Parents: 6ed695e
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Wed Aug 19 15:34:27 2015 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Wed Aug 19 15:34:27 2015 +0100

----------------------------------------------------------------------
 .../brooklyn/core/mgmt/EntityManagementUtils.java |  3 ++-
 .../core/plan/PlanNotRecognizedException.java     |  5 +----
 .../brooklyn/core/plan/PlanToSpecTransformer.java | 18 ++++++++++++++++--
 .../brooklyn/spi/creation/CampCatalogUtils.java   |  2 +-
 .../spi/creation/CampToSpecTransformer.java       |  5 +++--
 5 files changed, 23 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a47d5aaa/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java
index 1b150f1..4d37824 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java
@@ -95,11 +95,12 @@ public class EntityManagementUtils {
         throw new PlanNotRecognizedException("Invalid plan, tried parsing with " + types);
     }
 
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     public static AbstractBrooklynObjectSpec<?, ?> createCatalogSpec(ManagementContext
mgmt, CatalogItem<?, ?> item) {
         Collection<String> types = new ArrayList<String>();
         for (PlanToSpecTransformer c : PlanToSpecFactory.all(mgmt)) {
             try {
-                return c.createCatalogSpec(item);
+                return c.createCatalogSpec((CatalogItem)item);
             } catch (PlanNotRecognizedException e) {
                 types.add(c.getName());
             }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a47d5aaa/core/src/main/java/org/apache/brooklyn/core/plan/PlanNotRecognizedException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/plan/PlanNotRecognizedException.java
b/core/src/main/java/org/apache/brooklyn/core/plan/PlanNotRecognizedException.java
index 2551220..4d62d4a 100644
--- a/core/src/main/java/org/apache/brooklyn/core/plan/PlanNotRecognizedException.java
+++ b/core/src/main/java/org/apache/brooklyn/core/plan/PlanNotRecognizedException.java
@@ -19,11 +19,8 @@
 package org.apache.brooklyn.core.plan;
 
 public class PlanNotRecognizedException extends RuntimeException {
-    private static final long serialVersionUID = 1L;
 
-    public PlanNotRecognizedException() {
-        super();
-    }
+    private static final long serialVersionUID = -5590108442839125317L;
 
     public PlanNotRecognizedException(String message, Throwable cause) {
         super(message, cause);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a47d5aaa/core/src/main/java/org/apache/brooklyn/core/plan/PlanToSpecTransformer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/plan/PlanToSpecTransformer.java b/core/src/main/java/org/apache/brooklyn/core/plan/PlanToSpecTransformer.java
index 13cd3bb..66f1b62 100644
--- a/core/src/main/java/org/apache/brooklyn/core/plan/PlanToSpecTransformer.java
+++ b/core/src/main/java/org/apache/brooklyn/core/plan/PlanToSpecTransformer.java
@@ -18,6 +18,8 @@
  */
 package org.apache.brooklyn.core.plan;
 
+import java.util.ServiceLoader;
+
 import org.apache.brooklyn.api.catalog.CatalogItem;
 import org.apache.brooklyn.api.entity.Application;
 import org.apache.brooklyn.api.entity.EntitySpec;
@@ -26,10 +28,22 @@ import org.apache.brooklyn.core.mgmt.ManagementContextInjectable;
 
 import com.google.common.annotations.Beta;
 
+/** Pluggable {@link ServiceLoader} interface for defferent plan-interpreters.
+ * Implementations should take a plan and return an {@link EntitySpec}.
+ */
+@Beta
 public interface PlanToSpecTransformer extends ManagementContextInjectable {
+    
+    /** Human-readable name for this transformer */
     String getName();
-    @Beta
+    
+    /** whether this accepts the given MIME format */
     boolean accepts(String mime);
+    
+    /** creates an {@link EntitySpec} given a plan, according to the transformation rules
this understands */
     <T extends Application> EntitySpec<T> createApplicationSpec(String plan);
-    AbstractBrooklynObjectSpec<?, ?> createCatalogSpec(CatalogItem<?, ?> item);
+    
+    /** creates an object spec given a catalog item, according to the transformation rules
this understands */
+    <T,SpecT extends AbstractBrooklynObjectSpec<T, SpecT>> AbstractBrooklynObjectSpec<T,
SpecT> createCatalogSpec(CatalogItem<T, SpecT> item);
+    
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a47d5aaa/usage/camp/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/CampCatalogUtils.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/CampCatalogUtils.java
b/usage/camp/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/CampCatalogUtils.java
index 71aded1..59557bb 100644
--- a/usage/camp/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/CampCatalogUtils.java
+++ b/usage/camp/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/CampCatalogUtils.java
@@ -39,7 +39,6 @@ import org.apache.brooklyn.camp.brooklyn.api.AssemblyTemplateSpecInstantiator;
 import org.apache.brooklyn.camp.spi.AssemblyTemplate;
 import org.apache.brooklyn.camp.spi.instantiate.AssemblyTemplateInstantiator;
 import org.apache.brooklyn.camp.spi.pdp.DeploymentPlan;
-import org.apache.brooklyn.camp.util.yaml.Yamls;
 import org.apache.brooklyn.core.catalog.internal.BasicBrooklynCatalog;
 import org.apache.brooklyn.core.catalog.internal.BasicBrooklynCatalog.BrooklynLoaderTracker;
 import org.apache.brooklyn.core.catalog.internal.CatalogUtils;
@@ -49,6 +48,7 @@ import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.apache.brooklyn.util.guava.Maybe;
 import org.apache.brooklyn.util.stream.Streams;
 import org.apache.brooklyn.util.text.Strings;
+import org.apache.brooklyn.util.yaml.Yamls;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a47d5aaa/usage/camp/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/CampToSpecTransformer.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/CampToSpecTransformer.java
b/usage/camp/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/CampToSpecTransformer.java
index 7650a9b..abf3200 100644
--- a/usage/camp/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/CampToSpecTransformer.java
+++ b/usage/camp/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/CampToSpecTransformer.java
@@ -78,9 +78,10 @@ public class CampToSpecTransformer implements PlanToSpecTransformer {
       }
     }
 
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     @Override
-    public AbstractBrooklynObjectSpec<?, ?> createCatalogSpec(CatalogItem<?, ?>
item) {
-        return CampCatalogUtils.createSpec(mgmt, item);
+    public <T, SpecT extends AbstractBrooklynObjectSpec<T, SpecT>> AbstractBrooklynObjectSpec<T,
SpecT> createCatalogSpec(CatalogItem<T, SpecT> item) {
+        return (AbstractBrooklynObjectSpec<T, SpecT>) CampCatalogUtils.createSpec(mgmt,
(CatalogItem)item);
     }
 
     @Override


Mime
View raw message