BROOKLYN-162 convert camp-base and camp-server to org.apache prefix
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/7d782f34 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/7d782f34 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/7d782f34 Branch: refs/heads/master Commit: 7d782f34ae8fed8c3753f3f637265374af063abb Parents: f092e18 Author: Alex Heneveld <[email protected]> Authored: Tue Aug 18 12:40:46 2015 +0100 Committer: Alex Heneveld <[email protected]> Committed: Tue Aug 18 12:40:46 2015 +0100 ---------------------------------------------------------------------- .../brooklyn/camp/AggregatingCampPlatform.java | 131 --------- .../io/brooklyn/camp/BasicCampPlatform.java | 143 ---------- .../java/io/brooklyn/camp/CampPlatform.java | 76 ------ .../camp/commontypes/RepresentationSkew.java | 23 -- .../io/brooklyn/camp/spi/AbstractResource.java | 197 -------------- .../brooklyn/camp/spi/ApplicationComponent.java | 93 ------- .../camp/spi/ApplicationComponentTemplate.java | 54 ---- .../java/io/brooklyn/camp/spi/Assembly.java | 109 -------- .../io/brooklyn/camp/spi/AssemblyTemplate.java | 118 --------- .../main/java/io/brooklyn/camp/spi/Link.java | 40 --- .../io/brooklyn/camp/spi/PlatformComponent.java | 101 ------- .../camp/spi/PlatformComponentTemplate.java | 52 ---- .../brooklyn/camp/spi/PlatformRootSummary.java | 70 ----- .../brooklyn/camp/spi/PlatformTransaction.java | 46 ---- .../spi/collection/AbstractResourceLookup.java | 35 --- .../collection/AggregatingResourceLookup.java | 56 ---- .../spi/collection/BasicResourceLookup.java | 71 ----- .../camp/spi/collection/ResolvableLink.java | 37 --- .../camp/spi/collection/ResourceLookup.java | 47 ---- .../AssemblyTemplateInstantiator.java | 30 --- .../BasicAssemblyTemplateInstantiator.java | 36 --- .../java/io/brooklyn/camp/spi/pdp/Artifact.java | 99 ------- .../brooklyn/camp/spi/pdp/ArtifactContent.java | 65 ----- .../camp/spi/pdp/ArtifactRequirement.java | 72 ----- .../spi/pdp/AssemblyTemplateConstructor.java | 100 ------- .../brooklyn/camp/spi/pdp/DeploymentPlan.java | 150 ----------- .../java/io/brooklyn/camp/spi/pdp/Service.java | 94 ------- .../camp/spi/pdp/ServiceCharacteristic.java | 72 ----- .../brooklyn/camp/spi/resolve/PdpMatcher.java | 51 ---- .../brooklyn/camp/spi/resolve/PdpProcessor.java | 188 ------------- .../camp/spi/resolve/PlanInterpreter.java | 113 -------- .../interpret/PlanInterpretationContext.java | 152 ----------- .../interpret/PlanInterpretationNode.java | 263 ------------------- .../main/java/io/brooklyn/util/yaml/Yamls.java | 24 -- .../brooklyn/camp/AggregatingCampPlatform.java | 130 +++++++++ .../apache/brooklyn/camp/BasicCampPlatform.java | 142 ++++++++++ .../org/apache/brooklyn/camp/CampPlatform.java | 76 ++++++ .../camp/commontypes/RepresentationSkew.java | 23 ++ .../brooklyn/camp/spi/AbstractResource.java | 197 ++++++++++++++ .../brooklyn/camp/spi/ApplicationComponent.java | 93 +++++++ .../camp/spi/ApplicationComponentTemplate.java | 54 ++++ .../org/apache/brooklyn/camp/spi/Assembly.java | 109 ++++++++ .../brooklyn/camp/spi/AssemblyTemplate.java | 118 +++++++++ .../java/org/apache/brooklyn/camp/spi/Link.java | 40 +++ .../brooklyn/camp/spi/PlatformComponent.java | 101 +++++++ .../camp/spi/PlatformComponentTemplate.java | 52 ++++ .../brooklyn/camp/spi/PlatformRootSummary.java | 70 +++++ .../brooklyn/camp/spi/PlatformTransaction.java | 46 ++++ .../spi/collection/AbstractResourceLookup.java | 35 +++ .../collection/AggregatingResourceLookup.java | 56 ++++ .../spi/collection/BasicResourceLookup.java | 71 +++++ .../camp/spi/collection/ResolvableLink.java | 37 +++ .../camp/spi/collection/ResourceLookup.java | 47 ++++ .../AssemblyTemplateInstantiator.java | 30 +++ .../BasicAssemblyTemplateInstantiator.java | 36 +++ .../apache/brooklyn/camp/spi/pdp/Artifact.java | 99 +++++++ .../brooklyn/camp/spi/pdp/ArtifactContent.java | 65 +++++ .../camp/spi/pdp/ArtifactRequirement.java | 72 +++++ .../spi/pdp/AssemblyTemplateConstructor.java | 100 +++++++ .../brooklyn/camp/spi/pdp/DeploymentPlan.java | 150 +++++++++++ .../apache/brooklyn/camp/spi/pdp/Service.java | 94 +++++++ .../camp/spi/pdp/ServiceCharacteristic.java | 72 +++++ .../brooklyn/camp/spi/resolve/PdpMatcher.java | 51 ++++ .../brooklyn/camp/spi/resolve/PdpProcessor.java | 187 +++++++++++++ .../camp/spi/resolve/PlanInterpreter.java | 113 ++++++++ .../interpret/PlanInterpretationContext.java | 152 +++++++++++ .../interpret/PlanInterpretationNode.java | 262 ++++++++++++++++++ .../apache/brooklyn/camp/util/yaml/Yamls.java | 24 ++ .../pdp/DeploymentPlanToyInterpreterTest.java | 114 -------- .../io/brooklyn/camp/spi/pdp/PdpYamlTest.java | 78 ------ .../web/MockAssemblyTemplateInstantiator.java | 38 --- .../camp/test/mock/web/MockWebPlatform.java | 131 --------- .../test/platform/BasicCampPlatformTest.java | 87 ------ .../pdp/DeploymentPlanToyInterpreterTest.java | 113 ++++++++ .../brooklyn/camp/spi/pdp/PdpYamlTest.java | 80 ++++++ .../web/MockAssemblyTemplateInstantiator.java | 37 +++ .../camp/test/mock/web/MockWebPlatform.java | 132 ++++++++++ .../test/platform/BasicCampPlatformTest.java | 86 ++++++ .../camp/spi/pdp/pdp-single-artifact.yaml | 27 -- .../camp/spi/pdp/pdp-single-service.yaml | 29 -- .../pdp/yaml-sample-toy-interpreter-result.yaml | 22 -- .../spi/pdp/yaml-sample-toy-interpreter.yaml | 28 -- .../camp/spi/pdp/pdp-single-artifact.yaml | 27 ++ .../camp/spi/pdp/pdp-single-service.yaml | 29 ++ .../pdp/yaml-sample-toy-interpreter-result.yaml | 22 ++ .../spi/pdp/yaml-sample-toy-interpreter.yaml | 28 ++ .../io/brooklyn/camp/CampRestResources.java | 70 ----- .../main/java/io/brooklyn/camp/CampServer.java | 185 ------------- .../java/io/brooklyn/camp/dto/ApiErrorDto.java | 119 --------- .../camp/dto/ApplicationComponentDto.java | 72 ----- .../dto/ApplicationComponentTemplateDto.java | 44 ---- .../java/io/brooklyn/camp/dto/AssemblyDto.java | 77 ------ .../brooklyn/camp/dto/AssemblyTemplateDto.java | 72 ----- .../main/java/io/brooklyn/camp/dto/DtoBase.java | 31 --- .../brooklyn/camp/dto/DtoCustomAttributes.java | 66 ----- .../main/java/io/brooklyn/camp/dto/LinkDto.java | 72 ----- .../brooklyn/camp/dto/PlatformComponentDto.java | 82 ------ .../camp/dto/PlatformComponentTemplateDto.java | 44 ---- .../java/io/brooklyn/camp/dto/PlatformDto.java | 131 --------- .../java/io/brooklyn/camp/dto/ResourceDto.java | 112 -------- .../rest/resource/AbstractCampRestResource.java | 56 ---- .../camp/rest/resource/ApidocRestResource.java | 31 --- .../ApplicationComponentRestResource.java | 50 ---- ...pplicationComponentTemplateRestResource.java | 50 ---- .../rest/resource/AssemblyRestResource.java | 52 ---- .../resource/AssemblyTemplateRestResource.java | 88 ------- .../resource/PlatformComponentRestResource.java | 50 ---- .../PlatformComponentTemplateRestResource.java | 50 ---- .../rest/resource/PlatformRestResource.java | 89 ------- .../io/brooklyn/camp/rest/util/CampJsons.java | 39 --- .../camp/rest/util/CampRestContext.java | 50 ---- .../brooklyn/camp/rest/util/CampRestGuavas.java | 32 --- .../io/brooklyn/camp/rest/util/DtoFactory.java | 176 ------------- .../camp/rest/util/WebResourceUtils.java | 60 ----- .../brooklyn/camp/server/dto/ApiErrorDto.java | 119 +++++++++ .../server/dto/ApplicationComponentDto.java | 72 +++++ .../dto/ApplicationComponentTemplateDto.java | 44 ++++ .../brooklyn/camp/server/dto/AssemblyDto.java | 77 ++++++ .../camp/server/dto/AssemblyTemplateDto.java | 72 +++++ .../brooklyn/camp/server/dto/DtoBase.java | 31 +++ .../camp/server/dto/DtoCustomAttributes.java | 66 +++++ .../brooklyn/camp/server/dto/LinkDto.java | 72 +++++ .../camp/server/dto/PlatformComponentDto.java | 82 ++++++ .../dto/PlatformComponentTemplateDto.java | 44 ++++ .../brooklyn/camp/server/dto/PlatformDto.java | 131 +++++++++ .../brooklyn/camp/server/dto/ResourceDto.java | 112 ++++++++ .../camp/server/rest/CampRestResources.java | 69 +++++ .../brooklyn/camp/server/rest/CampServer.java | 185 +++++++++++++ .../rest/resource/AbstractCampRestResource.java | 56 ++++ .../rest/resource/ApidocRestResource.java | 31 +++ .../ApplicationComponentRestResource.java | 49 ++++ ...pplicationComponentTemplateRestResource.java | 49 ++++ .../rest/resource/AssemblyRestResource.java | 51 ++++ .../resource/AssemblyTemplateRestResource.java | 87 ++++++ .../resource/PlatformComponentRestResource.java | 49 ++++ .../PlatformComponentTemplateRestResource.java | 49 ++++ .../rest/resource/PlatformRestResource.java | 87 ++++++ .../camp/server/rest/util/CampJsons.java | 39 +++ .../camp/server/rest/util/CampRestContext.java | 50 ++++ .../camp/server/rest/util/CampRestGuavas.java | 32 +++ .../camp/server/rest/util/DtoFactory.java | 176 +++++++++++++ .../camp/server/rest/util/WebResourceUtils.java | 59 +++++ .../ApplicationCompomentTemplateDtoTest.java | 49 ---- .../java/io/brooklyn/camp/dto/BasicDtoTest.java | 90 ------- .../java/io/brooklyn/camp/dto/LinkDtoTest.java | 62 ----- .../dto/PlatformCompomentTemplateDtoTest.java | 49 ---- .../io/brooklyn/camp/dto/ResourceDtoTest.java | 77 ------ .../rest/resource/PlatformRestResourceTest.java | 42 --- .../test/fixture/AbstractRestResourceTest.java | 86 ------ .../camp/test/fixture/InMemoryCamp.java | 53 ---- .../ApplicationCompomentTemplateDtoTest.java | 49 ++++ .../brooklyn/camp/server/dto/BasicDtoTest.java | 91 +++++++ .../brooklyn/camp/server/dto/LinkDtoTest.java | 63 +++++ .../dto/PlatformCompomentTemplateDtoTest.java | 49 ++++ .../camp/server/dto/ResourceDtoTest.java | 77 ++++++ .../rest/resource/PlatformRestResourceTest.java | 43 +++ .../test/fixture/AbstractRestResourceTest.java | 85 ++++++ .../camp/server/test/fixture/InMemoryCamp.java | 52 ++++ .../api/AssemblyTemplateSpecInstantiator.java | 7 +- .../brooklyn/config/BrooklynServerConfig.java | 2 +- .../catalog/internal/BasicBrooklynCatalog.java | 10 +- .../internal/EntityManagementUtils.java | 9 +- .../lite/CampPlatformWithJustBrooklynMgmt.java | 2 +- .../brooklyn/camp/lite/CampYamlLiteTest.java | 9 +- .../brooklyn/camp/lite/TestAppAssembly.java | 3 +- .../camp/lite/TestAppAssemblyInstantiator.java | 15 +- .../entity/rebind/RebindCatalogItemTest.java | 4 +- .../camp/brooklyn/BrooklynCampConstants.java | 4 +- .../camp/brooklyn/BrooklynCampPlatform.java | 7 +- .../BrooklynCampPlatformLauncherAbstract.java | 3 +- .../camp/brooklyn/YamlLauncherAbstract.java | 5 +- .../BrooklynAssemblyTemplateInstantiator.java | 15 +- .../BrooklynComponentTemplateResolver.java | 9 +- .../spi/creation/BrooklynEntityMatcher.java | 11 +- .../service/BrooklynServiceTypeResolver.java | 3 +- .../service/CatalogServiceTypeResolver.java | 3 +- .../service/ChefServiceTypeResolver.java | 3 +- .../service/JavaServiceTypeResolver.java | 3 +- .../spi/dsl/BrooklynDslDeferredSupplier.java | 7 +- .../spi/dsl/BrooklynDslInterpreter.java | 9 +- .../lookup/AbstractBrooklynResourceLookup.java | 7 +- .../lookup/AbstractTemplateBrooklynLookup.java | 7 +- .../spi/lookup/AssemblyBrooklynLookup.java | 7 +- .../lookup/AssemblyTemplateBrooklynLookup.java | 7 +- .../lookup/PlatformComponentBrooklynLookup.java | 9 +- ...PlatformComponentTemplateBrooklynLookup.java | 7 +- .../platform/BrooklynImmutableCampPlatform.java | 25 +- .../camp/brooklyn/AbstractYamlRebindTest.java | 5 +- .../camp/brooklyn/AbstractYamlTest.java | 5 +- ...aWebAppWithDslYamlRebindIntegrationTest.java | 5 +- .../brooklyn/JavaWebAppsIntegrationTest.java | 14 +- .../camp/brooklyn/JavaWebAppsMatchingTest.java | 11 +- .../brooklyn/ReloadBrooklynPropertiesTest.java | 7 +- .../brooklyn/launcher/BrooklynLauncher.java | 6 +- .../camp/BrooklynCampPlatformLauncher.java | 4 +- .../resources/AbstractBrooklynRestResource.java | 3 +- .../rest/resources/ApplicationResource.java | 3 +- 197 files changed, 6230 insertions(+), 6272 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/io/brooklyn/camp/AggregatingCampPlatform.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/AggregatingCampPlatform.java b/camp/camp-base/src/main/java/io/brooklyn/camp/AggregatingCampPlatform.java deleted file mode 100644 index 4e000c5..0000000 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/AggregatingCampPlatform.java +++ /dev/null @@ -1,131 +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; - -import io.brooklyn.camp.spi.AbstractResource; -import io.brooklyn.camp.spi.ApplicationComponent; -import io.brooklyn.camp.spi.ApplicationComponentTemplate; -import io.brooklyn.camp.spi.Assembly; -import io.brooklyn.camp.spi.AssemblyTemplate; -import io.brooklyn.camp.spi.PlatformComponent; -import io.brooklyn.camp.spi.PlatformComponentTemplate; -import io.brooklyn.camp.spi.PlatformRootSummary; -import io.brooklyn.camp.spi.PlatformTransaction; -import io.brooklyn.camp.spi.collection.AggregatingResourceLookup; -import io.brooklyn.camp.spi.collection.ResourceLookup; - -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nullable; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Function; - -/** A {@link CampPlatform} implementation which is empty but allows adding new items, - * as well as adding other platforms; meant for subclassing only */ -public class AggregatingCampPlatform extends CampPlatform { - - private static final Logger log = LoggerFactory.getLogger(AggregatingCampPlatform.class); - - protected AggregatingCampPlatform(PlatformRootSummary root) { - this(root, new BasicCampPlatform(root)); - } - - public AggregatingCampPlatform(PlatformRootSummary root, CampPlatform platformWhereTransactionsOccur) { - super(root); - log.debug("Creating {} with main platform: {}", this, platformWhereTransactionsOccur); - this.mainPlatform = platformWhereTransactionsOccur; - } - - /** platform where additions are made */ - CampPlatform mainPlatform; - List<CampPlatform> otherPlatformsToSearch = new ArrayList<CampPlatform>(); - - protected void addPlatform(CampPlatform platform) { - log.debug("Adding child platform to {}: {}", this, platform); - otherPlatformsToSearch.add(platform); - } - - protected <T extends AbstractResource> ResourceLookup<T> aggregatingLookup(Function<CampPlatform, ResourceLookup<T>> lookupFunction) { - List<ResourceLookup<T>> lookups = new ArrayList<ResourceLookup<T>>(); - lookups.add(lookupFunction.apply(mainPlatform)); - for (CampPlatform p: otherPlatformsToSearch) - lookups.add(lookupFunction.apply(p)); - return AggregatingResourceLookup.of(lookups); - } - - public ResourceLookup<PlatformComponentTemplate> platformComponentTemplates() { - return aggregatingLookup(new Function<CampPlatform, ResourceLookup<PlatformComponentTemplate>>() { - public ResourceLookup<PlatformComponentTemplate> apply(@Nullable CampPlatform input) { - return input.platformComponentTemplates(); - } - }); - } - - @Override - public ResourceLookup<ApplicationComponentTemplate> applicationComponentTemplates() { - return aggregatingLookup(new Function<CampPlatform, ResourceLookup<ApplicationComponentTemplate>>() { - public ResourceLookup<ApplicationComponentTemplate> apply(@Nullable CampPlatform input) { - return input.applicationComponentTemplates(); - } - }); - } - - public ResourceLookup<AssemblyTemplate> assemblyTemplates() { - return aggregatingLookup(new Function<CampPlatform, ResourceLookup<AssemblyTemplate>>() { - public ResourceLookup<AssemblyTemplate> apply(@Nullable CampPlatform input) { - return input.assemblyTemplates(); - } - }); - } - - public ResourceLookup<PlatformComponent> platformComponents() { - return aggregatingLookup(new Function<CampPlatform, ResourceLookup<PlatformComponent>>() { - public ResourceLookup<PlatformComponent> apply(@Nullable CampPlatform input) { - return input.platformComponents(); - } - }); - } - - @Override - public ResourceLookup<ApplicationComponent> applicationComponents() { - return aggregatingLookup(new Function<CampPlatform, ResourceLookup<ApplicationComponent>>() { - public ResourceLookup<ApplicationComponent> apply(@Nullable CampPlatform input) { - return input.applicationComponents(); - } - }); - } - - public ResourceLookup<Assembly> assemblies() { - return aggregatingLookup(new Function<CampPlatform, ResourceLookup<Assembly>>() { - public ResourceLookup<Assembly> apply(@Nullable CampPlatform input) { - return input.assemblies(); - } - }); - } - - @Override - public PlatformTransaction transaction() { - return mainPlatform.transaction(); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/io/brooklyn/camp/BasicCampPlatform.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/BasicCampPlatform.java b/camp/camp-base/src/main/java/io/brooklyn/camp/BasicCampPlatform.java deleted file mode 100644 index 16a3dee..0000000 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/BasicCampPlatform.java +++ /dev/null @@ -1,143 +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; - -import io.brooklyn.camp.spi.ApplicationComponent; -import io.brooklyn.camp.spi.ApplicationComponentTemplate; -import io.brooklyn.camp.spi.Assembly; -import io.brooklyn.camp.spi.AssemblyTemplate; -import io.brooklyn.camp.spi.PlatformComponent; -import io.brooklyn.camp.spi.PlatformComponentTemplate; -import io.brooklyn.camp.spi.PlatformRootSummary; -import io.brooklyn.camp.spi.PlatformTransaction; -import io.brooklyn.camp.spi.collection.BasicResourceLookup; - -import java.util.concurrent.atomic.AtomicBoolean; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** A {@link CampPlatform} implementation which is empty but allows adding new items */ -public class BasicCampPlatform extends CampPlatform { - - private static final Logger log = LoggerFactory.getLogger(BasicCampPlatform.class); - - public BasicCampPlatform() { - this(PlatformRootSummary.builder().name("CAMP Platform").build()); - } - - public BasicCampPlatform(PlatformRootSummary root) { - super(root); - } - - BasicResourceLookup<PlatformComponentTemplate> platformComponentTemplates = new BasicResourceLookup<PlatformComponentTemplate>(); - BasicResourceLookup<ApplicationComponentTemplate> applicationComponentTemplates = new BasicResourceLookup<ApplicationComponentTemplate>(); - BasicResourceLookup<AssemblyTemplate> assemblyTemplates = new BasicResourceLookup<AssemblyTemplate>(); - - BasicResourceLookup<PlatformComponent> platformComponents = new BasicResourceLookup<PlatformComponent>(); - BasicResourceLookup<ApplicationComponent> applicationComponents = new BasicResourceLookup<ApplicationComponent>(); - BasicResourceLookup<Assembly> assemblies = new BasicResourceLookup<Assembly>(); - - public BasicResourceLookup<PlatformComponentTemplate> platformComponentTemplates() { - return platformComponentTemplates; - } - - @Override - public BasicResourceLookup<ApplicationComponentTemplate> applicationComponentTemplates() { - return applicationComponentTemplates; - } - - public BasicResourceLookup<AssemblyTemplate> assemblyTemplates() { - return assemblyTemplates; - } - - public BasicResourceLookup<PlatformComponent> platformComponents() { - return platformComponents; - } - - @Override - public BasicResourceLookup<ApplicationComponent> applicationComponents() { - return applicationComponents; - } - - public BasicResourceLookup<Assembly> assemblies() { - return assemblies; - } - - @Override - public PlatformTransaction transaction() { - return new BasicPlatformTransaction(this); - } - - public static class BasicPlatformTransaction extends PlatformTransaction { - private final BasicCampPlatform platform; - private final AtomicBoolean committed = new AtomicBoolean(false); - - public BasicPlatformTransaction(BasicCampPlatform platform) { - this.platform = platform; - } - - @Override - public void commit() { - if (committed.getAndSet(true)) - throw new IllegalStateException("transaction being committed multiple times"); - - for (Object o: additions) { - if (o instanceof AssemblyTemplate) { - platform.assemblyTemplates.add((AssemblyTemplate) o); - continue; - } - if (o instanceof PlatformComponentTemplate) { - platform.platformComponentTemplates.add((PlatformComponentTemplate) o); - continue; - } - if (o instanceof ApplicationComponentTemplate) { - platform.applicationComponentTemplates.add((ApplicationComponentTemplate) o); - continue; - } - - if (o instanceof Assembly) { - platform.assemblies.add((Assembly) o); - continue; - } - if (o instanceof PlatformComponent) { - platform.platformComponents.add((PlatformComponent) o); - continue; - } - if (o instanceof ApplicationComponent) { - platform.applicationComponents.add((ApplicationComponent) o); - continue; - } - - throw new UnsupportedOperationException("Object "+o+" of type "+o.getClass()+" cannot be added to "+platform); - } - } - - @Override - protected void finalize() throws Throwable { - if (!committed.get()) { - // normal, in the case of errors (which might occur when catalog tries to figure out the right plan format); shouldn't happen otherwise - // if we want log.warn visibility of these, then we will have to supply an abandon() method on this interface and ensure that is invoked on errors - log.debug("transaction "+this+" was never applied"); - } - super.finalize(); - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/io/brooklyn/camp/CampPlatform.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/CampPlatform.java b/camp/camp-base/src/main/java/io/brooklyn/camp/CampPlatform.java deleted file mode 100644 index fc263cb..0000000 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/CampPlatform.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; - -import io.brooklyn.camp.spi.ApplicationComponent; -import io.brooklyn.camp.spi.ApplicationComponentTemplate; -import io.brooklyn.camp.spi.Assembly; -import io.brooklyn.camp.spi.AssemblyTemplate; -import io.brooklyn.camp.spi.PlatformComponent; -import io.brooklyn.camp.spi.PlatformComponentTemplate; -import io.brooklyn.camp.spi.PlatformRootSummary; -import io.brooklyn.camp.spi.PlatformTransaction; -import io.brooklyn.camp.spi.collection.ResourceLookup; -import io.brooklyn.camp.spi.resolve.PdpProcessor; - -import com.google.common.base.Preconditions; - -public abstract class CampPlatform { - - private final PlatformRootSummary root; - private final PdpProcessor pdp; - - public CampPlatform(PlatformRootSummary root) { - this.root = Preconditions.checkNotNull(root, "root"); - pdp = createPdpProcessor(); - } - - // --- root - - public PlatformRootSummary root() { - return root; - } - - // --- other aspects - - public PdpProcessor pdp() { - return pdp; - } - - - // --- required custom implementation hooks - - public abstract ResourceLookup<PlatformComponentTemplate> platformComponentTemplates(); - public abstract ResourceLookup<ApplicationComponentTemplate> applicationComponentTemplates(); - public abstract ResourceLookup<AssemblyTemplate> assemblyTemplates(); - - public abstract ResourceLookup<PlatformComponent> platformComponents(); - public abstract ResourceLookup<ApplicationComponent> applicationComponents(); - public abstract ResourceLookup<Assembly> assemblies(); - - /** returns object where changes to a PDP can be made; note all changes must be committed */ - public abstract PlatformTransaction transaction(); - - // --- optional customisation overrides - - protected PdpProcessor createPdpProcessor() { - return new PdpProcessor(this); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/io/brooklyn/camp/commontypes/RepresentationSkew.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/commontypes/RepresentationSkew.java b/camp/camp-base/src/main/java/io/brooklyn/camp/commontypes/RepresentationSkew.java deleted file mode 100644 index 1f9644f..0000000 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/commontypes/RepresentationSkew.java +++ /dev/null @@ -1,23 +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.commontypes; - -public enum RepresentationSkew { - CREATING, NONE, DESTROYING, UNKNOWN -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/io/brooklyn/camp/spi/AbstractResource.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/AbstractResource.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/AbstractResource.java deleted file mode 100644 index 5f04e20..0000000 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/AbstractResource.java +++ /dev/null @@ -1,197 +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.spi; - -import io.brooklyn.camp.commontypes.RepresentationSkew; - -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import brooklyn.util.collections.MutableMap; -import brooklyn.util.text.Identifiers; -import brooklyn.util.time.Time; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -/** Superclass of CAMP resource implementation objects. - * Typically used to hold common state of implementation objects - * and to populate the DTO's used by the REST API. - * <p> - * These class instances are typically created using the - * static {@link #builder()} methods they contain. - * The resulting instances are typically immutable, - * so where fields can change callers should use a new builder - * (or update an underlying data store). - * <p> - * This class is not meant to be instantiated directly, as - * CAMP only uses defined subclasses (ie containing these fields). - * It is instantiable for testing. - */ -public class AbstractResource { - - public static final String CAMP_TYPE = "Resource"; - - private String id = Identifiers.makeRandomId(8); - private String name; - private String type; - private String description; - private String sourceCode; - private Date created = Time.dropMilliseconds(new Date()); - private List<String> tags = Collections.emptyList(); - private RepresentationSkew representationSkew; - - private Map<String,Object> customAttributes = new MutableMap<String, Object>(); - - /** Use {@link #builder()} to create */ - protected AbstractResource() {} - - // getters - - public String getId() { - return id; - } - public String getName() { - return name; - } - public String getType() { - return type; - } - public String getDescription() { - return description; - } - public String getSourceCode() { - return sourceCode; - } - public Date getCreated() { - return created; - } - public List<String> getTags() { - return tags; - } - public RepresentationSkew getRepresentationSkew() { - return representationSkew; - } - public Map<String, Object> getCustomAttributes() { - return ImmutableMap.copyOf(customAttributes); - } - - // setters - - private void setId(String id) { - this.id = id; - } - private void setName(String name) { - this.name = name; - } - private void setDescription(String description) { - this.description = description; - } - private void setSourceCode(String sourceCode) { - this.sourceCode = sourceCode; - } - private void setCreated(Date created) { - // precision beyond seconds breaks equals check - this.created = Time.dropMilliseconds(created); - } - private void setTags(List<String> tags) { - this.tags = ImmutableList.copyOf(tags); - } - private void setType(String type) { - this.type = type; - } - private void setRepresentationSkew(RepresentationSkew representationSkew) { - this.representationSkew = representationSkew; - } - public void setCustomAttribute(String key, Object value) { - this.customAttributes.put(key, value); - } - - // builder - @SuppressWarnings("rawtypes") - public static Builder<? extends AbstractResource,? extends Builder> builder() { - return new AbstractResource().new AbstractResourceBuilder(CAMP_TYPE); - } - - /** Builder creates the instance up front to avoid repetition of fields in the builder; - * but prevents object leakage until build and prevents changes after build, - * so effectively immutable. - * <p> - * Similarly setters in the class are private so those objects are also typically effectively immutable. */ - public abstract class Builder<T extends AbstractResource,U extends Builder<T,U>> { - - private boolean built = false; - private String type = null; - private boolean initialized = false; - - protected Builder(String type) { - this.type = type; - } - - protected final synchronized void check() { - if (built) - throw new IllegalStateException("Builder instance from "+this+" cannot be access after build"); - if (!initialized) { - initialized = true; - initialize(); - } - } - - protected void initialize() { - if (type!=null) type(type); - } - - @SuppressWarnings("unchecked") - public synchronized T build() { - check(); - built = true; - return (T) AbstractResource.this; - } - - @SuppressWarnings("unchecked") - protected U thisBuilder() { return (U)this; } - - public U type(String x) { check(); AbstractResource.this.setType(x); return thisBuilder(); } - public U id(String x) { check(); AbstractResource.this.setId(x); return thisBuilder(); } - public U name(String x) { check(); AbstractResource.this.setName(x); return thisBuilder(); } - public U description(String x) { check(); AbstractResource.this.setDescription(x); return thisBuilder(); } - public U created(Date x) { check(); AbstractResource.this.setCreated(x); return thisBuilder(); } - public U tags(List<String> x) { check(); AbstractResource.this.setTags(x); return thisBuilder(); } - public U representationSkew(RepresentationSkew x) { check(); AbstractResource.this.setRepresentationSkew(x); return thisBuilder(); } - public U customAttribute(String key, Object value) { check(); AbstractResource.this.setCustomAttribute(key, value); return thisBuilder(); } - public U sourceCode(String x) { check(); AbstractResource.this.setSourceCode(x); return thisBuilder(); } - -// public String type() { return instance().type; } - } - - @VisibleForTesting - protected class AbstractResourceBuilder extends Builder<AbstractResource,AbstractResourceBuilder> { - protected AbstractResourceBuilder(String type) { - super(type); - } - } - - @Override - public String toString() { - return super.toString()+"[id="+getId()+"; type="+getType()+"]"; - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/io/brooklyn/camp/spi/ApplicationComponent.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/ApplicationComponent.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/ApplicationComponent.java deleted file mode 100644 index 3e956a4..0000000 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/ApplicationComponent.java +++ /dev/null @@ -1,93 +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.spi; - -import io.brooklyn.camp.spi.collection.BasicResourceLookup; -import io.brooklyn.camp.spi.collection.ResourceLookup; -import io.brooklyn.camp.spi.collection.ResourceLookup.EmptyResourceLookup; - - -/** Holds the metadata (name, description, etc) for a PCT - * as well as fields pointing to behaviour (eg creation of PlatformComponent). - * <p> - * See {@link AbstractResource} for more general information. - */ -public class ApplicationComponent extends AbstractResource { - - public static final String CAMP_TYPE = "ApplicationComponent"; - static { assert CAMP_TYPE.equals(ApplicationComponent.class.getSimpleName()); } - - /** Use {@link #builder()} to create */ - protected ApplicationComponent() {} - - ResourceLookup<ApplicationComponent> applicationComponents; - ResourceLookup<PlatformComponent> platformComponents; - String externalManagementUri; - - public ResourceLookup<ApplicationComponent> getApplicationComponents() { - return applicationComponents != null ? applicationComponents : new EmptyResourceLookup<ApplicationComponent>(); - } - public ResourceLookup<PlatformComponent> getPlatformComponents() { - return platformComponents != null ? platformComponents : new EmptyResourceLookup<PlatformComponent>(); - } - - private void setApplicationComponents(ResourceLookup<ApplicationComponent> applicationComponents) { - this.applicationComponents = applicationComponents; - } - private void setPlatformComponents(ResourceLookup<PlatformComponent> platformComponents) { - this.platformComponents = platformComponents; - } - - // builder - - public static Builder<? extends ApplicationComponent> builder() { - return new ApplicationComponent().new Builder<ApplicationComponent>(CAMP_TYPE); - } - - public class Builder<T extends ApplicationComponent> extends AbstractResource.Builder<T,Builder<T>> { - - protected Builder(String type) { super(type); } - - public Builder<T> applicationComponentTemplates(ResourceLookup<ApplicationComponent> x) { ApplicationComponent.this.setApplicationComponents(x); return thisBuilder(); } - public Builder<T> platformComponentTemplates(ResourceLookup<PlatformComponent> x) { ApplicationComponent.this.setPlatformComponents(x); return thisBuilder(); } - - public synchronized Builder<T> add(ApplicationComponent x) { - if (ApplicationComponent.this.applicationComponents==null) { - ApplicationComponent.this.applicationComponents = new BasicResourceLookup<ApplicationComponent>(); - } - if (!(ApplicationComponent.this.applicationComponents instanceof BasicResourceLookup)) { - throw new IllegalStateException("Cannot add to resource lookup "+ApplicationComponent.this.applicationComponents); - } - ((BasicResourceLookup<ApplicationComponent>)ApplicationComponent.this.applicationComponents).add(x); - return thisBuilder(); - } - - public synchronized Builder<T> add(PlatformComponent x) { - if (ApplicationComponent.this.platformComponents==null) { - ApplicationComponent.this.platformComponents = new BasicResourceLookup<PlatformComponent>(); - } - if (!(ApplicationComponent.this.platformComponents instanceof BasicResourceLookup)) { - throw new IllegalStateException("Cannot add to resource lookup "+ApplicationComponent.this.platformComponents); - } - ((BasicResourceLookup<PlatformComponent>)ApplicationComponent.this.platformComponents).add(x); - return thisBuilder(); - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/io/brooklyn/camp/spi/ApplicationComponentTemplate.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/ApplicationComponentTemplate.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/ApplicationComponentTemplate.java deleted file mode 100644 index f3212c7..0000000 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/ApplicationComponentTemplate.java +++ /dev/null @@ -1,54 +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.spi; - - -/** Holds the metadata (name, description, etc) for a PCT - * as well as fields pointing to behaviour (eg creation of PlatformComponent). - * <p> - * See {@link AbstractResource} for more general information. - */ -public class ApplicationComponentTemplate extends AbstractResource { - - public static final String CAMP_TYPE = "ApplicationComponentTemplate"; - static { assert CAMP_TYPE.equals(ApplicationComponentTemplate.class.getSimpleName()); } - - /** Use {@link #builder()} to create */ - protected ApplicationComponentTemplate() {} - - - // no fields beyond basic resource - - // TODO platform component templates, maybe other act's too ? - - - // builder - - public static Builder<? extends ApplicationComponentTemplate> builder() { - return new ApplicationComponentTemplate().new Builder<ApplicationComponentTemplate>(CAMP_TYPE); - } - - public class Builder<T extends ApplicationComponentTemplate> extends AbstractResource.Builder<T,Builder<T>> { - - protected Builder(String type) { super(type); } - -// public Builder<T> foo(String x) { instance().setFoo(x); return thisBuilder(); } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/io/brooklyn/camp/spi/Assembly.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/Assembly.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/Assembly.java deleted file mode 100644 index 15cfd51..0000000 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/Assembly.java +++ /dev/null @@ -1,109 +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.spi; - -import io.brooklyn.camp.spi.collection.BasicResourceLookup; -import io.brooklyn.camp.spi.collection.ResourceLookup; -import io.brooklyn.camp.spi.collection.ResourceLookup.EmptyResourceLookup; - - -/** Holds the metadata (name, description, etc) for an AssemblyTemplate - * as well as fields pointing to behaviour (eg list of ACT's). - * <p> - * See {@link AbstractResource} for more general information. - */ -public class Assembly extends AbstractResource { - - public static final String CAMP_TYPE = "Assembly"; - static { assert CAMP_TYPE.equals(Assembly.class.getSimpleName()); } - - /** Use {@link #builder()} to create */ - protected Assembly() {} - - AssemblyTemplate assemblyTemplate; - ResourceLookup<ApplicationComponent> applicationComponents; - ResourceLookup<PlatformComponent> platformComponents; - - // TODO -// "parameterDefinitionUri": URI, -// "pdpUri" : URI ? - - public AssemblyTemplate getAssemblyTemplate() { - return assemblyTemplate; - } - public ResourceLookup<ApplicationComponent> getApplicationComponents() { - return applicationComponents != null ? applicationComponents : new EmptyResourceLookup<ApplicationComponent>(); - } - public ResourceLookup<PlatformComponent> getPlatformComponents() { - return platformComponents != null ? platformComponents : new EmptyResourceLookup<PlatformComponent>(); - } - - private void setAssemblyTemplate(AssemblyTemplate assemblyTemplate) { - this.assemblyTemplate = assemblyTemplate; - } - private void setApplicationComponents(ResourceLookup<ApplicationComponent> applicationComponents) { - this.applicationComponents = applicationComponents; - } - private void setPlatformComponents(ResourceLookup<PlatformComponent> platformComponents) { - this.platformComponents = platformComponents; - } - - // builder - - public static Builder<? extends Assembly> builder() { - return new Assembly().new Builder<Assembly>(CAMP_TYPE); - } - - public class Builder<T extends Assembly> extends AbstractResource.Builder<T,Builder<T>> { - - protected Builder(String type) { super(type); } - - public Builder<T> assemblyTemplate(AssemblyTemplate x) { Assembly.this.setAssemblyTemplate(x); return thisBuilder(); } - public Builder<T> applicationComponentTemplates(ResourceLookup<ApplicationComponent> x) { Assembly.this.setApplicationComponents(x); return thisBuilder(); } - public Builder<T> platformComponentTemplates(ResourceLookup<PlatformComponent> x) { Assembly.this.setPlatformComponents(x); return thisBuilder(); } - - public synchronized Builder<T> add(ApplicationComponent x) { - if (Assembly.this.applicationComponents==null) { - Assembly.this.applicationComponents = new BasicResourceLookup<ApplicationComponent>(); - } - if (!(Assembly.this.applicationComponents instanceof BasicResourceLookup)) { - throw new IllegalStateException("Cannot add to resource lookup "+Assembly.this.applicationComponents); - } - ((BasicResourceLookup<ApplicationComponent>)Assembly.this.applicationComponents).add(x); - return thisBuilder(); - } - - public synchronized Builder<T> add(PlatformComponent x) { - if (Assembly.this.platformComponents==null) { - Assembly.this.platformComponents = new BasicResourceLookup<PlatformComponent>(); - } - if (!(Assembly.this.platformComponents instanceof BasicResourceLookup)) { - throw new IllegalStateException("Cannot add to resource lookup "+Assembly.this.platformComponents); - } - ((BasicResourceLookup<PlatformComponent>)Assembly.this.platformComponents).add(x); - return thisBuilder(); - } - - @Override - public synchronized T build() { - return super.build(); - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/io/brooklyn/camp/spi/AssemblyTemplate.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/AssemblyTemplate.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/AssemblyTemplate.java deleted file mode 100644 index 4779a1c..0000000 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/AssemblyTemplate.java +++ /dev/null @@ -1,118 +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.spi; - -import com.google.common.base.Preconditions; - -import io.brooklyn.camp.spi.collection.BasicResourceLookup; -import io.brooklyn.camp.spi.collection.ResourceLookup; -import io.brooklyn.camp.spi.collection.ResourceLookup.EmptyResourceLookup; -import io.brooklyn.camp.spi.instantiate.AssemblyTemplateInstantiator; - - -/** Holds the metadata (name, description, etc) for an AssemblyTemplate - * as well as fields pointing to behaviour (eg list of ACT's). - * <p> - * See {@link AbstractResource} for more general information. - */ -public class AssemblyTemplate extends AbstractResource { - - public static final String CAMP_TYPE = "AssemblyTemplate"; - static { assert CAMP_TYPE.equals(AssemblyTemplate.class.getSimpleName()); } - - Class<? extends AssemblyTemplateInstantiator> instantiator; - ResourceLookup<ApplicationComponentTemplate> applicationComponentTemplates; - ResourceLookup<PlatformComponentTemplate> platformComponentTemplates; - - // TODO -// "parameterDefinitionUri": URI, -// "pdpUri" : URI ? - - /** Use {@link #builder()} to create */ - protected AssemblyTemplate() {} - - public Class<? extends AssemblyTemplateInstantiator> getInstantiator() { - return instantiator; - } - public ResourceLookup<ApplicationComponentTemplate> getApplicationComponentTemplates() { - return applicationComponentTemplates != null ? applicationComponentTemplates : new EmptyResourceLookup<ApplicationComponentTemplate>(); - } - public ResourceLookup<PlatformComponentTemplate> getPlatformComponentTemplates() { - return platformComponentTemplates != null ? platformComponentTemplates : new EmptyResourceLookup<PlatformComponentTemplate>(); - } - - private void setInstantiator(Class<? extends AssemblyTemplateInstantiator> instantiator) { - this.instantiator = instantiator; - } - private void setApplicationComponentTemplates(ResourceLookup<ApplicationComponentTemplate> applicationComponentTemplates) { - this.applicationComponentTemplates = applicationComponentTemplates; - } - private void setPlatformComponentTemplates(ResourceLookup<PlatformComponentTemplate> platformComponentTemplates) { - this.platformComponentTemplates = platformComponentTemplates; - } - - // builder - - public static Builder<? extends AssemblyTemplate> builder() { - return new AssemblyTemplate().new Builder<AssemblyTemplate>(CAMP_TYPE); - } - - public class Builder<T extends AssemblyTemplate> extends AbstractResource.Builder<T,Builder<T>> { - - protected Builder(String type) { super(type); } - - public Builder<T> instantiator(Class<? extends AssemblyTemplateInstantiator> x) { AssemblyTemplate.this.setInstantiator(x); return thisBuilder(); } - public Builder<T> applicationComponentTemplates(ResourceLookup<ApplicationComponentTemplate> x) { AssemblyTemplate.this.setApplicationComponentTemplates(x); return thisBuilder(); } - public Builder<T> platformComponentTemplates(ResourceLookup<PlatformComponentTemplate> x) { AssemblyTemplate.this.setPlatformComponentTemplates(x); return thisBuilder(); } - - /** allows callers to see the partially formed instance when needed, for example to query instantiators; - * could be replaced by specific methods as and when that is preferred */ - @SuppressWarnings("unchecked") - public T peek() { return (T) AssemblyTemplate.this; } - - public synchronized Builder<T> add(ApplicationComponentTemplate x) { - if (AssemblyTemplate.this.applicationComponentTemplates==null) { - AssemblyTemplate.this.applicationComponentTemplates = new BasicResourceLookup<ApplicationComponentTemplate>(); - } - if (!(AssemblyTemplate.this.applicationComponentTemplates instanceof BasicResourceLookup)) { - throw new IllegalStateException("Cannot add to resource lookup "+AssemblyTemplate.this.applicationComponentTemplates); - } - ((BasicResourceLookup<ApplicationComponentTemplate>)AssemblyTemplate.this.applicationComponentTemplates).add(x); - return thisBuilder(); - } - - public synchronized Builder<T> add(PlatformComponentTemplate x) { - if (AssemblyTemplate.this.platformComponentTemplates==null) { - AssemblyTemplate.this.platformComponentTemplates = new BasicResourceLookup<PlatformComponentTemplate>(); - } - if (!(AssemblyTemplate.this.platformComponentTemplates instanceof BasicResourceLookup)) { - throw new IllegalStateException("Cannot add to resource lookup "+AssemblyTemplate.this.platformComponentTemplates); - } - ((BasicResourceLookup<PlatformComponentTemplate>)AssemblyTemplate.this.platformComponentTemplates).add(x); - return thisBuilder(); - } - - @Override - public synchronized T build() { - Preconditions.checkNotNull(AssemblyTemplate.this.instantiator); - return super.build(); - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/io/brooklyn/camp/spi/Link.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/Link.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/Link.java deleted file mode 100644 index d8ee643..0000000 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/Link.java +++ /dev/null @@ -1,40 +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.spi; - -public class Link<T> { - - private final String id; - private final String name; - - public Link(String id, String name) { - super(); - this.id = id; - this.name = name; - } - - public String getId() { - return id; - } - - public String getName() { - return name; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/io/brooklyn/camp/spi/PlatformComponent.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/PlatformComponent.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/PlatformComponent.java deleted file mode 100644 index d531174..0000000 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/PlatformComponent.java +++ /dev/null @@ -1,101 +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.spi; - -import io.brooklyn.camp.spi.collection.BasicResourceLookup; -import io.brooklyn.camp.spi.collection.ResourceLookup; -import io.brooklyn.camp.spi.collection.ResourceLookup.EmptyResourceLookup; - - -/** Holds the metadata (name, description, etc) for a PCT - * as well as fields pointing to behaviour (eg creation of PlatformComponent). - * <p> - * See {@link AbstractResource} for more general information. - */ -public class PlatformComponent extends AbstractResource { - - public static final String CAMP_TYPE = "PlatformComponent"; - static { assert CAMP_TYPE.equals(PlatformComponent.class.getSimpleName()); } - - /** Use {@link #builder()} to create */ - protected PlatformComponent() {} - - ResourceLookup<ApplicationComponent> applicationComponents; - ResourceLookup<PlatformComponent> platformComponents; - String externalManagementUri; - - public ResourceLookup<ApplicationComponent> getApplicationComponents() { - return applicationComponents != null ? applicationComponents : new EmptyResourceLookup<ApplicationComponent>(); - } - public ResourceLookup<PlatformComponent> getPlatformComponents() { - return platformComponents != null ? platformComponents : new EmptyResourceLookup<PlatformComponent>(); - } - - private void setApplicationComponents(ResourceLookup<ApplicationComponent> applicationComponents) { - this.applicationComponents = applicationComponents; - } - private void setPlatformComponents(ResourceLookup<PlatformComponent> platformComponents) { - this.platformComponents = platformComponents; - } - - public String getExternalManagementUri() { - return externalManagementUri; - } - private void setExternalManagementUri(String externalManagementUri) { - this.externalManagementUri = externalManagementUri; - } - - // builder - - public static Builder<? extends PlatformComponent> builder() { - return new PlatformComponent().new Builder<PlatformComponent>(CAMP_TYPE); - } - - public class Builder<T extends PlatformComponent> extends AbstractResource.Builder<T,Builder<T>> { - - protected Builder(String type) { super(type); } - - public Builder<T> externalManagementUri(String x) { PlatformComponent.this.setExternalManagementUri(x); return thisBuilder(); } - public Builder<T> applicationComponentTemplates(ResourceLookup<ApplicationComponent> x) { PlatformComponent.this.setApplicationComponents(x); return thisBuilder(); } - public Builder<T> platformComponentTemplates(ResourceLookup<PlatformComponent> x) { PlatformComponent.this.setPlatformComponents(x); return thisBuilder(); } - - public synchronized Builder<T> add(ApplicationComponent x) { - if (PlatformComponent.this.applicationComponents==null) { - PlatformComponent.this.applicationComponents = new BasicResourceLookup<ApplicationComponent>(); - } - if (!(PlatformComponent.this.applicationComponents instanceof BasicResourceLookup)) { - throw new IllegalStateException("Cannot add to resource lookup "+PlatformComponent.this.applicationComponents); - } - ((BasicResourceLookup<ApplicationComponent>)PlatformComponent.this.applicationComponents).add(x); - return thisBuilder(); - } - - public synchronized Builder<T> add(PlatformComponent x) { - if (PlatformComponent.this.platformComponents==null) { - PlatformComponent.this.platformComponents = new BasicResourceLookup<PlatformComponent>(); - } - if (!(PlatformComponent.this.platformComponents instanceof BasicResourceLookup)) { - throw new IllegalStateException("Cannot add to resource lookup "+PlatformComponent.this.platformComponents); - } - ((BasicResourceLookup<PlatformComponent>)PlatformComponent.this.platformComponents).add(x); - return thisBuilder(); - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/io/brooklyn/camp/spi/PlatformComponentTemplate.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/PlatformComponentTemplate.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/PlatformComponentTemplate.java deleted file mode 100644 index 7f93f34..0000000 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/PlatformComponentTemplate.java +++ /dev/null @@ -1,52 +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.spi; - - -/** Holds the metadata (name, description, etc) for a PCT - * as well as fields pointing to behaviour (eg creation of PlatformComponent). - * <p> - * See {@link AbstractResource} for more general information. - */ -public class PlatformComponentTemplate extends AbstractResource { - - public static final String CAMP_TYPE = "PlatformComponentTemplate"; - static { assert CAMP_TYPE.equals(PlatformComponentTemplate.class.getSimpleName()); } - - /** Use {@link #builder()} to create */ - protected PlatformComponentTemplate() {} - - - // no fields beyond basic resource - - - // builder - - public static Builder<? extends PlatformComponentTemplate> builder() { - return new PlatformComponentTemplate().new Builder<PlatformComponentTemplate>(CAMP_TYPE); - } - - public class Builder<T extends PlatformComponentTemplate> extends AbstractResource.Builder<T,Builder<T>> { - - protected Builder(String type) { super(type); } - -// public Builder<T> foo(String x) { instance().setFoo(x); return thisBuilder(); } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/io/brooklyn/camp/spi/PlatformRootSummary.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/PlatformRootSummary.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/PlatformRootSummary.java deleted file mode 100644 index eb34ff9..0000000 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/PlatformRootSummary.java +++ /dev/null @@ -1,70 +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.spi; - -/** Holds the metadata (name, description, etc) for a CampPlatform. - * Required to initialize a CampPlatform. - * <p> - * See {@link AbstractResource} for more general information. - */ -public class PlatformRootSummary extends AbstractResource { - - public static final String CAMP_TYPE = "Platform"; - - /** Use {@link #builder()} to create */ - protected PlatformRootSummary() { - } - - // no fields beyond basic resource - - //TODO: - - // in the DTO - -// "supportedFormatsUri": URI, -// "extensionsUri": URI, -// "typeDefinitionsUri": URI, -// "tags": [ String, + ], ? -// "specificationVersion": String[], -// "implementationVersion": String, ? -// "assemblyTemplates": [ Link + ], ? -// "assemblies": [ Link + ], ? -// "platformComponentTemplates": [ Link + ], ? -// "platformComponentCapabilities": [Link + ], ? -// "platformComponents": [ Link + ], ? - - - // builder - - public static Builder<? extends PlatformRootSummary> builder() { - return new PlatformRootSummary().new Builder<PlatformRootSummary>(CAMP_TYPE); - } - - public class Builder<T extends PlatformRootSummary> extends AbstractResource.Builder<T,Builder<T>> { - - protected Builder(String type) { super(type); } - - protected void initialize() { - super.initialize(); - // TODO a better way not to have an ID here (new subclass BasicIdentifiableResource for other BasicResource instances) - id(""); - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/io/brooklyn/camp/spi/PlatformTransaction.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/PlatformTransaction.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/PlatformTransaction.java deleted file mode 100644 index 33ef7c3..0000000 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/PlatformTransaction.java +++ /dev/null @@ -1,46 +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.spi; - -import java.util.ArrayList; -import java.util.List; - -public abstract class PlatformTransaction { - - protected List<Object> additions = new ArrayList<Object>(); - - /** apply the transaction */ - public abstract void commit(); - - public PlatformTransaction add(AssemblyTemplate at) { - additions.add(at); - return this; - } - - public PlatformTransaction add(ApplicationComponentTemplate act) { - additions.add(act); - return this; - } - - public PlatformTransaction add(PlatformComponentTemplate pct) { - additions.add(pct); - return this; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/io/brooklyn/camp/spi/collection/AbstractResourceLookup.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/collection/AbstractResourceLookup.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/collection/AbstractResourceLookup.java deleted file mode 100644 index 64005c8..0000000 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/collection/AbstractResourceLookup.java +++ /dev/null @@ -1,35 +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.spi.collection; - -import io.brooklyn.camp.spi.AbstractResource; - -public abstract class AbstractResourceLookup<T extends AbstractResource> implements ResourceLookup<T> { - - /** convenience for concrete subclasses */ - protected ResolvableLink<T> newLink(String id, String name) { - return new ResolvableLink<T>(id, name, this); - } - - @Override - public boolean isEmpty() { - return links().isEmpty(); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/io/brooklyn/camp/spi/collection/AggregatingResourceLookup.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/collection/AggregatingResourceLookup.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/collection/AggregatingResourceLookup.java deleted file mode 100644 index 3a902ff..0000000 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/collection/AggregatingResourceLookup.java +++ /dev/null @@ -1,56 +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.spi.collection; - -import io.brooklyn.camp.spi.AbstractResource; - -import java.util.ArrayList; -import java.util.List; - -public class AggregatingResourceLookup<T extends AbstractResource> extends AbstractResourceLookup<T> { - - List<ResourceLookup<T>> targets = new ArrayList<ResourceLookup<T>>(); - - public static <T extends AbstractResource> AggregatingResourceLookup<T> of(ResourceLookup<T> ...targets) { - AggregatingResourceLookup<T> result = new AggregatingResourceLookup<T>(); - for (ResourceLookup<T> item: targets) result.targets.add(item); - return result; - } - - public static <T extends AbstractResource> AggregatingResourceLookup<T> of(Iterable<ResourceLookup<T>> targets) { - AggregatingResourceLookup<T> result = new AggregatingResourceLookup<T>(); - for (ResourceLookup<T> item: targets) result.targets.add(item); - return result; - } - - public T get(String id) { - for (ResourceLookup<T> item: targets) { - T result = item.get(id); - if (result!=null) return result; - } - return null; - } - - public List<ResolvableLink<T>> links() { - List<ResolvableLink<T>> result = new ArrayList<ResolvableLink<T>>(); - for (ResourceLookup<T> item: targets) result.addAll(item.links()); - return result; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/io/brooklyn/camp/spi/collection/BasicResourceLookup.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/collection/BasicResourceLookup.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/collection/BasicResourceLookup.java deleted file mode 100644 index 12a1972..0000000 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/collection/BasicResourceLookup.java +++ /dev/null @@ -1,71 +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.spi.collection; - -import io.brooklyn.camp.spi.AbstractResource; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import brooklyn.util.collections.MutableMap; - -public class BasicResourceLookup<T extends AbstractResource> extends AbstractResourceLookup<T> { - - Map<String,T> items = new MutableMap<String,T>(); - Map<String,ResolvableLink<T>> links = new MutableMap<String,ResolvableLink<T>>(); - - public T get(String id) { - return items.get(id); - } - - public synchronized List<ResolvableLink<T>> links() { - return new ArrayList<ResolvableLink<T>>(links.values()); - } - - public synchronized void add(T item) { - T old = items.put(item.getId(), item); - if (old!=null) { - items.put(old.getId(), old); - throw new IllegalStateException("Already contains item for "+item.getId()+": "+old+" (adding "+item+")"); - } - links.put(item.getId(), newLink(item.getId(), item.getName())); - } - - public synchronized void addAll(T... items) { - for (T item: items) add(item); - } - - public synchronized T update(T item) { - T old = items.put(item.getId(), item); - links.put(item.getId(), newLink(item.getId(), item.getName())); - return old; - } - - public synchronized boolean remove(String id) { - items.remove(id); - return links.remove(id)!=null; - } - - public static <T extends AbstractResource> BasicResourceLookup<T> of(T ...items) { - BasicResourceLookup<T> result = new BasicResourceLookup<T>(); - for (T item: items) result.add(item); - return result; - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/io/brooklyn/camp/spi/collection/ResolvableLink.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/collection/ResolvableLink.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/collection/ResolvableLink.java deleted file mode 100644 index 1ad5fd3..0000000 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/collection/ResolvableLink.java +++ /dev/null @@ -1,37 +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.spi.collection; - -import io.brooklyn.camp.spi.AbstractResource; -import io.brooklyn.camp.spi.Link; - -public class ResolvableLink<T extends AbstractResource> extends Link<T> { - - protected final ResourceLookup<T> provider; - - public ResolvableLink(String id, String name, ResourceLookup<T> provider) { - super(id, name); - this.provider = provider; - } - - public T resolve() { - return provider.get(getId()); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/io/brooklyn/camp/spi/collection/ResourceLookup.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/collection/ResourceLookup.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/collection/ResourceLookup.java deleted file mode 100644 index 231417f..0000000 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/collection/ResourceLookup.java +++ /dev/null @@ -1,47 +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.spi.collection; - -import io.brooklyn.camp.spi.AbstractResource; - -import java.util.Collections; -import java.util.List; -import java.util.NoSuchElementException; - -public interface ResourceLookup<T extends AbstractResource> { - - public abstract T get(String id); - - public abstract List<ResolvableLink<T>> links(); - - public abstract boolean isEmpty(); - - public static class EmptyResourceLookup<T extends AbstractResource> implements ResourceLookup<T> { - public T get(String id) { - throw new NoSuchElementException("no resource: "+id); - } - public List<ResolvableLink<T>> links() { - return Collections.emptyList(); - } - public boolean isEmpty() { - return links().isEmpty(); - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/io/brooklyn/camp/spi/instantiate/AssemblyTemplateInstantiator.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/instantiate/AssemblyTemplateInstantiator.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/instantiate/AssemblyTemplateInstantiator.java deleted file mode 100644 index 55e7c64..0000000 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/instantiate/AssemblyTemplateInstantiator.java +++ /dev/null @@ -1,30 +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.spi.instantiate; - -import io.brooklyn.camp.CampPlatform; -import io.brooklyn.camp.spi.Assembly; -import io.brooklyn.camp.spi.AssemblyTemplate; - -/** instances of this class should have a public no-arg constructor so the class names can be serialized */ -public interface AssemblyTemplateInstantiator { - - public Assembly instantiate(AssemblyTemplate template, CampPlatform platform); - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/io/brooklyn/camp/spi/instantiate/BasicAssemblyTemplateInstantiator.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/instantiate/BasicAssemblyTemplateInstantiator.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/instantiate/BasicAssemblyTemplateInstantiator.java deleted file mode 100644 index dbe3acd..0000000 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/instantiate/BasicAssemblyTemplateInstantiator.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.spi.instantiate; - -import io.brooklyn.camp.CampPlatform; -import io.brooklyn.camp.spi.Assembly; -import io.brooklyn.camp.spi.AssemblyTemplate; - -/** A simple instantiator which simply invokes the component's instantiators in parallel */ -public class BasicAssemblyTemplateInstantiator implements AssemblyTemplateInstantiator { - - public Assembly instantiate(AssemblyTemplate template, CampPlatform platform) { - // TODO this should build it based on the components -// template.getPlatformComponentTemplates().links().iterator().next().resolve(); - - // platforms should set a bunch of instantiators, or else let the ComponentTemplates do this! - throw new UnsupportedOperationException("Basic instantiator not yet supported"); - } - -}
