brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject [19/20] incubator-brooklyn git commit: Package rename to org.apache.brooklyn: usage/camp/
Date Wed, 05 Aug 2015 20:56:23 GMT
Package rename to org.apache.brooklyn: usage/camp/


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

Branch: refs/heads/master
Commit: e406d1ad4ede0410142c5426bc720920b91dc9f7
Parents: 74ee6aa
Author: Aled Sage <aled.sage@gmail.com>
Authored: Wed Aug 5 14:56:27 2015 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Wed Aug 5 16:51:01 2015 +0100

----------------------------------------------------------------------
 .../camp/brooklyn/BrooklynCampConstants.java    |  50 -
 .../camp/brooklyn/BrooklynCampPlatform.java     |  76 --
 .../BrooklynCampPlatformLauncherAbstract.java   |  73 --
 .../BrooklynCampPlatformLauncherNoServer.java   |  36 -
 .../camp/brooklyn/BrooklynCampReservedKeys.java |  29 -
 .../camp/brooklyn/YamlLauncherAbstract.java     | 133 ---
 .../camp/brooklyn/YamlLauncherNoServer.java     |  39 -
 .../BrooklynAssemblyTemplateInstantiator.java   | 282 ------
 .../BrooklynComponentTemplateResolver.java      | 491 ----------
 .../BrooklynEntityDecorationResolver.java       | 181 ----
 .../spi/creation/BrooklynEntityMatcher.java     | 193 ----
 .../creation/BrooklynYamlLocationResolver.java  | 142 ---
 .../creation/BrooklynYamlTypeInstantiator.java  | 208 -----
 .../spi/creation/EntitySpecConfiguration.java   |  58 --
 .../service/BrooklynServiceTypeResolver.java    |  72 --
 .../service/CatalogServiceTypeResolver.java     |  78 --
 .../service/ChefServiceTypeResolver.java        |  62 --
 .../service/JavaServiceTypeResolver.java        |  39 -
 .../creation/service/ServiceTypeResolver.java   |  73 --
 .../spi/dsl/BrooklynDslDeferredSupplier.java    |  99 --
 .../spi/dsl/BrooklynDslInterpreter.java         | 188 ----
 .../camp/brooklyn/spi/dsl/DslUtils.java         |  44 -
 .../spi/dsl/methods/BrooklynDslCommon.java      | 302 ------
 .../brooklyn/spi/dsl/methods/DslComponent.java  | 320 -------
 .../camp/brooklyn/spi/dsl/parse/DslParser.java  | 144 ---
 .../spi/dsl/parse/FunctionWithArgs.java         |  57 --
 .../brooklyn/spi/dsl/parse/QuotedString.java    |  49 -
 .../lookup/AbstractBrooklynResourceLookup.java  |  36 -
 .../lookup/AbstractTemplateBrooklynLookup.java  |  62 --
 .../spi/lookup/AssemblyBrooklynLookup.java      |  69 --
 .../lookup/AssemblyTemplateBrooklynLookup.java  |  70 --
 .../brooklyn/spi/lookup/BrooklynUrlLookup.java  |  38 -
 .../lookup/PlatformComponentBrooklynLookup.java |  61 --
 ...PlatformComponentTemplateBrooklynLookup.java |  59 --
 .../platform/BrooklynImmutableCampPlatform.java | 107 ---
 .../camp/brooklyn/BrooklynCampConstants.java    |  50 +
 .../camp/brooklyn/BrooklynCampPlatform.java     |  78 ++
 .../BrooklynCampPlatformLauncherAbstract.java   |  73 ++
 .../BrooklynCampPlatformLauncherNoServer.java   |  36 +
 .../camp/brooklyn/BrooklynCampReservedKeys.java |  29 +
 .../camp/brooklyn/YamlLauncherAbstract.java     | 133 +++
 .../camp/brooklyn/YamlLauncherNoServer.java     |  39 +
 .../BrooklynAssemblyTemplateInstantiator.java   | 283 ++++++
 .../BrooklynComponentTemplateResolver.java      | 490 ++++++++++
 .../BrooklynEntityDecorationResolver.java       | 180 ++++
 .../spi/creation/BrooklynEntityMatcher.java     | 193 ++++
 .../creation/BrooklynYamlLocationResolver.java  | 142 +++
 .../creation/BrooklynYamlTypeInstantiator.java  | 208 +++++
 .../spi/creation/EntitySpecConfiguration.java   |  58 ++
 .../service/BrooklynServiceTypeResolver.java    |  71 ++
 .../service/CatalogServiceTypeResolver.java     |  78 ++
 .../service/ChefServiceTypeResolver.java        |  61 ++
 .../service/JavaServiceTypeResolver.java        |  39 +
 .../creation/service/ServiceTypeResolver.java   |  73 ++
 .../spi/dsl/BrooklynDslDeferredSupplier.java    |  99 ++
 .../spi/dsl/BrooklynDslInterpreter.java         | 188 ++++
 .../camp/brooklyn/spi/dsl/DslUtils.java         |  44 +
 .../spi/dsl/methods/BrooklynDslCommon.java      | 301 ++++++
 .../brooklyn/spi/dsl/methods/DslComponent.java  | 320 +++++++
 .../camp/brooklyn/spi/dsl/parse/DslParser.java  | 144 +++
 .../spi/dsl/parse/FunctionWithArgs.java         |  57 ++
 .../brooklyn/spi/dsl/parse/QuotedString.java    |  49 +
 .../lookup/AbstractBrooklynResourceLookup.java  |  36 +
 .../lookup/AbstractTemplateBrooklynLookup.java  |  62 ++
 .../spi/lookup/AssemblyBrooklynLookup.java      |  69 ++
 .../lookup/AssemblyTemplateBrooklynLookup.java  |  70 ++
 .../brooklyn/spi/lookup/BrooklynUrlLookup.java  |  38 +
 .../lookup/PlatformComponentBrooklynLookup.java |  61 ++
 ...PlatformComponentTemplateBrooklynLookup.java |  59 ++
 .../platform/BrooklynImmutableCampPlatform.java | 109 +++
 ...lyn.spi.creation.service.ServiceTypeResolver |  22 -
 ...lyn.spi.creation.service.ServiceTypeResolver |  22 +
 .../camp/brooklyn/AbstractYamlRebindTest.java   | 206 -----
 .../camp/brooklyn/AbstractYamlTest.java         | 182 ----
 .../io/brooklyn/camp/brooklyn/AppYamlTest.java  | 119 ---
 .../BrooklynYamlTypeInstantiatorTest.java       |  76 --
 .../camp/brooklyn/ByonLocationsYamlTest.java    | 281 ------
 .../camp/brooklyn/DslAndRebindYamlTest.java     | 245 -----
 .../brooklyn/EmptySoftwareProcessYamlTest.java  | 103 ---
 .../EnrichersSlightlySimplerYamlTest.java       | 134 ---
 .../camp/brooklyn/EnrichersYamlTest.java        | 257 ------
 .../brooklyn/EntitiesYamlIntegrationTest.java   |  71 --
 .../camp/brooklyn/EntitiesYamlTest.java         | 919 -------------------
 ...aWebAppWithDslYamlRebindIntegrationTest.java | 125 ---
 .../brooklyn/JavaWebAppsIntegrationTest.java    | 272 ------
 .../camp/brooklyn/JavaWebAppsMatchingTest.java  | 144 ---
 .../camp/brooklyn/LocationsYamlTest.java        | 285 ------
 .../camp/brooklyn/MapReferenceYamlTest.java     | 130 ---
 .../brooklyn/camp/brooklyn/ObjectsYamlTest.java | 280 ------
 .../camp/brooklyn/PoliciesYamlTest.java         | 215 -----
 .../camp/brooklyn/ReferencedYamlTest.java       | 180 ----
 .../brooklyn/ReferencingYamlTestEntity.java     |  66 --
 .../brooklyn/ReferencingYamlTestEntityImpl.java |  25 -
 .../brooklyn/ReloadBrooklynPropertiesTest.java  |  87 --
 .../camp/brooklyn/TestEntityWithInitConfig.java |  35 -
 .../brooklyn/TestEntityWithInitConfigImpl.java  |  59 --
 .../camp/brooklyn/TestReferencingEnricher.java  |  34 -
 .../camp/brooklyn/TestReferencingPolicy.java    |  34 -
 .../TestSensorAndEffectorInitializer.java       |  86 --
 .../brooklyn/VanillaBashNetcatYamlTest.java     | 113 ---
 .../io/brooklyn/camp/brooklyn/WrapAppTest.java  |  93 --
 .../catalog/AbstractCatalogXmlTest.java         | 109 ---
 .../CatalogOsgiVersionMoreEntityTest.java       | 261 ------
 .../brooklyn/catalog/CatalogXmlOsgiTest.java    |  37 -
 .../brooklyn/catalog/CatalogXmlVersionTest.java |  58 --
 .../brooklyn/catalog/CatalogYamlCombiTest.java  | 145 ---
 .../brooklyn/catalog/CatalogYamlEntityTest.java | 781 ----------------
 .../catalog/CatalogYamlLocationTest.java        | 248 -----
 .../brooklyn/catalog/CatalogYamlPolicyTest.java | 196 ----
 .../brooklyn/catalog/CatalogYamlRebindTest.java | 132 ---
 .../catalog/CatalogYamlTemplateTest.java        |  96 --
 .../catalog/CatalogYamlVersioningTest.java      | 258 ------
 .../camp/brooklyn/catalog/TestBasicApp.java     |  27 -
 .../camp/brooklyn/catalog/TestBasicAppImpl.java |  24 -
 .../camp/brooklyn/spi/dsl/DslParseTest.java     |  79 --
 .../camp/brooklyn/AbstractYamlRebindTest.java   | 208 +++++
 .../camp/brooklyn/AbstractYamlTest.java         | 184 ++++
 .../brooklyn/camp/brooklyn/AppYamlTest.java     | 119 +++
 .../BrooklynYamlTypeInstantiatorTest.java       |  75 ++
 .../camp/brooklyn/ByonLocationsYamlTest.java    | 281 ++++++
 .../camp/brooklyn/DslAndRebindYamlTest.java     | 245 +++++
 .../brooklyn/EmptySoftwareProcessYamlTest.java  | 103 +++
 .../EnrichersSlightlySimplerYamlTest.java       | 134 +++
 .../camp/brooklyn/EnrichersYamlTest.java        | 257 ++++++
 .../brooklyn/EntitiesYamlIntegrationTest.java   |  71 ++
 .../camp/brooklyn/EntitiesYamlTest.java         | 919 +++++++++++++++++++
 ...aWebAppWithDslYamlRebindIntegrationTest.java | 125 +++
 .../brooklyn/JavaWebAppsIntegrationTest.java    | 275 ++++++
 .../camp/brooklyn/JavaWebAppsMatchingTest.java  | 146 +++
 .../camp/brooklyn/LocationsYamlTest.java        | 285 ++++++
 .../camp/brooklyn/MapReferenceYamlTest.java     | 130 +++
 .../brooklyn/camp/brooklyn/ObjectsYamlTest.java | 280 ++++++
 .../camp/brooklyn/PoliciesYamlTest.java         | 215 +++++
 .../camp/brooklyn/ReferencedYamlTest.java       | 180 ++++
 .../brooklyn/ReferencingYamlTestEntity.java     |  66 ++
 .../brooklyn/ReferencingYamlTestEntityImpl.java |  25 +
 .../brooklyn/ReloadBrooklynPropertiesTest.java  |  89 ++
 .../camp/brooklyn/TestEntityWithInitConfig.java |  35 +
 .../brooklyn/TestEntityWithInitConfigImpl.java  |  59 ++
 .../camp/brooklyn/TestReferencingEnricher.java  |  34 +
 .../camp/brooklyn/TestReferencingPolicy.java    |  34 +
 .../TestSensorAndEffectorInitializer.java       |  86 ++
 .../brooklyn/VanillaBashNetcatYamlTest.java     | 114 +++
 .../brooklyn/camp/brooklyn/WrapAppTest.java     |  93 ++
 .../catalog/AbstractCatalogXmlTest.java         | 109 +++
 .../CatalogOsgiVersionMoreEntityTest.java       | 262 ++++++
 .../brooklyn/catalog/CatalogXmlOsgiTest.java    |  37 +
 .../brooklyn/catalog/CatalogXmlVersionTest.java |  58 ++
 .../brooklyn/catalog/CatalogYamlCombiTest.java  | 143 +++
 .../brooklyn/catalog/CatalogYamlEntityTest.java | 780 ++++++++++++++++
 .../catalog/CatalogYamlLocationTest.java        | 247 +++++
 .../brooklyn/catalog/CatalogYamlPolicyTest.java | 195 ++++
 .../brooklyn/catalog/CatalogYamlRebindTest.java | 132 +++
 .../catalog/CatalogYamlTemplateTest.java        |  95 ++
 .../catalog/CatalogYamlVersioningTest.java      | 257 ++++++
 .../camp/brooklyn/catalog/TestBasicApp.java     |  27 +
 .../camp/brooklyn/catalog/TestBasicAppImpl.java |  24 +
 .../camp/brooklyn/spi/dsl/DslParseTest.java     |  79 ++
 .../more-entities-osgi-catalog-scan.yaml        |  32 -
 .../more-entity-v1-called-v1-osgi-catalog.yaml  |  27 -
 .../catalog/more-entity-v1-osgi-catalog.yaml    |  27 -
 ...more-entity-v1-with-policy-osgi-catalog.yaml |  29 -
 .../catalog/more-entity-v2-osgi-catalog.yaml    |  28 -
 .../more-policies-osgi-catalog-scan.yaml        |  32 -
 .../catalog/simple-policy-osgi-catalog.yaml     |  27 -
 .../more-entities-osgi-catalog-scan.yaml        |  32 +
 .../more-entity-v1-called-v1-osgi-catalog.yaml  |  27 +
 .../catalog/more-entity-v1-osgi-catalog.yaml    |  27 +
 ...more-entity-v1-with-policy-osgi-catalog.yaml |  29 +
 .../catalog/more-entity-v2-osgi-catalog.yaml    |  28 +
 .../more-policies-osgi-catalog-scan.yaml        |  32 +
 .../catalog/simple-policy-osgi-catalog.yaml     |  27 +
 .../camp/src/test/resources/simple-catalog.xml  |   2 +-
 .../resources/test-entity-with-init-config.yaml |   2 +-
 .../resources/test-referencing-enrichers.yaml   |  26 +-
 .../resources/test-referencing-entities.yaml    |  12 +-
 .../resources/test-referencing-policies.yaml    |  26 +-
 .../brooklyn/launcher/BrooklynLauncher.java     |   4 +-
 .../camp/BrooklynCampPlatformLauncher.java      |   5 +-
 .../launcher/camp/SimpleYamlLauncher.java       |   4 +-
 .../blueprints/AbstractBlueprintTest.java       |   2 +-
 .../brooklyn/rest/BrooklynRestApiLauncher.java  |   4 +-
 .../brooklyn/rest/HaMasterCheckFilterTest.java  |   2 +-
 .../rest/testing/BrooklynRestApiTest.java       |   2 +-
 184 files changed, 11602 insertions(+), 11596 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampConstants.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampConstants.java b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampConstants.java
deleted file mode 100644
index c8d3d1d..0000000
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampConstants.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.
- */
-package io.brooklyn.camp.brooklyn;
-
-import io.brooklyn.camp.CampPlatform;
-
-import java.util.Set;
-
-import brooklyn.config.BrooklynServerConfig;
-import brooklyn.config.ConfigInheritance;
-import brooklyn.config.ConfigKey;
-import brooklyn.entity.basic.ConfigKeys;
-
-import com.google.common.collect.ImmutableSet;
-
-public class BrooklynCampConstants {
-
-    public static final String PLAN_ID_FLAG = "planId";
-
-    public static final ConfigKey<String> PLAN_ID = ConfigKeys.builder(String.class, "camp.plan.id")
-            .description("Identifier supplied in the deployment plan for component to which this entity corresponds "
-                        + "(human-readable, for correlating across plan, template, and instance)")
-            .inheritance(ConfigInheritance.NONE)
-            .build();
-
-    public static final ConfigKey<String> TEMPLATE_ID = ConfigKeys.builder(String.class, "camp.template.id")
-            .description("UID of the component in the CAMP template from which this entity was created")
-            .inheritance(ConfigInheritance.NONE)
-            .build();
-
-    public static final ConfigKey<CampPlatform> CAMP_PLATFORM = BrooklynServerConfig.CAMP_PLATFORM;
-
-    public static final Set<String> YAML_URL_PROTOCOL_WHITELIST = ImmutableSet.of("classpath", "http");
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampPlatform.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampPlatform.java b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampPlatform.java
deleted file mode 100644
index db4ce37..0000000
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampPlatform.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.
- */
-package io.brooklyn.camp.brooklyn;
-
-import io.brooklyn.camp.AggregatingCampPlatform;
-import io.brooklyn.camp.CampPlatform;
-import io.brooklyn.camp.brooklyn.spi.creation.BrooklynEntityMatcher;
-import io.brooklyn.camp.brooklyn.spi.dsl.BrooklynDslInterpreter;
-import io.brooklyn.camp.brooklyn.spi.platform.BrooklynImmutableCampPlatform;
-import io.brooklyn.camp.spi.PlatformRootSummary;
-import brooklyn.camp.brooklyn.api.HasBrooklynManagementContext;
-import brooklyn.config.BrooklynProperties;
-import brooklyn.management.ManagementContext;
-import brooklyn.management.ManagementContext.PropertiesReloadListener;
-
-/** {@link CampPlatform} implementation which includes Brooklyn entities 
- * (via {@link BrooklynImmutableCampPlatform})
- * and allows customisation / additions */
-public class BrooklynCampPlatform extends AggregatingCampPlatform implements HasBrooklynManagementContext {
-
-    private final ManagementContext bmc;
-
-    public BrooklynCampPlatform(PlatformRootSummary root, ManagementContext managementContext) {
-        super(root);
-        addPlatform(new BrooklynImmutableCampPlatform(root, managementContext));
-        
-        this.bmc = managementContext;
-        
-        addMatchers();
-        addInterpreters();
-        
-        managementContext.addPropertiesReloadListener(new PropertiesReloadListener() {
-            private static final long serialVersionUID = -3739276553334749184L;
-            @Override public void reloaded() {
-                setConfigKeyAtManagmentContext();
-            }
-        });
-    }
-
-    // --- brooklyn setup
-    
-    public ManagementContext getBrooklynManagementContext() {
-        return bmc;
-    }
-    
-    protected void addMatchers() {
-        // TODO artifacts
-        pdp().addMatcher(new BrooklynEntityMatcher(bmc));
-    }
-    
-    protected void addInterpreters() {
-        pdp().addInterpreter(new BrooklynDslInterpreter());
-    }
-
-    public BrooklynCampPlatform setConfigKeyAtManagmentContext() {
-        ((BrooklynProperties)bmc.getConfig()).put(BrooklynCampConstants.CAMP_PLATFORM, this);
-        return this;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampPlatformLauncherAbstract.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampPlatformLauncherAbstract.java b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampPlatformLauncherAbstract.java
deleted file mode 100644
index 81f633a..0000000
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampPlatformLauncherAbstract.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.
- */
-package io.brooklyn.camp.brooklyn;
-
-import io.brooklyn.camp.spi.PlatformRootSummary;
-import brooklyn.management.ManagementContext;
-import brooklyn.management.internal.LocalManagementContext;
-
-import com.google.common.annotations.Beta;
-
-/** launcher for {@link BrooklynCampPlatform}, which may or may not start a (web) server depending on children */
-@Beta
-public abstract class BrooklynCampPlatformLauncherAbstract {
-
-    protected BrooklynCampPlatform platform;
-    protected ManagementContext mgmt;
-    
-    public BrooklynCampPlatformLauncherAbstract useManagementContext(ManagementContext mgmt) {
-        if (this.mgmt!=null && mgmt!=this.mgmt)
-            throw new IllegalStateException("Attempt to change mgmt context; not supported.");
-        
-        this.mgmt = mgmt;
-        
-        return this;
-    }
-    
-    public BrooklynCampPlatformLauncherAbstract launch() {
-        if (platform!=null)
-            throw new IllegalStateException("platform already created");
-
-        if (getBrooklynMgmt()==null)
-            useManagementContext(newMgmtContext());
-        
-        platform = new BrooklynCampPlatform(
-                PlatformRootSummary.builder().name("Brooklyn CAMP Platform").build(),
-                getBrooklynMgmt())
-            .setConfigKeyAtManagmentContext();
-        
-        return this;
-    }
-
-    protected LocalManagementContext newMgmtContext() {
-        return new LocalManagementContext();
-    }
-
-    public ManagementContext getBrooklynMgmt() {
-        return mgmt;
-    }
-    
-    public BrooklynCampPlatform getCampPlatform() {
-        return platform;
-    }
-
-    /** stops any servers (camp and brooklyn) launched by this launcher */
-    public abstract void stopServers() throws Exception;
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampPlatformLauncherNoServer.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampPlatformLauncherNoServer.java b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampPlatformLauncherNoServer.java
deleted file mode 100644
index 440c5ed..0000000
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampPlatformLauncherNoServer.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.
- */
-package io.brooklyn.camp.brooklyn;
-
-import com.google.common.annotations.Beta;
-
-
-/** launcher for {@link BrooklynCampPlatform}, which does not start a server (and can live in this project) */
-@Beta
-public class BrooklynCampPlatformLauncherNoServer extends BrooklynCampPlatformLauncherAbstract {
-
-    public void stopServers() {
-        // nothing to do
-    }
-    
-    public static void main(String[] args) {
-        new BrooklynCampPlatformLauncherNoServer().launch();
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampReservedKeys.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampReservedKeys.java b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampReservedKeys.java
deleted file mode 100644
index b81e223..0000000
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampReservedKeys.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.
- */
-package io.brooklyn.camp.brooklyn;
-
-public interface BrooklynCampReservedKeys {
-    public static final String BROOKLYN_CONFIG = "brooklyn.config";
-    public static final String BROOKLYN_FLAGS = "brooklyn.flags";
-    public static final String BROOKLYN_POLICIES = "brooklyn.policies";
-    public static final String BROOKLYN_ENRICHERS = "brooklyn.enrichers";
-    public static final String BROOKLYN_CHILDREN = "brooklyn.children";
-    public static final String BROOKLYN_INITIALIZERS = "brooklyn.initializers";
-    public static final String BROOKLYN_CATALOG = "brooklyn.catalog";
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/YamlLauncherAbstract.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/YamlLauncherAbstract.java b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/YamlLauncherAbstract.java
deleted file mode 100644
index c4e7894..0000000
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/YamlLauncherAbstract.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 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.
- */
-package io.brooklyn.camp.brooklyn;
-
-import io.brooklyn.camp.spi.Assembly;
-import io.brooklyn.camp.spi.AssemblyTemplate;
-
-import java.io.Reader;
-import java.util.Set;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.entity.Application;
-import brooklyn.entity.Entity;
-import brooklyn.entity.basic.BrooklynShutdownHooks;
-import brooklyn.entity.basic.BrooklynTaskTags;
-import brooklyn.entity.basic.Entities;
-import brooklyn.management.ManagementContext;
-import brooklyn.management.Task;
-import brooklyn.util.ResourceUtils;
-import brooklyn.util.exceptions.Exceptions;
-import brooklyn.util.stream.Streams;
-
-import com.google.common.annotations.Beta;
-
-/** convenience for launching YAML files directly */
-@Beta
-public abstract class YamlLauncherAbstract {
-
-    private static final Logger log = LoggerFactory.getLogger(YamlLauncherAbstract.class);
-       
-    protected final BrooklynCampPlatformLauncherAbstract platformLauncher;
-
-    protected final BrooklynCampPlatform platform;
-    protected final ManagementContext brooklynMgmt;
-    protected boolean shutdownAppsOnExit = false;
-
-    public YamlLauncherAbstract() {
-        this.platformLauncher = newPlatformLauncher();
-        platformLauncher.launch();
-        this.platform = platformLauncher.getCampPlatform();
-        this.brooklynMgmt = platformLauncher.getBrooklynMgmt();
-    }
-
-    public ManagementContext getManagementContext() {
-        return brooklynMgmt;
-    }
-
-    public boolean getShutdownAppsOnExit() {
-        return shutdownAppsOnExit;
-    }
-    
-    public void setShutdownAppsOnExit(boolean shutdownAppsOnExit) {
-        this.shutdownAppsOnExit = shutdownAppsOnExit;
-    }
-    
-    protected abstract BrooklynCampPlatformLauncherAbstract newPlatformLauncher();
-
-    public Application launchAppYaml(String url) {
-        return launchAppYaml(url, true);
-    }
-
-    public Application launchAppYaml(String url, boolean waitForTasksToComplete) {
-        try {
-            Reader input = Streams.reader(new ResourceUtils(this).getResourceFromUrl(url));
-            Application app = launchAppYaml(input, waitForTasksToComplete);
-            log.info("Application started from YAML file "+url+": "+app);
-            return app;
-        } catch (Exception e) {
-            throw Exceptions.propagate(e);
-        }
-    }
-
-    public Application launchAppYaml(Reader input) {
-        return launchAppYaml(input, true);
-    }
-
-    public Application launchAppYaml(Reader input, boolean waitForTasksToComplete) {
-        try {
-            AssemblyTemplate at = platform.pdp().registerDeploymentPlan(input);
-
-            Assembly assembly = at.getInstantiator().newInstance().instantiate(at, platform);
-            Entity app = brooklynMgmt.getEntityManager().getEntity(assembly.getId());
-            log.info("Launching "+app);
-
-            if (getShutdownAppsOnExit()) BrooklynShutdownHooks.invokeStopOnShutdown(app);
-
-            if (waitForTasksToComplete) {
-                Set<Task<?>> tasks = BrooklynTaskTags.getTasksInEntityContext(brooklynMgmt.getExecutionManager(), app);
-                log.info("Waiting on "+tasks.size()+" task(s)");
-                for (Task<?> t: tasks) {
-                    t.blockUntilEnded();
-                }
-            }
-
-            log.info("Application started from YAML: "+app);
-            Entities.dumpInfo(app);
-            return (Application)app;
-        } catch (Exception e) {
-            throw Exceptions.propagate(e);
-        }
-    }
-
-    /** kills all apps, web servers, and mgmt context
-     * <p>
-     * this launcher does not support being used again subsequently */
-    public void destroyAll() {
-        Entities.destroyAll(getManagementContext());
-        try {
-            platformLauncher.stopServers();
-        } catch (Exception e) {
-            log.warn("Unable to stop servers (ignoring): "+e);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/YamlLauncherNoServer.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/YamlLauncherNoServer.java b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/YamlLauncherNoServer.java
deleted file mode 100644
index c5ef371..0000000
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/YamlLauncherNoServer.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.
- */
-package io.brooklyn.camp.brooklyn;
-
-import com.google.common.annotations.Beta;
-
-/** convenience for launching YAML files directly */
-@Beta
-public class YamlLauncherNoServer extends YamlLauncherAbstract {
-
-    @Override
-    protected BrooklynCampPlatformLauncherAbstract newPlatformLauncher() {
-        return new BrooklynCampPlatformLauncherNoServer();
-    }
-
-    public static void main(String[] args) {
-        YamlLauncherNoServer l = new YamlLauncherNoServer();
-        l.setShutdownAppsOnExit(true);
-        
-        l.launchAppYaml("java-web-app-and-db-with-function.yaml");
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/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
deleted file mode 100644
index 7fb0da7..0000000
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * 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.
- */
-package io.brooklyn.camp.brooklyn.spi.creation;
-
-import io.brooklyn.camp.CampPlatform;
-import io.brooklyn.camp.brooklyn.BrooklynCampConstants;
-import io.brooklyn.camp.spi.Assembly;
-import io.brooklyn.camp.spi.AssemblyTemplate;
-import io.brooklyn.camp.spi.AssemblyTemplate.Builder;
-import io.brooklyn.camp.spi.PlatformComponentTemplate;
-import io.brooklyn.camp.spi.collection.ResolvableLink;
-import io.brooklyn.camp.spi.instantiate.AssemblyTemplateInstantiator;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.camp.brooklyn.api.AssemblyTemplateSpecInstantiator;
-import brooklyn.camp.brooklyn.api.HasBrooklynManagementContext;
-import org.apache.brooklyn.catalog.CatalogItem;
-import brooklyn.catalog.internal.BasicBrooklynCatalog.BrooklynLoaderTracker;
-import brooklyn.catalog.internal.CatalogUtils;
-import brooklyn.config.BrooklynServerConfig;
-import brooklyn.entity.Application;
-import brooklyn.entity.Entity;
-import brooklyn.entity.basic.BasicApplicationImpl;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.management.ManagementContext;
-import brooklyn.management.classloading.BrooklynClassLoadingContext;
-import brooklyn.management.internal.EntityManagementUtils;
-import brooklyn.management.internal.EntityManagementUtils.CreationResult;
-import brooklyn.util.ResourceUtils;
-import brooklyn.util.exceptions.Exceptions;
-import brooklyn.util.flags.TypeCoercions;
-import brooklyn.util.net.Urls;
-
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-
-public class BrooklynAssemblyTemplateInstantiator implements AssemblyTemplateSpecInstantiator {
-
-    private static final Logger log = LoggerFactory.getLogger(BrooklynAssemblyTemplateInstantiator.class);
-
-    public static final String NEVER_UNWRAP_APPS_PROPERTY = "wrappedApp";
-
-    @Override
-    public Assembly instantiate(AssemblyTemplate template, CampPlatform platform) {
-        Application app = create(template, platform);
-        CreationResult<Application, Void> start = EntityManagementUtils.start(app);
-        log.debug("CAMP created "+app+"; starting in "+start.task());
-        return platform.assemblies().get(app.getApplicationId());
-    }
-
-    public Application create(AssemblyTemplate template, CampPlatform platform) {
-        Application instance = EntityManagementUtils.createUnstarted(getBrooklynManagementContext(platform), template);
-        log.debug("CAMP created {}", instance);
-        return instance;
-    }
-
-    private ManagementContext getBrooklynManagementContext(CampPlatform platform) {
-        return ((HasBrooklynManagementContext)platform).getBrooklynManagementContext();
-    }
-
-    @SuppressWarnings("unchecked")
-    public EntitySpec<? extends Application> createSpec(AssemblyTemplate template, CampPlatform platform, BrooklynClassLoadingContext loader, boolean autoUnwrapIfPossible) {
-        log.debug("CAMP creating application instance for {} ({})", template.getId(), template);
-
-        // AssemblyTemplates created via PDP, _specifying_ then entities to put in
-
-        BrooklynComponentTemplateResolver resolver = BrooklynComponentTemplateResolver.Factory.newInstance(
-            loader, buildWrapperAppTemplate(template));
-        EntitySpec<? extends Application> app = resolver.resolveSpec(null);
-
-        // first build the children into an empty shell app
-        List<EntitySpec<?>> childSpecs = buildTemplateServicesAsSpecs(loader, template, platform);
-        for (EntitySpec<?> childSpec : childSpecs) {
-            app.child(childSpec);
-        }
-
-        if (autoUnwrapIfPossible && 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
-            // (transformations will be done by the resolveSpec call above, but we are collapsing oldApp so transfer to app=newApp)
-            EntityManagementUtils.collapseSpec(oldApp, app);
-        } else {
-            app.configure(EntityManagementUtils.WRAPPER_APP_MARKER, Boolean.TRUE);
-        }
-
-        return app;
-    }
-
-    private AssemblyTemplate buildWrapperAppTemplate(AssemblyTemplate template) {
-        Builder<? extends AssemblyTemplate> builder = AssemblyTemplate.builder();
-        builder.type("brooklyn:" + BasicApplicationImpl.class.getName());
-        builder.id(template.getId());
-        builder.name(template.getName());
-        builder.sourceCode(template.getSourceCode());
-        for (Entry<String, Object> entry : template.getCustomAttributes().entrySet()) {
-            builder.customAttribute(entry.getKey(), entry.getValue());
-        }
-        builder.instantiator(template.getInstantiator());
-        AssemblyTemplate wrapTemplate = builder.build();
-        return wrapTemplate;
-    }
-
-    protected boolean shouldUnwrap(AssemblyTemplate template, EntitySpec<? extends Application> app) {
-        Object leaveWrapped = template.getCustomAttributes().get(NEVER_UNWRAP_APPS_PROPERTY);
-        if (leaveWrapped!=null) {
-            if (TypeCoercions.coerce(leaveWrapped, Boolean.class))
-                return false;
-        }
-
-        if (app.getChildren().size()!=1)
-            return false;
-
-        EntitySpec<?> childSpec = Iterables.getOnlyElement(app.getChildren());
-        if (childSpec.getType()==null || !Application.class.isAssignableFrom(childSpec.getType()))
-            return false;
-
-        return EntityManagementUtils.hasNoNameOrCustomKeysOrRoot(template, app);
-    }
-
-    private List<EntitySpec<?>> buildTemplateServicesAsSpecs(BrooklynClassLoadingContext loader, AssemblyTemplate template, CampPlatform platform) {
-        return buildTemplateServicesAsSpecsImpl(loader, template, platform, Sets.<String>newLinkedHashSet());
-    }
-
-    private List<EntitySpec<?>> buildTemplateServicesAsSpecsImpl(BrooklynClassLoadingContext loader, AssemblyTemplate template, CampPlatform platform, Set<String> encounteredCatalogTypes) {
-        List<EntitySpec<?>> result = Lists.newArrayList();
-
-        for (ResolvableLink<PlatformComponentTemplate> ctl: template.getPlatformComponentTemplates().links()) {
-            PlatformComponentTemplate appChildComponentTemplate = ctl.resolve();
-            BrooklynComponentTemplateResolver entityResolver = BrooklynComponentTemplateResolver.Factory.newInstance(loader, appChildComponentTemplate);
-            EntitySpec<?> spec = resolveSpec(ResourceUtils.create(this), entityResolver, encounteredCatalogTypes);
-
-            result.add(spec);
-        }
-        return result;
-    }
-
-    static EntitySpec<?> resolveSpec(ResourceUtils ru,
-            BrooklynComponentTemplateResolver entityResolver,
-            Set<String> encounteredCatalogTypes) {
-        String brooklynType = entityResolver.getServiceTypeResolver().getBrooklynType(entityResolver.getDeclaredType());
-        CatalogItem<Entity, EntitySpec<?>> item = entityResolver.getServiceTypeResolver().getCatalogItem(entityResolver, entityResolver.getDeclaredType());
-
-        if (log.isTraceEnabled()) log.trace("Building CAMP template services: type="+brooklynType+"; item="+item+"; loader="+entityResolver.getLoader()+"; encounteredCatalogTypes="+encounteredCatalogTypes);
-
-        EntitySpec<?> spec = null;
-        String protocol = Urls.getProtocol(brooklynType);
-        if (protocol != null) {
-            if (BrooklynCampConstants.YAML_URL_PROTOCOL_WHITELIST.contains(protocol)) {
-                spec = tryResolveYamlUrlReferenceSpec(ru, brooklynType, entityResolver.getLoader(), encounteredCatalogTypes);
-                if (spec != null) {
-                    entityResolver.populateSpec(spec);
-                }
-            } else {
-                // TODO support https above
-                // TODO this will probably be logged if we refer to  chef:cookbook  or other service types which BCTR accepts;
-                // better would be to have BCTR supporting the calls above
-                log.debug("The reference " + brooklynType + " looks like a URL (running the CAMP Brooklyn assembly-template instantiator) but the protocol " +
-                        protocol + " isn't white listed (" + BrooklynCampConstants.YAML_URL_PROTOCOL_WHITELIST + "). " +
-                        "Will try to load it as catalog item or java type.");
-            }
-        }
-
-        if (spec == null) {
-            // load from java or yaml
-            spec = entityResolver.resolveSpec(encounteredCatalogTypes);
-        }
-
-        return spec;
-    }
-
-    private static EntitySpec<?> tryResolveYamlUrlReferenceSpec(
-            ResourceUtils ru,
-            String brooklynType, BrooklynClassLoadingContext itemLoader,
-            Set<String> encounteredCatalogTypes) {
-        ManagementContext mgmt = itemLoader.getManagementContext();
-        Reader yaml;
-        try {
-            yaml = new InputStreamReader(ru.getResourceFromUrl(brooklynType), "UTF-8");
-        } catch (Exception e) {
-            log.warn("AssemblyTemplate type " + brooklynType + " which looks like a URL can't be fetched.", e);
-            return null;
-        }
-        try {
-            return createNestedSpec(mgmt, encounteredCatalogTypes, yaml, itemLoader);
-        } finally {
-            try {
-                yaml.close();
-            } catch (IOException e) {
-                throw Exceptions.propagate(e);
-            }
-        }
-    }
-
-    static EntitySpec<?> resolveCatalogYamlReferenceSpec(
-            ManagementContext mgmt,
-            CatalogItem<Entity, EntitySpec<?>> item,
-            Set<String> encounteredCatalogTypes) {
-
-        String yaml = item.getPlanYaml();
-        Reader input = new StringReader(yaml);
-        BrooklynClassLoadingContext itemLoader = CatalogUtils.newClassLoadingContext(mgmt, item);
-
-        return createNestedSpec(mgmt, encounteredCatalogTypes, input, itemLoader);
-    }
-
-    private static EntitySpec<?> createNestedSpec(ManagementContext mgmt,
-            Set<String> encounteredCatalogTypes, Reader input,
-            BrooklynClassLoadingContext itemLoader) {
-        CampPlatform platform = BrooklynServerConfig.getCampPlatform(mgmt).get();
-
-        AssemblyTemplate at;
-        BrooklynLoaderTracker.setLoader(itemLoader);
-        try {
-            at = platform.pdp().registerDeploymentPlan(input);
-        } finally {
-            BrooklynLoaderTracker.unsetLoader(itemLoader);
-        }
-        return createNestedSpecStatic(at, platform, itemLoader, encounteredCatalogTypes);
-    }
-
-    @Override
-    public EntitySpec<?> createNestedSpec(
-            AssemblyTemplate template,
-            CampPlatform platform,
-            BrooklynClassLoadingContext itemLoader,
-            Set<String> encounteredCatalogTypes) {
-        return createNestedSpecStatic(template, platform, itemLoader, encounteredCatalogTypes);
-    }
-    
-    private static EntitySpec<?> createNestedSpecStatic(
-        AssemblyTemplate template,
-        CampPlatform platform,
-        BrooklynClassLoadingContext itemLoader,
-        Set<String> encounteredCatalogTypes) {
-        // In case we want to allow multiple top-level entities in a catalog we need to think
-        // about what it would mean to subsequently call buildChildrenEntitySpecs on the list of top-level entities!
-        try {
-            AssemblyTemplateInstantiator ati = template.getInstantiator().newInstance();
-            if (ati instanceof BrooklynAssemblyTemplateInstantiator) {
-                List<EntitySpec<?>> specs = ((BrooklynAssemblyTemplateInstantiator)ati).buildTemplateServicesAsSpecsImpl(itemLoader, template, platform, encounteredCatalogTypes);
-                if (specs.size() > 1) {
-                    throw new UnsupportedOperationException("Only supporting single service in catalog item currently: got "+specs);
-                }
-                return specs.get(0);
-            } else {
-                throw new IllegalStateException("Cannot create application with instantiator: " + ati);
-            }
-        } catch (Exception e) {
-            throw Exceptions.propagate(e);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
deleted file mode 100644
index ef5b506..0000000
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
+++ /dev/null
@@ -1,491 +0,0 @@
-/*
- * 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.
- */
-package io.brooklyn.camp.brooklyn.spi.creation;
-
-import io.brooklyn.camp.brooklyn.BrooklynCampConstants;
-import io.brooklyn.camp.brooklyn.BrooklynCampReservedKeys;
-import io.brooklyn.camp.brooklyn.spi.creation.service.BrooklynServiceTypeResolver;
-import io.brooklyn.camp.brooklyn.spi.creation.service.ServiceTypeResolver;
-import io.brooklyn.camp.spi.AbstractResource;
-import io.brooklyn.camp.spi.ApplicationComponentTemplate;
-import io.brooklyn.camp.spi.AssemblyTemplate;
-import io.brooklyn.camp.spi.PlatformComponentTemplate;
-
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.ServiceLoader;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.annotation.Nullable;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.brooklyn.catalog.CatalogItem;
-import brooklyn.catalog.internal.CatalogUtils;
-import brooklyn.config.ConfigKey;
-import brooklyn.entity.Application;
-import brooklyn.entity.Entity;
-import brooklyn.entity.basic.AbstractEntity;
-import brooklyn.entity.basic.BrooklynTags;
-import brooklyn.entity.basic.BrooklynTaskTags;
-import brooklyn.entity.basic.ConfigKeys;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.entity.proxying.InternalEntityFactory;
-import brooklyn.location.Location;
-import brooklyn.management.ManagementContext;
-import brooklyn.management.ManagementContextInjectable;
-import brooklyn.management.classloading.BrooklynClassLoadingContext;
-import brooklyn.management.classloading.JavaBrooklynClassLoadingContext;
-import brooklyn.management.internal.ManagementContextInternal;
-import brooklyn.util.ResourceUtils;
-import brooklyn.util.collections.MutableList;
-import brooklyn.util.collections.MutableSet;
-import brooklyn.util.config.ConfigBag;
-import brooklyn.util.flags.FlagUtils;
-import brooklyn.util.flags.FlagUtils.FlagConfigKeyAndValueRecord;
-import brooklyn.util.guava.Maybe;
-import brooklyn.util.javalang.Reflections;
-import brooklyn.util.task.Tasks;
-import brooklyn.util.text.Strings;
-
-import com.google.common.base.Function;
-import com.google.common.base.Splitter;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Maps;
-
-/**
- * This generates instances of a template resolver that use a {@link ServiceTypeResolver}
- * to parse the {@code serviceType} line in the template.
- */
-public class BrooklynComponentTemplateResolver {
-
-    private static final Logger log = LoggerFactory.getLogger(BrooklynComponentTemplateResolver.class);
-
-    private final BrooklynClassLoadingContext loader;
-    private final ManagementContext mgmt;
-    private final ConfigBag attrs;
-    private final Maybe<AbstractResource> template;
-    private final BrooklynYamlTypeInstantiator.Factory yamlLoader;
-    private final String type;
-    private final ServiceTypeResolver typeResolver;
-    private final AtomicBoolean alreadyBuilt = new AtomicBoolean(false);
-
-    public BrooklynComponentTemplateResolver(BrooklynClassLoadingContext loader, ConfigBag attrs, AbstractResource optionalTemplate, String type, ServiceTypeResolver typeResolver) {
-        this.loader = loader;
-        this.mgmt = loader.getManagementContext();
-        this.attrs = ConfigBag.newInstanceCopying(attrs);
-        this.template = Maybe.fromNullable(optionalTemplate);
-        this.yamlLoader = new BrooklynYamlTypeInstantiator.Factory(loader, this);
-        this.type = type;
-        this.typeResolver = typeResolver;
-    }
-
-    public BrooklynClassLoadingContext getLoader() { return loader; }
-    public ManagementContext getManagementContext() { return mgmt; }
-    public ConfigBag getAttrs() { return attrs; }
-    public Maybe<AbstractResource> getTemplate() { return template; }
-    public BrooklynYamlTypeInstantiator.Factory getYamlLoader() { return yamlLoader; }
-    public ServiceTypeResolver getServiceTypeResolver() { return typeResolver; }
-    public String getDeclaredType() { return type; }
-    public Boolean isAlreadyBuilt() { return alreadyBuilt.get(); }
-
-    public static class Factory {
-
-        /** returns resolver type based on the service type, inspecting the arguments in order to determine the service type */
-        private static ServiceTypeResolver computeResolverType(BrooklynClassLoadingContext context, String knownServiceType, AbstractResource optionalTemplate, ConfigBag attrs) {
-            String type = getDeclaredType(knownServiceType, optionalTemplate, attrs);
-            return findService(context, type);
-        }
-
-        // TODO This could be extended to support multiple prefixes per resolver and a 'best-match' algorithm
-        protected static ServiceTypeResolver findService(BrooklynClassLoadingContext context, String type) {
-            if (type.indexOf(':') != -1) {
-                String prefix = Splitter.on(":").splitToList(type).get(0);
-                ServiceLoader<ServiceTypeResolver> loader = ServiceLoader.load(ServiceTypeResolver.class,
-                        context.getManagementContext().getCatalogClassLoader());
-                for (ServiceTypeResolver resolver : loader) {
-                   if (prefix.equals(resolver.getTypePrefix())) {
-                       return resolver;
-                   }
-                }
-            }
-            return null;
-        }
-
-        public static BrooklynComponentTemplateResolver newInstance(BrooklynClassLoadingContext context, Map<String, ?> childAttrs) {
-            return newInstance(context, ConfigBag.newInstance(childAttrs), null);
-        }
-
-        public static BrooklynComponentTemplateResolver newInstance(BrooklynClassLoadingContext context, AbstractResource template) {
-            return newInstance(context, ConfigBag.newInstance(template.getCustomAttributes()), template);
-        }
-
-        public static BrooklynComponentTemplateResolver newInstance(BrooklynClassLoadingContext context, String serviceType) {
-            return newInstance(context, ConfigBag.newInstance().configureStringKey("serviceType", serviceType), null);
-        }
-
-        private static BrooklynComponentTemplateResolver newInstance(BrooklynClassLoadingContext context, ConfigBag attrs, AbstractResource optionalTemplate) {
-            ServiceTypeResolver typeResolver = computeResolverType(context, null, optionalTemplate, attrs);
-            String type = getDeclaredType(null, optionalTemplate, attrs);
-            if (typeResolver == null) // use default
-                typeResolver = new BrooklynServiceTypeResolver();
-            return new BrooklynComponentTemplateResolver(context, attrs, optionalTemplate, type, typeResolver);
-        }
-
-        public static String getDeclaredType(String knownServiceType, AbstractResource optionalTemplate, @Nullable ConfigBag attrs) {
-            String type = knownServiceType;
-            if (type==null && optionalTemplate!=null) {
-                type = optionalTemplate.getType();
-                if (type.equals(AssemblyTemplate.CAMP_TYPE) || type.equals(PlatformComponentTemplate.CAMP_TYPE) || type.equals(ApplicationComponentTemplate.CAMP_TYPE))
-                    // ignore these values for the type; only subclasses are interesting
-                    type = null;
-            }
-            if (type==null) type = extractServiceTypeAttribute(attrs);
-            return type;
-        }
-
-        private static String extractServiceTypeAttribute(@Nullable ConfigBag attrs) {
-            return BrooklynYamlTypeInstantiator.InstantiatorFromKey.extractTypeName("service", attrs).orNull();
-        }
-
-        public static boolean supportsType(BrooklynClassLoadingContext context, String serviceType) {
-            ServiceTypeResolver typeResolver = computeResolverType(context, serviceType, null, null);
-            if (typeResolver != null) return true;
-            return newInstance(context, serviceType).canResolve();
-        }
-    }
-
-    protected boolean canResolve() {
-        if (typeResolver.getCatalogItem(this, type)!=null)
-            return true;
-        if (loader.tryLoadClass(getJavaType(), Entity.class).isPresent())
-            return true;
-        return false;
-    }
-
-    /** returns the entity class, if needed in contexts which scan its statics for example */
-    protected Class<? extends Entity> loadEntityClass() {
-        Maybe<Class<? extends Entity>> result = tryLoadEntityClass();
-        if (result.isAbsent())
-            throw new IllegalStateException("Could not find "+typeResolver.getBrooklynType(type), ((Maybe.Absent<?>)result).getException());
-        return result.get();
-    }
-
-    /** tries to load the Java entity class */
-    protected Maybe<Class<? extends Entity>> tryLoadEntityClass() {
-        return loader.tryLoadClass(getJavaType(), Entity.class);
-    }
-
-    // TODO Generalise to have other prefixes (e.g. explicit "catalog:" etc)?
-    protected boolean isJavaTypePrefix() {
-        return type != null && (type.toLowerCase().startsWith("java:") || type.toLowerCase().startsWith("brooklyn:java:"));
-    }
-
-    protected String getJavaType() {
-        CatalogItem<Entity, EntitySpec<?>> item = typeResolver.getCatalogItem(this, type);
-        if (!isJavaTypePrefix() && item != null && item.getJavaType() != null) {
-            return item.getJavaType();
-        } else {
-            return typeResolver.getBrooklynType(type);
-        }
-    }
-
-    /** resolves the spec, updating the loader if a catalog item is loaded */
-    protected <T extends Entity> EntitySpec<T> resolveSpec(Set<String> encounteredCatalogTypes) {
-        if (alreadyBuilt.getAndSet(true))
-            throw new IllegalStateException("Spec can only be used once: "+this);
-
-        EntitySpec<T> spec = createSpec(encounteredCatalogTypes);
-        populateSpec(spec);
-
-        return spec;
-    }
-
-    @SuppressWarnings({ "unchecked" })
-    protected <T extends Entity> EntitySpec<T> createSpec(Set<String> encounteredCatalogTypes) {
-        CatalogItem<Entity, EntitySpec<?>> item = getServiceTypeResolver().getCatalogItem(this, getDeclaredType());
-        if (encounteredCatalogTypes==null) encounteredCatalogTypes = MutableSet.of();
-        
-        //Take the symoblicName part of the catalog item only for recursion detection to prevent
-        //cross referencing of different versions. Not interested in non-catalog item types.
-        //Prevent catalog items self-referencing even if explicitly different version.
-        boolean firstOccurrence = (item == null || encounteredCatalogTypes.add(item.getSymbolicName()));
-        boolean recursiveButTryJava = !firstOccurrence;
-
-        // Load a java class from current loader if explicit java prefix, or if no item, or if item is legacy / 
-        // old-style catalog item (item != null && item.getJavaType() != null).
-        // Old-style catalog items (can be defined in catalog.xml only) don't have structure, only a single type, so
-        // they are loaded as a simple java type, only taking the class name from the catalog item instead of the
-        // type value in the YAML. Classpath entries in the item are also used (through the catalog root classloader).
-        if (isJavaTypePrefix() || item == null || item.getJavaType() != null) {
-            return createSpecFromJavaType();
-
-        // Same as above case, but this time force java type loading (either as plain class or through an old-style
-        // catalog item, since we have already loaded a class item with the same name as the type value.
-        } else if (recursiveButTryJava) {
-            if (tryLoadEntityClass().isAbsent()) {
-                throw new IllegalStateException("Recursive reference to " + item + " (and cannot be resolved as a Java type)");
-            }
-            return createSpecFromJavaType();
-
-        // Only case that's left is a catalog item with YAML content - try to parse it recursively
-        // including it's OSGi bundles in the loader classpath.
-        } else {
-            // TODO perhaps migrate to catalog.createSpec ?
-            EntitySpec<?> spec = BrooklynAssemblyTemplateInstantiator.resolveCatalogYamlReferenceSpec(mgmt, item, encounteredCatalogTypes);
-            spec.catalogItemId(item.getId());
-            
-            return (EntitySpec<T>)spec;
-        }
-    }
-    
-    @SuppressWarnings("unchecked")
-    protected <T extends Entity> EntitySpec<T> createSpecFromJavaType() {
-        Class<T> type = (Class<T>) loadEntityClass();
-        
-        EntitySpec<T> spec;
-        if (type.isInterface()) {
-            spec = EntitySpec.create(type);
-        } else {
-            // If this is a concrete class, particularly for an Application class, we want the proxy
-            // to expose all interfaces it implements.
-            @SuppressWarnings("rawtypes")
-            Class interfaceclazz = (Application.class.isAssignableFrom(type)) ? Application.class : Entity.class;
-            List<Class<?>> additionalInterfaceClazzes = Reflections.getAllInterfaces(type);
-            spec = EntitySpec.create(interfaceclazz).impl(type).additionalInterfaces(additionalInterfaceClazzes);
-        }
-        spec.catalogItemId(CatalogUtils.getCatalogItemIdFromLoader(loader));
-        if (template.isPresent() && template.get().getSourceCode()!=null)
-            spec.tag(BrooklynTags.newYamlSpecTag(template.get().getSourceCode()));
-
-        return spec;
-    }
-
-    //called from BrooklynAssemblyTemplateInstantiator as well
-    @SuppressWarnings("unchecked")
-    protected <T extends Entity> void populateSpec(EntitySpec<T> spec) {
-        String name, templateId=null, planId=null;
-        if (template.isPresent()) {
-            name = template.get().getName();
-            templateId = template.get().getId();
-        } else {
-            name = (String)attrs.getStringKey("name");
-        }
-        planId = (String)attrs.getStringKey("id");
-        if (planId==null)
-            planId = (String) attrs.getStringKey(BrooklynCampConstants.PLAN_ID_FLAG);
-
-        Object childrenObj = attrs.getStringKey(BrooklynCampReservedKeys.BROOKLYN_CHILDREN);
-        if (childrenObj != null) {
-            // Creating a new set of encounteredCatalogTypes means that this won't check things recursively;
-            // but we are looking at children so we probably *should* be resetting the recursive list we've looked at;
-            // (but see also, a previous comment here which suggested otherwise? - Apr 2015)
-            Set<String> encounteredCatalogTypes = MutableSet.of();
-
-            Iterable<Map<String,?>> children = (Iterable<Map<String,?>>)childrenObj;
-            for (Map<String,?> childAttrs : children) {
-                BrooklynComponentTemplateResolver entityResolver = BrooklynComponentTemplateResolver.Factory.newInstance(loader, childAttrs);
-                EntitySpec<? extends Entity> childSpec = BrooklynAssemblyTemplateInstantiator.resolveSpec(ResourceUtils.create(this), entityResolver, encounteredCatalogTypes);
-                spec.child(childSpec);
-            }
-        }
-        if (!Strings.isBlank(name))
-            spec.displayName(name);
-        if (templateId != null)
-            spec.configure(BrooklynCampConstants.TEMPLATE_ID, templateId);
-        if (planId != null)
-            spec.configure(BrooklynCampConstants.PLAN_ID, planId);
-
-        List<Location> childLocations = new BrooklynYamlLocationResolver(mgmt).resolveLocations(attrs.getAllConfig(), true);
-        if (childLocations != null)
-            spec.locations(childLocations);
-
-        typeResolver.decorateSpec(this, spec);
-        configureEntityConfig(spec);
-    }
-
-    /** returns new *uninitialised* entity, with just a few of the pieces from the spec;
-     * initialisation occurs soon after, in {@link #initEntity(ManagementContext, Entity, EntitySpec)},
-     * inside an execution context and after entity ID's are recognised
-     */
-    protected <T extends Entity> T newEntity(EntitySpec<T> spec) {
-        Class<? extends T> entityImpl = (spec.getImplementation() != null) ? spec.getImplementation() : mgmt.getEntityManager().getEntityTypeRegistry().getImplementedBy(spec.getType());
-        InternalEntityFactory entityFactory = ((ManagementContextInternal)mgmt).getEntityFactory();
-        T entity = entityFactory.constructEntity(entityImpl, spec);
-
-        String planId = (String)spec.getConfig().get(BrooklynCampConstants.PLAN_ID);
-        if (planId != null) {
-            entity.config().set(BrooklynCampConstants.PLAN_ID, planId);
-        }
-
-        if (spec.getLocations().size() > 0) {
-            ((AbstractEntity)entity).addLocations(spec.getLocations());
-        }
-
-        if (spec.getParent() != null) entity.setParent(spec.getParent());
-
-        return entity;
-    }
-
-    @SuppressWarnings({ "unchecked", "rawtypes" })
-    protected void configureEntityConfig(EntitySpec<?> spec) {
-        // first take *recognised* flags and config keys from the top-level, and put them in the bag (of brooklyn.config)
-        // attrs will contain only brooklyn.xxx properties when coming from BrooklynEntityMatcher.
-        // Any top-level flags will go into "brooklyn.flags". When resolving a spec from $brooklyn:entitySpec
-        // top level flags remain in place. Have to support both cases.
-
-        ConfigBag bag = ConfigBag.newInstance((Map<Object, Object>) attrs.getStringKey(BrooklynCampReservedKeys.BROOKLYN_CONFIG));
-        ConfigBag bagFlags = ConfigBag.newInstanceCopying(attrs);
-        if (attrs.containsKey(BrooklynCampReservedKeys.BROOKLYN_FLAGS)) {
-            bagFlags.putAll((Map<String, Object>) attrs.getStringKey(BrooklynCampReservedKeys.BROOKLYN_FLAGS));
-        }
-
-        Collection<FlagConfigKeyAndValueRecord> topLevelApparentConfig = findAllFlagsAndConfigKeys(spec, bagFlags);
-        for (FlagConfigKeyAndValueRecord r: topLevelApparentConfig) {
-            if (r.getConfigKeyMaybeValue().isPresent())
-                bag.putIfAbsent((ConfigKey)r.getConfigKey(), r.getConfigKeyMaybeValue().get());
-            if (r.getFlagMaybeValue().isPresent())
-                bag.putAsStringKeyIfAbsent(r.getFlagName(), r.getFlagMaybeValue().get());
-        }
-
-        // now set configuration for all the items in the bag
-        Collection<FlagConfigKeyAndValueRecord> records = findAllFlagsAndConfigKeys(spec, bag);
-        Set<String> keyNamesUsed = new LinkedHashSet<String>();
-        for (FlagConfigKeyAndValueRecord r: records) {
-            if (r.getFlagMaybeValue().isPresent()) {
-                Object transformed = new SpecialFlagsTransformer(loader).transformSpecialFlags(r.getFlagMaybeValue().get());
-                spec.configure(r.getFlagName(), transformed);
-                keyNamesUsed.add(r.getFlagName());
-            }
-            if (r.getConfigKeyMaybeValue().isPresent()) {
-                Object transformed = new SpecialFlagsTransformer(loader).transformSpecialFlags(r.getConfigKeyMaybeValue().get());
-                spec.configure((ConfigKey<Object>)r.getConfigKey(), transformed);
-                keyNamesUsed.add(r.getConfigKey().getName());
-            }
-        }
-
-        // set unused keys as anonymous config keys -
-        // they aren't flags or known config keys, so must be passed as config keys in order for
-        // EntitySpec to know what to do with them (as they are passed to the spec as flags)
-        for (String key: MutableSet.copyOf(bag.getUnusedConfig().keySet())) {
-            // we don't let a flag with the same name as a config key override the config key
-            // (that's why we check whether it is used)
-            if (!keyNamesUsed.contains(key)) {
-                Object transformed = new SpecialFlagsTransformer(loader).transformSpecialFlags(bag.getStringKey(key));
-                spec.configure(ConfigKeys.newConfigKey(Object.class, key.toString()), transformed);
-            }
-        }
-    }
-
-    /**
-     * Searches for config keys in the type, additional interfaces and the implementation (if specified)
-     */
-    private Collection<FlagConfigKeyAndValueRecord> findAllFlagsAndConfigKeys(EntitySpec<?> spec, ConfigBag bagFlags) {
-        Set<FlagConfigKeyAndValueRecord> allKeys = MutableSet.of();
-        allKeys.addAll(FlagUtils.findAllFlagsAndConfigKeys(null, spec.getType(), bagFlags));
-        if (spec.getImplementation() != null) {
-            allKeys.addAll(FlagUtils.findAllFlagsAndConfigKeys(null, spec.getImplementation(), bagFlags));
-        }
-        for (Class<?> iface : spec.getAdditionalInterfaces()) {
-            allKeys.addAll(FlagUtils.findAllFlagsAndConfigKeys(null, iface, bagFlags));
-        }
-        return allKeys;
-    }
-
-    protected static class SpecialFlagsTransformer implements Function<Object, Object> {
-        protected final ManagementContext mgmt;
-        /* TODO find a way to make do without loader here?
-         * it is not very nice having to serialize it; but serialization of BLCL is now relatively clean.
-         *
-         * it is only used to instantiate classes, and now most things should be registered with catalog;
-         * the notable exception is when one entity in a bundle is creating another in the same bundle,
-         * it wants to use his bundle CLC to do that.  but we can set up some unique reference to the entity
-         * which can be used to find it from mgmt, rather than pass the loader.
-         */
-        private BrooklynClassLoadingContext loader = null;
-
-        public SpecialFlagsTransformer(BrooklynClassLoadingContext loader) {
-            this.loader = loader;
-            mgmt = loader.getManagementContext();
-        }
-        public Object apply(Object input) {
-            if (input instanceof Map)
-                return transformSpecialFlags((Map<?, ?>)input);
-            else if (input instanceof Set<?>)
-                return MutableSet.of(transformSpecialFlags((Iterable<?>)input));
-            else if (input instanceof List<?>)
-                return MutableList.copyOf(transformSpecialFlags((Iterable<?>)input));
-            else if (input instanceof Iterable<?>)
-                return transformSpecialFlags((Iterable<?>)input);
-            else
-                return transformSpecialFlags((Object)input);
-        }
-
-        protected Map<?, ?> transformSpecialFlags(Map<?, ?> flag) {
-            return Maps.transformValues(flag, this);
-        }
-
-        protected Iterable<?> transformSpecialFlags(Iterable<?> flag) {
-            return Iterables.transform(flag, this);
-        }
-
-        protected BrooklynClassLoadingContext getLoader() {
-            if (loader!=null) return loader;
-            // TODO currently loader will non-null unless someone has messed with the rebind files,
-            // but we'd like to get rid of it; ideally we'd have a reference to the entity.
-            // for now, this is a slightly naff way to do it, if we have to set loader=null as a workaround
-            Entity entity = BrooklynTaskTags.getTargetOrContextEntity(Tasks.current());
-            if (entity!=null) return CatalogUtils.getClassLoadingContext(entity);
-            return JavaBrooklynClassLoadingContext.create(mgmt);
-        }
-
-        /**
-         * Makes additional transformations to the given flag with the extra knowledge of the flag's management context.
-         * @return The modified flag, or the flag unchanged.
-         */
-        protected Object transformSpecialFlags(Object flag) {
-            if (flag instanceof EntitySpecConfiguration) {
-                EntitySpecConfiguration specConfig = (EntitySpecConfiguration) flag;
-                // TODO: This should called from BrooklynAssemblyTemplateInstantiator.configureEntityConfig
-                // And have transformSpecialFlags(Object flag, ManagementContext mgmt) drill into the Object flag if it's a map or iterable?
-                @SuppressWarnings("unchecked")
-                Map<String, Object> resolvedConfig = (Map<String, Object>)transformSpecialFlags(specConfig.getSpecConfiguration());
-                specConfig.setSpecConfiguration(resolvedConfig);
-                return Factory.newInstance(getLoader(), specConfig.getSpecConfiguration()).resolveSpec(null);
-            }
-            if (flag instanceof ManagementContextInjectable) {
-                log.debug("Injecting Brooklyn management context info object: {}", flag);
-                ((ManagementContextInjectable) flag).injectManagementContext(loader.getManagementContext());
-            }
-
-            return flag;
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    protected List<Map<String, Object>> getChildren(Map<String, Object> attrs) {
-        if (attrs==null) return null;
-        return (List<Map<String, Object>>) attrs.get(BrooklynCampReservedKeys.BROOKLYN_CHILDREN);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e406d1ad/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynEntityDecorationResolver.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynEntityDecorationResolver.java b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynEntityDecorationResolver.java
deleted file mode 100644
index 7c1decc..0000000
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynEntityDecorationResolver.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * 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.
- */
-package io.brooklyn.camp.brooklyn.spi.creation;
-
-import io.brooklyn.camp.brooklyn.BrooklynCampReservedKeys;
-import io.brooklyn.camp.brooklyn.spi.creation.BrooklynYamlTypeInstantiator.InstantiatorFromKey;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.brooklyn.catalog.BrooklynCatalog;
-import org.apache.brooklyn.catalog.CatalogItem;
-import brooklyn.catalog.internal.CatalogUtils;
-import brooklyn.entity.proxying.EntityInitializer;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.management.ManagementContext;
-import brooklyn.policy.Enricher;
-import brooklyn.policy.EnricherSpec;
-import brooklyn.policy.Policy;
-import brooklyn.policy.PolicySpec;
-import brooklyn.util.collections.MutableList;
-import brooklyn.util.config.ConfigBag;
-
-import com.google.common.annotations.Beta;
-
-/**
- * Pattern for resolving "decorations" on service specs / entity specs, such as policies, enrichers, etc.
- * @since 0.7.0
- */
-@Beta
-public abstract class BrooklynEntityDecorationResolver<DT> {
-
-    public final BrooklynYamlTypeInstantiator.Factory instantiator;
-    
-    protected BrooklynEntityDecorationResolver(BrooklynYamlTypeInstantiator.Factory instantiator) {
-        this.instantiator = instantiator;
-    }
-    
-    public abstract void decorate(EntitySpec<?> entitySpec, ConfigBag attrs);
-
-    protected Iterable<? extends DT> buildListOfTheseDecorationsFromEntityAttributes(ConfigBag attrs) {
-        Object value = getDecorationAttributeJsonValue(attrs); 
-        List<DT> decorations = MutableList.of();
-        if (value==null) return decorations;
-        if (value instanceof Iterable) {
-            for (Object decorationJson: (Iterable<?>)value)
-                addDecorationFromJsonMap(checkIsMap(decorationJson), decorations);
-        } else {
-            // in future may support types other than iterables here, 
-            // e.g. a map short form where the key is the type
-            throw new IllegalArgumentException(getDecorationKind()+" body should be iterable, not " + value.getClass());
-        }
-        return decorations;
-    }
-    
-    protected Map<?,?> checkIsMap(Object decorationJson) {
-        if (!(decorationJson instanceof Map))
-            throw new IllegalArgumentException(getDecorationKind()+" value must be a Map, not " + 
-                (decorationJson==null ? null : decorationJson.getClass()) );
-        return (Map<?,?>) decorationJson;
-    }
-
-    protected abstract String getDecorationKind();
-    protected abstract Object getDecorationAttributeJsonValue(ConfigBag attrs);
-    
-    /** creates and adds decorations from the given json to the given collection; 
-     * default impl requires a map and calls {@link #addDecorationFromJsonMap(Map, List)} */
-    protected void addDecorationFromJson(Object decorationJson, List<DT> decorations) {
-        addDecorationFromJsonMap(checkIsMap(decorationJson), decorations);
-    }
-    protected abstract void addDecorationFromJsonMap(Map<?,?> decorationJson, List<DT> decorations);
-    
-
-    public static class PolicySpecResolver extends BrooklynEntityDecorationResolver<PolicySpec<?>> {
-        
-        public PolicySpecResolver(BrooklynYamlTypeInstantiator.Factory loader) { super(loader); }
-        @Override protected String getDecorationKind() { return "Policy"; }
-
-        @Override
-        public void decorate(EntitySpec<?> entitySpec, ConfigBag attrs) {
-            entitySpec.policySpecs(buildListOfTheseDecorationsFromEntityAttributes(attrs));
-        }
-        
-        @Override
-        protected Object getDecorationAttributeJsonValue(ConfigBag attrs) {
-            return attrs.getStringKey(BrooklynCampReservedKeys.BROOKLYN_POLICIES);
-        }
-
-        @Override
-        @SuppressWarnings("unchecked")
-        protected void addDecorationFromJsonMap(Map<?, ?> decorationJson, List<PolicySpec<?>> decorations) {
-            InstantiatorFromKey decoLoader = instantiator.from(decorationJson).prefix("policy");
-
-            String policyType = decoLoader.getTypeName().get();
-            ManagementContext mgmt = instantiator.loader.getManagementContext();
-            BrooklynCatalog catalog = mgmt.getCatalog();
-            CatalogItem<?, ?> item = getPolicyCatalogItem(catalog, policyType);
-            PolicySpec<? extends Policy> spec;
-            if (item != null) {
-                spec = (PolicySpec<? extends Policy>) catalog.createSpec(item);
-                spec.configure(decoLoader.getConfigMap());
-            } else {
-                // this pattern of creating a spec could be simplified with a "Configurable" superinterface on *Spec  
-                spec = PolicySpec.create(decoLoader.getType(Policy.class))
-                    .configure( decoLoader.getConfigMap() );
-            }
-            decorations.add(spec);
-        }
-        private CatalogItem<?, ?> getPolicyCatalogItem(BrooklynCatalog catalog, String policyType) {
-            if (CatalogUtils.looksLikeVersionedId(policyType)) {
-                String id = CatalogUtils.getIdFromVersionedId(policyType);
-                String version = CatalogUtils.getVersionFromVersionedId(policyType);
-                return catalog.getCatalogItem(id, version);
-            } else {
-                return catalog.getCatalogItem(policyType, BrooklynCatalog.DEFAULT_VERSION);
-            }
-        }
-    }
-
-    public static class EnricherSpecResolver extends BrooklynEntityDecorationResolver<EnricherSpec<?>> {
-        
-        public EnricherSpecResolver(BrooklynYamlTypeInstantiator.Factory loader) { super(loader); }
-        @Override protected String getDecorationKind() { return "Enricher"; }
-
-        @Override
-        public void decorate(EntitySpec<?> entitySpec, ConfigBag attrs) {
-            entitySpec.enricherSpecs(buildListOfTheseDecorationsFromEntityAttributes(attrs));
-        }
-        
-        @Override
-        protected Object getDecorationAttributeJsonValue(ConfigBag attrs) {
-            return attrs.getStringKey(BrooklynCampReservedKeys.BROOKLYN_ENRICHERS);
-        }
-
-        @Override
-        protected void addDecorationFromJsonMap(Map<?, ?> decorationJson, List<EnricherSpec<?>> decorations) {
-            InstantiatorFromKey decoLoader = instantiator.from(decorationJson).prefix("enricher");
-            decorations.add(EnricherSpec.create(decoLoader.getType(Enricher.class))
-                .configure( decoLoader.getConfigMap() ));
-        }
-    }
-    
-    public static class InitializerResolver extends BrooklynEntityDecorationResolver<EntityInitializer> {
-        
-        public InitializerResolver(BrooklynYamlTypeInstantiator.Factory loader) { super(loader); }
-        @Override protected String getDecorationKind() { return "Entity initializer"; }
-
-        @Override
-        public void decorate(EntitySpec<?> entitySpec, ConfigBag attrs) {
-            entitySpec.addInitializers(buildListOfTheseDecorationsFromEntityAttributes(attrs));
-        }
-        
-        @Override
-        protected Object getDecorationAttributeJsonValue(ConfigBag attrs) {
-            return attrs.getStringKey(BrooklynCampReservedKeys.BROOKLYN_INITIALIZERS);
-        }
-
-        @Override
-        protected void addDecorationFromJsonMap(Map<?, ?> decorationJson, List<EntityInitializer> decorations) {
-            decorations.add(instantiator.from(decorationJson).prefix("initializer").newInstance(EntityInitializer.class));
-        }
-    }
-    
-
-}


Mime
View raw message