You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/02/01 18:51:21 UTC
[39/51] [abbrv] [partial] brooklyn-server git commit: move subdir
from incubator up a level as it is promoted to its own repo (first
non-incubator commit!)
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationContext.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationContext.java b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationContext.java
deleted file mode 100644
index f45d7c6..0000000
--- a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationContext.java
+++ /dev/null
@@ -1,152 +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 org.apache.brooklyn.camp.spi.resolve.interpret;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.brooklyn.camp.spi.resolve.PlanInterpreter;
-import org.apache.brooklyn.util.collections.MutableMap;
-
-import com.google.common.collect.ImmutableList;
-
-public class PlanInterpretationContext {
-
- private final Map<String,Object> originalDeploymentPlan;
- private final List<PlanInterpreter> interpreters;
- private final PlanInterpreter allInterpreter;
-
- public PlanInterpretationContext(Map<String,?> originalDeploymentPlan, List<PlanInterpreter> interpreters) {
- super();
- this.originalDeploymentPlan = MutableMap.copyOf(originalDeploymentPlan).asUnmodifiable();
- this.interpreters = ImmutableList.copyOf(interpreters);
- this.allInterpreter = new PlanInterpreter() {
- @Override
- public boolean isInterestedIn(PlanInterpretationNode node) {
- return true;
- }
-
- @Override
- public void applyYamlPrimitive(PlanInterpretationNode node) {
- for (PlanInterpreter i: PlanInterpretationContext.this.interpreters) {
- if (node.isExcluded())
- break;
- if (i.isInterestedIn(node)) {
- i.applyYamlPrimitive(node);
- }
- }
- }
-
- @Override
- public boolean applyMapBefore(PlanInterpretationNode node, Map<Object, Object> mapIn) {
- boolean result = true;
- for (PlanInterpreter i: PlanInterpretationContext.this.interpreters) {
- if (node.isExcluded())
- break;
- if (i.isInterestedIn(node)) {
- boolean ri= i.applyMapBefore(node, mapIn);
- result &= ri;
- }
- }
- return result;
- }
-
- @Override
- public boolean applyMapEntry(PlanInterpretationNode node, Map<Object, Object> mapIn, Map<Object, Object> mapOut,
- PlanInterpretationNode key, PlanInterpretationNode value) {
- boolean result = true;
- for (PlanInterpreter i: PlanInterpretationContext.this.interpreters) {
- if (node.isExcluded())
- break;
- if (i.isInterestedIn(key)) {
- boolean ri = i.applyMapEntry(node, mapIn, mapOut, key, value);
- result &= ri;
- }
- }
- return result;
- }
-
- @Override
- public void applyMapAfter(PlanInterpretationNode node, Map<Object, Object> mapIn, Map<Object, Object> mapOut) {
- for (PlanInterpreter i: PlanInterpretationContext.this.interpreters) {
- if (node.isExcluded())
- break;
- if (i.isInterestedIn(node)) {
- i.applyMapAfter(node, mapIn, mapOut);
- }
- }
- }
-
- @Override
- public boolean applyListBefore(PlanInterpretationNode node, List<Object> listIn) {
- boolean result = true;
- for (PlanInterpreter i: PlanInterpretationContext.this.interpreters) {
- if (node.isExcluded())
- break;
- if (i.isInterestedIn(node)) {
- boolean ri = i.applyListBefore(node, listIn);
- result &= ri;
- }
- }
- return result;
- }
-
- @Override
- public boolean applyListEntry(PlanInterpretationNode node, List<Object> listIn, List<Object> listOut,
- PlanInterpretationNode value) {
- boolean result = true;
- for (PlanInterpreter i: PlanInterpretationContext.this.interpreters) {
- if (node.isExcluded())
- break;
- if (i.isInterestedIn(value)) {
- boolean ri = i.applyListEntry(node, listIn, listOut, value);
- result &= ri;
- }
- }
- return result;
- }
-
- @Override
- public void applyListAfter(PlanInterpretationNode node, List<Object> listIn, List<Object> listOut) {
- for (PlanInterpreter i: PlanInterpretationContext.this.interpreters) {
- if (node.isExcluded())
- break;
- if (i.isInterestedIn(node)) {
- i.applyListAfter(node, listIn, listOut);
- }
- }
- }
-
- };
- }
-
- /** returns an interpreter which recurses through all interpreters */
- PlanInterpreter getAllInterpreter() {
- return allInterpreter;
- }
-
- public Map<String,Object> getOriginalDeploymentPlan() {
- return originalDeploymentPlan;
- }
-
- public List<PlanInterpreter> getInterpreters() {
- return interpreters;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationNode.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationNode.java b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationNode.java
deleted file mode 100644
index 2cf3d5d..0000000
--- a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationNode.java
+++ /dev/null
@@ -1,259 +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 org.apache.brooklyn.camp.spi.resolve.interpret;
-
-import java.util.Map;
-
-import org.apache.brooklyn.camp.spi.resolve.PlanInterpreter;
-import org.apache.brooklyn.util.collections.MutableList;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.text.StringPredicates;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.Iterables;
-
-/** Helper class for {@link PlanInterpreter} instances, doing the recursive work */
-public class PlanInterpretationNode {
-
- private static final Logger log = LoggerFactory.getLogger(PlanInterpretationNode.class);
-
- public enum Role { MAP_KEY, MAP_VALUE, LIST_ENTRY, YAML_PRIMITIVE }
-
- protected final PlanInterpretationNode parent;
- protected final Role roleInParent;
- protected final Object originalValue;
- protected final PlanInterpretationContext context;
- protected Object newValue = null;
- protected Boolean changed = null;
- protected boolean excluded = false;
- protected boolean immutable = false;
-
- /** creates a root node with {@link #apply()} called */
- public PlanInterpretationNode(PlanInterpretationContext context) {
- this.parent = null;
- this.roleInParent = null;
- this.originalValue = context.getOriginalDeploymentPlan();
- this.context = context;
- apply();
- }
-
- /** internal use: creates an internal node on which {@link #apply()} has *not* been called */
- protected PlanInterpretationNode(PlanInterpretationNode parent, Role roleInParent, Object originalItem) {
- this.parent = parent;
- this.roleInParent = roleInParent;
- this.originalValue = originalItem;
- this.context = parent.getContext();
- }
-
- public PlanInterpretationContext getContext() {
- return context;
- }
-
- public PlanInterpretationNode getParent() {
- return parent;
- }
-
- public Role getRoleInParent() {
- return roleInParent;
- }
-
- protected void apply() {
- if (changed!=null) throw new IllegalStateException("can only be applied once");
-
- if (!excluded) {
- if (originalValue instanceof Map) {
- applyToMap();
- immutable();
- } else if (originalValue instanceof Iterable) {
- applyToIterable();
- immutable();
- } else {
- applyToYamlPrimitive();
- }
- }
-
- if (changed==null) changed = false;
- }
-
- /** convenience for interpreters, tests if nodes are not excluded, and if not:
- * for string nodes, true iff the current value equals the given target;
- * for nodes which are currently maps or lists,
- * true iff not excluded and the value contains such an entry (key, in the case of map)
- **/
- public boolean matchesLiteral(String target) {
- if (isExcluded()) return false;
- if (getNewValue() instanceof CharSequence)
- return getNewValue().toString().equals(target);
- if (getNewValue() instanceof Map)
- return ((Map<?,?>)getOriginalValue()).containsKey(target);
- if (getNewValue() instanceof Iterable)
- return Iterables.contains((Iterable<?>)getOriginalValue(), target);
- return false;
- }
-
- /** convenience for interpreters, tests if nodes are not excluded, and if not:
- * for string nodes, true iff the current value starts with the given prefix;
- * for nodes which are currently maps or lists,
- * true iff not excluded and the value contains such an entry (key, in the case of map) */
- public boolean matchesPrefix(String prefix) {
- if (isExcluded()) return false;
- if (getNewValue() instanceof CharSequence)
- return getNewValue().toString().startsWith(prefix);
- if (getNewValue() instanceof Map)
- return Iterables.tryFind(((Map<?,?>)getNewValue()).keySet(), StringPredicates.isStringStartingWith(prefix)).isPresent();
- if (getNewValue() instanceof Iterable)
- return Iterables.tryFind((Iterable<?>)getNewValue(), StringPredicates.isStringStartingWith(prefix)).isPresent();
- return false;
- }
-
- // TODO matchesRegex ?
-
- public Object getOriginalValue() {
- return originalValue;
- }
-
- public Object getNewValue() {
- if (changed==null || !isChanged()) return originalValue;
- return newValue;
- }
-
- public boolean isChanged() {
- if (changed==null) throw new IllegalStateException("not yet applied");
- return changed;
- }
-
- public boolean isExcluded() {
- return excluded;
- }
-
- /** indicates that a node should no longer be translated */
- public PlanInterpretationNode exclude() {
- this.excluded = true;
- return this;
- }
-
- public PlanInterpretationNode setNewValue(Object newItem) {
- if (immutable)
- throw new IllegalStateException("Node "+this+" has been set immutable");
- this.newValue = newItem;
- this.changed = true;
- return this;
- }
-
- protected PlanInterpretationNode newPlanInterpretation(PlanInterpretationNode parent, Role roleInParent, Object item) {
- return new PlanInterpretationNode(parent, roleInParent, item);
- }
-
- protected void applyToMap() {
- Map<Object, Object> input = MutableMap.<Object,Object>copyOf((Map<?,?>)originalValue);
- Map<Object, Object> result = MutableMap.<Object,Object>of();
- newValue = result;
-
- // first do a "whole-node" application
- if (getContext().getAllInterpreter().applyMapBefore(this, input)) {
-
- for (Map.Entry<Object,Object> entry: input.entrySet()) {
- // then recurse in to this node and do various in-the-node applications
- PlanInterpretationNode value = newPlanInterpretation(this, Role.MAP_VALUE, entry.getValue());
- value.apply();
-
- PlanInterpretationNode key = newPlanInterpretation(this, Role.MAP_KEY, entry.getKey());
- key.apply();
-
- if (key.isChanged() || value.isChanged())
- changed = true;
-
- if (getContext().getAllInterpreter().applyMapEntry(this, input, result, key, value))
- result.put(key.getNewValue(), value.getNewValue());
- else
- changed = true;
- }
-
- // finally try applying to this node again
- getContext().getAllInterpreter().applyMapAfter(this, input, result);
- }
-
- if (changed==null) changed = false;
- }
-
- protected void applyToIterable() {
- MutableList<Object> input = MutableList.copyOf((Iterable<?>)originalValue);
- MutableList<Object> result = new MutableList<Object>();
- newValue = result;
-
- // first do a "whole-node" application
- if (getContext().getAllInterpreter().applyListBefore(this, input)) {
-
- for (Object entry: input) {
- // then recurse in to this node and do various in-the-node applications
- PlanInterpretationNode value = newPlanInterpretation(this, Role.LIST_ENTRY, entry);
- value.apply();
-
- if (value.isChanged())
- changed = true;
-
- if (getContext().getAllInterpreter().applyListEntry(this, input, result, value))
- result.add(value.getNewValue());
- }
-
- // finally try applying to this node again
- getContext().getAllInterpreter().applyListAfter(this, input, result);
- }
-
- if (changed==null) changed = false;
- }
-
- protected void applyToYamlPrimitive() {
- getContext().getAllInterpreter().applyYamlPrimitive(this);
- }
-
- public void immutable() {
- if (!isChanged()) {
- if (!checkCollectionImmutable(getNewValue())) {
- // results of Yaml parse are not typically immutable,
- // so force them to be changed so result of interpretation is immutable
- changed = true;
- setNewValue(immutable(getNewValue()));
- }
- } else {
- setNewValue(immutable(getNewValue()));
- }
- checkImmutable(getNewValue());
- immutable = true;
- }
-
- private void checkImmutable(Object in) {
- if (!checkCollectionImmutable(in))
- log.warn("Node original value "+in+" at "+this+" should be immutable");
- }
-
- private static boolean checkCollectionImmutable(Object in) {
- // not used -- input might now be UnmodifiableMap, as some args might be null,
- // and UnmodifiableMap is private :( ... (and same for list)
- return true;
- }
-
- private static Object immutable(Object in) {
- if (in instanceof Map) return MutableMap.copyOf((Map<?,?>)in).asUnmodifiable();
- if (in instanceof Iterable) return MutableList.copyOf((Iterable<?>)in).asUnmodifiable();
- return in;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/util/yaml/Yamls.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/util/yaml/Yamls.java b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/util/yaml/Yamls.java
deleted file mode 100644
index 1bfde6f..0000000
--- a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/util/yaml/Yamls.java
+++ /dev/null
@@ -1,24 +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 org.apache.brooklyn.camp.util.yaml;
-
-/** @deprecated since 0.7.0 use {@link org.apache.brooklyn.util.yaml.Yamls} */
-@Deprecated
-public class Yamls extends org.apache.brooklyn.util.yaml.Yamls {
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-base/src/test/java/org/apache/brooklyn/camp/spi/pdp/DeploymentPlanToyInterpreterTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-base/src/test/java/org/apache/brooklyn/camp/spi/pdp/DeploymentPlanToyInterpreterTest.java b/brooklyn-server/camp/camp-base/src/test/java/org/apache/brooklyn/camp/spi/pdp/DeploymentPlanToyInterpreterTest.java
deleted file mode 100644
index 51dcc2f..0000000
--- a/brooklyn-server/camp/camp-base/src/test/java/org/apache/brooklyn/camp/spi/pdp/DeploymentPlanToyInterpreterTest.java
+++ /dev/null
@@ -1,112 +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 org.apache.brooklyn.camp.spi.pdp;
-
-import java.util.Map;
-
-import org.apache.brooklyn.camp.BasicCampPlatform;
-import org.apache.brooklyn.camp.spi.resolve.PlanInterpreter.PlanInterpreterAdapter;
-import org.apache.brooklyn.camp.spi.resolve.interpret.PlanInterpretationNode;
-import org.apache.brooklyn.util.stream.Streams;
-import org.apache.brooklyn.util.text.Strings;
-import org.apache.brooklyn.util.yaml.Yamls;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-@Test
-public class DeploymentPlanToyInterpreterTest {
-
- private static final Logger log = LoggerFactory.getLogger(DeploymentPlanToyInterpreterTest.class);
-
- /**
- * Allows testing:
- *
- * $sample:foo becomes "bar"
- * $sample:caps:x capitalises the argument x
- * $sample:ignore as key causes key-value to be dropped (and value 0 for good measure)
- * $sample:reset causes containing map or list to be cleared at that point
- * $sample:remove as key causes argument as map to be dropped
- */
- public static class ToyInterpreter extends PlanInterpreterAdapter {
-
- @Override
- public boolean isInterestedIn(PlanInterpretationNode node) {
- return node.matchesPrefix("$sample:");
- }
-
- @Override
- public void applyYamlPrimitive(PlanInterpretationNode node) {
- if (node.matchesLiteral("$sample:foo")) node.setNewValue("bar").exclude();
- if (node.matchesPrefix("$sample:caps:")) {
- node.setNewValue(Strings.removeFromStart(node.getNewValue().toString(), "$sample:caps:").toUpperCase()).exclude();
- }
- }
-
- @Override
- public boolean applyMapBefore(PlanInterpretationNode node, Map<Object, Object> mapIn) {
- if (node.matchesLiteral("$sample:ignore"))
- // replace
- mapIn.put("$sample:ignore", 0);
- return super.applyMapBefore(node, mapIn);
- }
-
- @Override
- public boolean applyMapEntry(PlanInterpretationNode node, Map<Object, Object> mapIn, Map<Object, Object> mapOut,
- PlanInterpretationNode key, PlanInterpretationNode value) {
- if (key.matchesLiteral("$sample:ignore")) {
- Assert.assertEquals(value.getNewValue(), 0);
- return false;
- }
- if (key.matchesLiteral("$sample:reset")) {
- mapOut.clear();
- return false;
- }
-
- return super.applyMapEntry(node, mapIn, mapOut, key, value);
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public void applyMapAfter(PlanInterpretationNode node, Map<Object, Object> mapIn, Map<Object, Object> mapOut) {
- if (mapOut.containsKey("$sample:remove")) {
- Map toRemove = (Map) mapOut.get("$sample:remove");
- for (Object vv: toRemove.keySet()) mapOut.remove(vv);
- mapOut.remove("$sample:remove");
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- public void testToyInterpreter() {
- @SuppressWarnings("rawtypes")
- Map y1 = Yamls.getAs( Yamls.parseAll( Streams.reader(getClass().getResourceAsStream("yaml-sample-toy-interpreter.yaml"))), Map.class );
- log.info("pre-interpreter have: "+y1);
-
- BasicCampPlatform p = new BasicCampPlatform();
- p.pdp().addInterpreter(new ToyInterpreter());
- Map<String, Object> y2 = p.pdp().applyInterpreters(y1);
- log.info("interpreter gives: "+y2);
-
- Map<String, Object> y3 = Yamls.getAs( Yamls.parseAll( Streams.reader(getClass().getResourceAsStream("yaml-sample-toy-interpreter-result.yaml"))), Map.class );
- Assert.assertEquals(y2, y3);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-base/src/test/java/org/apache/brooklyn/camp/spi/pdp/PdpYamlTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-base/src/test/java/org/apache/brooklyn/camp/spi/pdp/PdpYamlTest.java b/brooklyn-server/camp/camp-base/src/test/java/org/apache/brooklyn/camp/spi/pdp/PdpYamlTest.java
deleted file mode 100644
index b9fee6f..0000000
--- a/brooklyn-server/camp/camp-base/src/test/java/org/apache/brooklyn/camp/spi/pdp/PdpYamlTest.java
+++ /dev/null
@@ -1,79 +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 org.apache.brooklyn.camp.spi.pdp;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-
-import org.apache.brooklyn.camp.BasicCampPlatform;
-import org.apache.brooklyn.camp.spi.AssemblyTemplate;
-import org.apache.brooklyn.camp.spi.pdp.Artifact;
-import org.apache.brooklyn.camp.spi.pdp.DeploymentPlan;
-import org.apache.brooklyn.camp.spi.pdp.Service;
-import org.apache.brooklyn.camp.test.mock.web.MockWebPlatform;
-import org.apache.brooklyn.util.stream.Streams;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-public class PdpYamlTest {
-
- private static final Logger log = LoggerFactory.getLogger(PdpYamlTest.class);
-
- @Test
- public void testSimpleYamlArtifactParse() throws IOException {
- BasicCampPlatform platform = MockWebPlatform.populate(new BasicCampPlatform());
- Reader input = Streams.reader(getClass().getResourceAsStream("pdp-single-artifact.yaml"));
- DeploymentPlan plan = platform.pdp().parseDeploymentPlan(input);
- log.info("DP is:\n"+plan.toString());
- Assert.assertEquals(plan.getName(), "sample");
- Assert.assertEquals(plan.getArtifacts().size(), 1);
- Assert.assertEquals(plan.getServices().size(), 0);
-
- Artifact artifact1 = plan.getArtifacts().iterator().next();
- Assert.assertEquals(artifact1.getName(), "sample WAR");
- }
-
- @Test
- public void testSimpleYamlServiceParse() throws IOException {
- BasicCampPlatform platform = MockWebPlatform.populate(new BasicCampPlatform());
- Reader input = Streams.reader(getClass().getResourceAsStream("pdp-single-service.yaml"));
- DeploymentPlan plan = platform.pdp().parseDeploymentPlan(input);
- log.info("DP is:\n"+plan.toString());
- Assert.assertEquals(plan.getName(), "sample");
- Assert.assertEquals(plan.getArtifacts().size(), 0);
- Assert.assertEquals(plan.getServices().size(), 1);
-
- Service service1 = plan.getServices().iterator().next();
- Assert.assertEquals(service1.getName(), "Hello WAR");
- }
-
- @Test
- public void testSimpleYamlMatch() throws IOException {
- BasicCampPlatform platform = MockWebPlatform.populate(new BasicCampPlatform());
- Reader input = new InputStreamReader(getClass().getResourceAsStream("pdp-single-artifact.yaml"));
- AssemblyTemplate at = platform.pdp().registerDeploymentPlan(input);
- log.info("AT is:\n"+at.toString());
- Assert.assertEquals(at.getApplicationComponentTemplates().links().size(), 1);
- Assert.assertEquals(at.getName(), "sample");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/mock/web/MockAssemblyTemplateInstantiator.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/mock/web/MockAssemblyTemplateInstantiator.java b/brooklyn-server/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/mock/web/MockAssemblyTemplateInstantiator.java
deleted file mode 100644
index a358eed..0000000
--- a/brooklyn-server/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/mock/web/MockAssemblyTemplateInstantiator.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 org.apache.brooklyn.camp.test.mock.web;
-
-import org.apache.brooklyn.camp.CampPlatform;
-import org.apache.brooklyn.camp.spi.Assembly;
-import org.apache.brooklyn.camp.spi.AssemblyTemplate;
-import org.apache.brooklyn.camp.spi.instantiate.AssemblyTemplateInstantiator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class MockAssemblyTemplateInstantiator implements AssemblyTemplateInstantiator {
-
- private static final Logger log = LoggerFactory.getLogger(MockAssemblyTemplateInstantiator.class);
-
- public Assembly instantiate(AssemblyTemplate template, CampPlatform platform) {
- log.debug("Ignoring request to instantiate "+template);
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/mock/web/MockWebPlatform.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/mock/web/MockWebPlatform.java b/brooklyn-server/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/mock/web/MockWebPlatform.java
deleted file mode 100644
index 4a60d1c..0000000
--- a/brooklyn-server/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/mock/web/MockWebPlatform.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 org.apache.brooklyn.camp.test.mock.web;
-
-import javax.annotation.Nullable;
-
-import org.apache.brooklyn.camp.BasicCampPlatform;
-import org.apache.brooklyn.camp.spi.ApplicationComponentTemplate;
-import org.apache.brooklyn.camp.spi.AssemblyTemplate;
-import org.apache.brooklyn.camp.spi.PlatformComponentTemplate;
-import org.apache.brooklyn.camp.spi.collection.BasicResourceLookup;
-import org.apache.brooklyn.camp.spi.collection.ResolvableLink;
-import org.apache.brooklyn.camp.spi.instantiate.AssemblyTemplateInstantiator;
-import org.apache.brooklyn.camp.spi.pdp.Artifact;
-import org.apache.brooklyn.camp.spi.pdp.AssemblyTemplateConstructor;
-import org.apache.brooklyn.camp.spi.pdp.Service;
-import org.apache.brooklyn.camp.spi.resolve.PdpMatcher;
-import org.apache.brooklyn.util.guava.Maybe;
-
-public class MockWebPlatform {
-
- public static final ApplicationComponentTemplate WAR =
- ApplicationComponentTemplate.builder()
- .name("io.camp.mock:WAR")
- .description("Mock WAR")
- .build();
-
- public static final PlatformComponentTemplate APPSERVER =
- PlatformComponentTemplate.builder()
- .name("io.camp.mock:AppServer")
- .description("Mock Application Server")
- .build();
-
- public static final PlatformComponentTemplate DATABASE =
- PlatformComponentTemplate.builder()
- .name("io.camp.mock:Database")
- .description("Mock Database")
- .build();
-
- public static final AssemblyTemplate ASSEMBLY1 =
- AssemblyTemplate.builder()
- .name("WebAppAssembly1")
- .description("Mock Web App Assembly Template")
- .applicationComponentTemplates(BasicResourceLookup.of(WAR))
- .instantiator(MockAssemblyTemplateInstantiator.class)
- .build();
-
- public static final PdpMatcher WAR_GETS_WAR_MATCHER = new PdpMatcher.ArtifactMatcher("com.java:WAR") {
- public boolean apply(Object art, AssemblyTemplateConstructor atc) {
- ApplicationComponentTemplate act = ApplicationComponentTemplate.builder()
- .name( ((Artifact)art).getName() )
- .description( ((Artifact)art).getDescription() )
- .customAttribute("implementation", WAR.getName())
- .customAttribute("artifactType", ((Artifact)art).getArtifactType())
- .build();
-
- // TODO requirements, etc
-
- atc.add(act);
-
- return true;
- }
- };
-
- public static final PdpMatcher newLiteralServiceTypeToPlatformComponentTemplateMatcher(final BasicCampPlatform platform, @Nullable final Class<? extends AssemblyTemplateInstantiator> instantiator) {
- return new PdpMatcher() {
- public boolean apply(Object item, AssemblyTemplateConstructor atc) {
- if (!(item instanceof Service)) return false;
- Service svc = (Service)item;
- String type = svc.getServiceType();
-
- for (ResolvableLink<PlatformComponentTemplate> t: platform.platformComponentTemplates().links()) {
- if (type.equals(t.getName())) {
- PlatformComponentTemplate pct = PlatformComponentTemplate.builder()
- .name(svc.getName())
- .customAttribute("serviceType", type)
- .description(Maybe.fromNullable(svc.getDescription()).or(t.resolve().getDescription()))
- .build();
- if (atc!=null) {
- atc.add(pct);
- if (instantiator!=null)
- atc.instantiator(instantiator);
- }
- return true;
- }
- }
- return false;
- }
-
- @Override
- public boolean accepts(Object deploymentPlanItem) {
- return apply(deploymentPlanItem, null);
- }
- };
- }
-
- public static <T extends BasicCampPlatform> T populate(T platform) {
- return populate(platform, null);
- }
- public static <T extends BasicCampPlatform> T populate(T platform, @Nullable Class<? extends AssemblyTemplateInstantiator> instantiator) {
- platform.platformComponentTemplates().addAll(APPSERVER, DATABASE);
- platform.applicationComponentTemplates().add(WAR);
- platform.assemblyTemplates().add(ASSEMBLY1);
-
- platform.pdp().addMatcher(WAR_GETS_WAR_MATCHER);
- platform.pdp().addMatcher(newLiteralServiceTypeToPlatformComponentTemplateMatcher(platform, instantiator));
-
- return platform;
- }
-
- public static BasicCampPlatform newPlatform() {
- return MockWebPlatform.populate(new BasicCampPlatform());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/platform/BasicCampPlatformTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/platform/BasicCampPlatformTest.java b/brooklyn-server/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/platform/BasicCampPlatformTest.java
deleted file mode 100644
index ccebaa6..0000000
--- a/brooklyn-server/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/platform/BasicCampPlatformTest.java
+++ /dev/null
@@ -1,86 +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 org.apache.brooklyn.camp.test.platform;
-
-import org.apache.brooklyn.camp.BasicCampPlatform;
-import org.apache.brooklyn.camp.spi.AbstractResource;
-import org.apache.brooklyn.camp.spi.ApplicationComponentTemplate;
-import org.apache.brooklyn.camp.spi.PlatformComponentTemplate;
-import org.apache.brooklyn.camp.spi.collection.ResolvableLink;
-import org.apache.brooklyn.camp.test.mock.web.MockWebPlatform;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-public class BasicCampPlatformTest {
-
- @Test
- public void testEmptyPlatform() {
- BasicCampPlatform p = new BasicCampPlatform();
- assertResourceFieldsNotNull(p.root());
- Assert.assertEquals(p.platformComponentTemplates().links().size(), 0);
- }
-
- @Test
- public void testWebPctSetup() {
- BasicCampPlatform p = new BasicCampPlatform();
- p.platformComponentTemplates().add(MockWebPlatform.APPSERVER);
-
- assertResourceFieldsNotNull(p.root());
-
- Assert.assertEquals(p.platformComponentTemplates().links().size(), 1);
- ResolvableLink<PlatformComponentTemplate> l = p.platformComponentTemplates().links().get(0);
- assertLinkFieldsNotNull(l);
- Assert.assertEquals(l.getName(), "io.camp.mock:AppServer");
-
- PlatformComponentTemplate pct = l.resolve();
- assertResourceFieldsNotNull(pct);
- }
-
- @Test
- public void testWarActSetup() {
- BasicCampPlatform p = new BasicCampPlatform();
- p.applicationComponentTemplates().add(MockWebPlatform.WAR);
-
- assertResourceFieldsNotNull(p.root());
-
- Assert.assertEquals(p.platformComponentTemplates().links().size(), 0);
- Assert.assertEquals(p.applicationComponentTemplates().links().size(), 1);
- ResolvableLink<ApplicationComponentTemplate> l = p.applicationComponentTemplates().links().get(0);
- assertLinkFieldsNotNull(l);
- Assert.assertEquals(l.getName(), "io.camp.mock:WAR");
-
- ApplicationComponentTemplate act = l.resolve();
- assertResourceFieldsNotNull(act);
- }
-
-
- public static void assertLinkFieldsNotNull(ResolvableLink<?> x) {
- Assert.assertNotNull(x.getId());
- Assert.assertNotNull(x.getName());
- }
-
- public static void assertResourceFieldsNotNull(AbstractResource x) {
- Assert.assertNotNull(x.getId());
- Assert.assertNotNull(x.getType());
- Assert.assertNotNull(x.getCreated());
- Assert.assertNotNull(x.getName());
- Assert.assertNotNull(x.getTags());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/pdp-single-artifact.yaml
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/pdp-single-artifact.yaml b/brooklyn-server/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/pdp-single-artifact.yaml
deleted file mode 100644
index 0b4518b..0000000
--- a/brooklyn-server/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/pdp-single-artifact.yaml
+++ /dev/null
@@ -1,27 +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.
-#
-name: sample
-description: Tomcat sample JSP and servlet application.
-origin: http://www.oracle.com/nCAMP/Hand
-artifacts:
- -
- type: com.java:WAR
- content: { href: sample.war }
- name: sample WAR
- description: Tomcat sample WAR file
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/pdp-single-service.yaml
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/pdp-single-service.yaml b/brooklyn-server/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/pdp-single-service.yaml
deleted file mode 100644
index fe052d6..0000000
--- a/brooklyn-server/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/pdp-single-service.yaml
+++ /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.
-#
-name: sample
-description: Tomcat sample JSP and servlet application.
-origin: http://www.oracle.com/nCAMP/Hand
-services:
- -
- type: brooklyn:WebAppCluster
- name: Hello WAR
- wars:
- /: hello.war
- controller.spec:
- port: 80
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter-result.yaml
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter-result.yaml b/brooklyn-server/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter-result.yaml
deleted file mode 100644
index 71b0ba8..0000000
--- a/brooklyn-server/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter-result.yaml
+++ /dev/null
@@ -1,22 +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.
-#
-keep: 1
-mess:
- a: bar
- b: [ c, D ]
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter.yaml
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter.yaml b/brooklyn-server/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter.yaml
deleted file mode 100644
index 8aa01d2..0000000
--- a/brooklyn-server/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter.yaml
+++ /dev/null
@@ -1,28 +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.
-#
-$sample:ignore: 1
-keep: 1
-mess:
- 2: z
- $sample:reset:
- $sample:ignore: z
- a: $sample:foo
- b: [ c, "$sample:caps:d" ]
- 3: $sample:caps:x
- $sample:remove: {3: X}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-brooklyn/README.md
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-brooklyn/README.md b/brooklyn-server/camp/camp-brooklyn/README.md
deleted file mode 100644
index e0a112a..0000000
--- a/brooklyn-server/camp/camp-brooklyn/README.md
+++ /dev/null
@@ -1,20 +0,0 @@
-
-Depends on brooklyncentral/camp-server
-
-----
-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.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-brooklyn/pom.xml
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-brooklyn/pom.xml b/brooklyn-server/camp/camp-brooklyn/pom.xml
deleted file mode 100644
index b818b99..0000000
--- a/brooklyn-server/camp/camp-brooklyn/pom.xml
+++ /dev/null
@@ -1,217 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <artifactId>brooklyn-camp</artifactId>
- <packaging>jar</packaging>
- <name>Brooklyn CAMP REST API</name>
- <description>
- Brooklyn support for the Oasis CAMP server
- </description>
-
- <parent>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-parent</artifactId>
- <version>0.9.0-SNAPSHOT</version><!-- BROOKLYN_VERSION -->
- <relativePath>../../parent/pom.xml</relativePath>
- </parent>
-
- <dependencies>
-
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-policy</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-utils-common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn.camp</groupId>
- <artifactId>camp-base</artifactId>
- <version>${project.version}</version>
- <exclusions>
- <!-- Dependency versions mismatch between transitive dependencies, declare explicitly -->
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.code.findbugs</groupId>
- <artifactId>jsr305</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
-
- <!-- for $brooklyn:object -->
- <dependency>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- <version>1.9.1</version>
- <exclusions>
- <!-- Dependency versions mismatch between transitive dependencies, declare explicitly -->
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <!-- TODO not enamoured of including software-base here, but it allows us to reference chef and vanilla for short names;
- ideally there is a mixin strategy by which they can be discovered (eg using java service discovery) -->
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-software-base</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-logback-xml</artifactId>
- <version>${project.version}</version>
- <!-- optional so that this project has logging; dependencies may redeclare or supply their own -->
- <optional>true</optional>
- </dependency>
-
- <!-- demo and tests -->
- <dependency>
- <groupId>org.apache.brooklyn.camp</groupId>
- <artifactId>camp-base</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-core</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-rt-osgi</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-software-base</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-locations-jclouds</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-test-support</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <scope>test</scope>
- </dependency>
-
- <!-- Transitive dependencies, declared explicitly due to version mismatch -->
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>${commons-logging.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
-
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <supportedProjectTypes>
- <supportedProjectType>jar</supportedProjectType>
- </supportedProjectTypes>
- <instructions>
- <Export-Package>org.apache.brooklyn.*</Export-Package>
- </instructions>
- </configuration>
- </plugin>
-
-<!-- if you want to build a WAR, full or skinny:
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <version>${maven-war-plugin.version}</version>
- <executions>
- <execution>
- <id>make-skinny-war</id>
- <phase>install</phase>
- <goals>
- <goal>war</goal>
- </goals>
- <configuration>
- <classifier>skinny</classifier>
- <packagingExcludes>WEB-INF/lib/*.jar,WEB-INF/classes/**/*.class</packagingExcludes>
- </configuration>
- </execution>
- <execution>
- <id>make-full-war</id>
- <phase>install</phase>
- <goals>
- <goal>war</goal>
- </goals>
- <configuration>
- <classifier>full</classifier>
- </configuration>
- </execution>
- </executions>
- </plugin>
--->
-
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampConstants.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampConstants.java b/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampConstants.java
deleted file mode 100644
index d3641f2..0000000
--- a/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampConstants.java
+++ /dev/null
@@ -1,49 +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 org.apache.brooklyn.camp.brooklyn;
-
-import java.util.Set;
-
-import org.apache.brooklyn.camp.CampPlatform;
-import org.apache.brooklyn.config.ConfigInheritance;
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.config.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 = ConfigKeys.newConfigKey(CampPlatform.class, "brooklyn.camp.platform",
- "Config set at brooklyn management platform to find the CampPlatform instance (bi-directional)");
-
- public static final Set<String> YAML_URL_PROTOCOL_WHITELIST = ImmutableSet.of("classpath", "http", "https");
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampPlatform.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampPlatform.java b/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampPlatform.java
deleted file mode 100644
index 7290c24..0000000
--- a/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampPlatform.java
+++ /dev/null
@@ -1,103 +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 org.apache.brooklyn.camp.brooklyn;
-
-import static com.google.common.base.Preconditions.checkState;
-
-import java.util.Map;
-
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.api.mgmt.ManagementContext.PropertiesReloadListener;
-import org.apache.brooklyn.camp.AggregatingCampPlatform;
-import org.apache.brooklyn.camp.CampPlatform;
-import org.apache.brooklyn.camp.brooklyn.spi.creation.BrooklynEntityMatcher;
-import org.apache.brooklyn.camp.brooklyn.spi.dsl.BrooklynDslInterpreter;
-import org.apache.brooklyn.camp.brooklyn.spi.platform.BrooklynImmutableCampPlatform;
-import org.apache.brooklyn.camp.spi.PlatformRootSummary;
-import org.apache.brooklyn.core.mgmt.HasBrooklynManagementContext;
-import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
-import org.apache.brooklyn.core.mgmt.internal.CampYamlParser;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-
-/** {@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
-
- @Override
- 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() {
- ((ManagementContextInternal)bmc).getBrooklynProperties().put(BrooklynCampConstants.CAMP_PLATFORM, this);
- ((ManagementContextInternal)bmc).getBrooklynProperties().put(CampYamlParser.YAML_PARSER_KEY, new YamlParserImpl(this));
- return this;
- }
-
- public static class YamlParserImpl implements CampYamlParser {
- private final BrooklynCampPlatform platform;
-
- YamlParserImpl(BrooklynCampPlatform platform) {
- this.platform = platform;
- }
-
- public Map<String, Object> parse(Map<String, Object> map) {
- return platform.pdp().applyInterpreters(map);
- }
-
- public Object parse(String val) {
- Map<String, Object> result = platform.pdp().applyInterpreters(ImmutableMap.of("dummyKey", val));
- checkState(result.keySet().equals(ImmutableSet.of("dummyKey")), "expected single result, but got %s", result);
- return result.get("dummyKey");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampPlatformLauncherAbstract.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampPlatformLauncherAbstract.java b/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampPlatformLauncherAbstract.java
deleted file mode 100644
index 921615e..0000000
--- a/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/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 org.apache.brooklyn.camp.brooklyn;
-
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.camp.spi.PlatformRootSummary;
-import org.apache.brooklyn.core.mgmt.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/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampPlatformLauncherNoServer.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampPlatformLauncherNoServer.java b/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampPlatformLauncherNoServer.java
deleted file mode 100644
index be2488b..0000000
--- a/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampPlatformLauncherNoServer.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 org.apache.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 {
-
- @Override
- public void stopServers() {
- // nothing to do
- }
-
- public static void main(String[] args) {
- new BrooklynCampPlatformLauncherNoServer().launch();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampReservedKeys.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampReservedKeys.java b/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampReservedKeys.java
deleted file mode 100644
index 52f52e9..0000000
--- a/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/BrooklynCampReservedKeys.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 org.apache.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_PARAMETERS = "brooklyn.parameters";
- public static final String BROOKLYN_CATALOG = "brooklyn.catalog";
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/YamlLauncherAbstract.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/YamlLauncherAbstract.java b/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/YamlLauncherAbstract.java
deleted file mode 100644
index 931a358..0000000
--- a/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/YamlLauncherAbstract.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 org.apache.brooklyn.camp.brooklyn;
-
-import java.io.Reader;
-import java.util.Set;
-
-import org.apache.brooklyn.api.entity.Application;
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.api.mgmt.Task;
-import org.apache.brooklyn.camp.spi.Assembly;
-import org.apache.brooklyn.camp.spi.AssemblyTemplate;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.mgmt.BrooklynTaskTags;
-import org.apache.brooklyn.core.mgmt.internal.BrooklynShutdownHooks;
-import org.apache.brooklyn.util.core.ResourceUtils;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.stream.Streams;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-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/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/YamlLauncherNoServer.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/YamlLauncherNoServer.java b/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/YamlLauncherNoServer.java
deleted file mode 100644
index 1ec3c8d..0000000
--- a/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/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 org.apache.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/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/api/AssemblyTemplateSpecInstantiator.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/api/AssemblyTemplateSpecInstantiator.java b/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/api/AssemblyTemplateSpecInstantiator.java
deleted file mode 100644
index 8540663..0000000
--- a/brooklyn-server/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/api/AssemblyTemplateSpecInstantiator.java
+++ /dev/null
@@ -1,43 +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 org.apache.brooklyn.camp.brooklyn.api;
-
-import java.util.List;
-import java.util.Set;
-
-import org.apache.brooklyn.api.entity.Application;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.mgmt.classloading.BrooklynClassLoadingContext;
-import org.apache.brooklyn.camp.CampPlatform;
-import org.apache.brooklyn.camp.spi.AssemblyTemplate;
-import org.apache.brooklyn.camp.spi.instantiate.AssemblyTemplateInstantiator;
-
-public interface AssemblyTemplateSpecInstantiator extends AssemblyTemplateInstantiator {
-
- /**
- * Gets the single item returned by {@link #createServiceSpecs}
- * and wraps it in an Application if needed, applying top-level
- * attributes and locations to the root entity.
- */
- EntitySpec<? extends Application> createApplicationSpec(AssemblyTemplate template, CampPlatform platform, BrooklynClassLoadingContext loader, Set<String> encounteredCatalogTypes);
-
- /** Returns specs for each item in the services list */
- List<EntitySpec<?>> createServiceSpecs(AssemblyTemplate template, CampPlatform platform, BrooklynClassLoadingContext itemLoader, Set<String> encounteredCatalogTypes);
-
-}