You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2014/07/09 23:46:16 UTC

[03/50] git commit: when app is promoted, take some of the fields set at the template level (but if app is not promoted, don't *reapply* things like location)

when app is promoted, take some of the fields set at the template level
(but if app is not promoted, don't *reapply* things like location)


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

Branch: refs/heads/master
Commit: e8f0371e4a9e1a383d3e5cb44045cf8756e2cdf6
Parents: 19c0a2b
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Fri Jul 4 13:23:37 2014 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Jul 9 22:34:42 2014 +0100

----------------------------------------------------------------------
 .../BrooklynAssemblyTemplateInstantiator.java     | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e8f0371e/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
index 274a3a8..a1bc769 100644
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
+++ b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
@@ -290,18 +290,18 @@ public class BrooklynAssemblyTemplateInstantiator implements AssemblyTemplateSpe
         buildTemplateServicesAsSpecs(template, app, mgmt);
         
         if (shouldUnwrap(template, app)) {
+            EntitySpec<? extends Application> oldApp = app;
             app = (EntitySpec<? extends Application>) Iterables.getOnlyElement( app.getChildren() );
+            // if promoted, apply the transformations done to the app
+            // (normally this will be done by the resolveSpec call above)
+            if (app.getDisplayName()==null) app.displayName(oldApp.getDisplayName());
+            app.locations(oldApp.getLocations());
+            app.configure(app.getConfig());
+            app.addInitializers(oldApp.getInitializers());
+            // TODO other things, as they are added (or refuse to promote if they are set)
+            // (it's a bit messy doing this copy)
         }
         
-        // now apply template items to the root app (possibly promoted)
-        
-        // take name from template if not already set
-        if (app.getDisplayName()==null && template.getName()!=null)
-            app.displayName(template.getName());
-          
-        // apply locations defined at the root of the template
-        applyLocations(mgmt, template, app);
-        
         return app;
     }