http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/policy/PolicySpec.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/policy/PolicySpec.java b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/policy/PolicySpec.java deleted file mode 100644 index a139d5d..0000000 --- a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/policy/PolicySpec.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 org.apache.brooklyn.api.policy; - -import java.util.Map; - -import org.apache.brooklyn.api.internal.AbstractBrooklynObjectSpec; - -/** - * Gives details of a policy to be created. It describes the policy's configuration, and is - * reusable to create multiple policies with the same configuration. - * - * To create a PolicySpec, it is strongly encouraged to use {@code create(...)} methods. - * - * @param <T> The type of policy to be created - * - * @author aled - */ -public class PolicySpec<T extends Policy> extends AbstractBrooklynObjectSpec<T,PolicySpec<T>> { - - private final static long serialVersionUID = 1L; - - - /** - * Creates a new {@link PolicySpec} instance for a policy of the given type. The returned - * {@link PolicySpec} can then be customized. - * - * @param type A {@link Policy} class - */ - public static <T extends Policy> PolicySpec<T> create(Class<T> type) { - return new PolicySpec<T>(type); - } - - /** - * Creates a new {@link PolicySpec} instance with the given config, for a policy of the given type. - * - * This is primarily for groovy code; equivalent to {@code PolicySpec.create(type).configure(config)}. - * - * @param config The spec's configuration (see {@link PolicySpec#configure(Map)}). - * @param type A {@link Policy} class - */ - public static <T extends Policy> PolicySpec<T> create(Map<?,?> config, Class<T> type) { - return PolicySpec.create(type).configure(config); - } - - protected PolicySpec(Class<T> type) { - super(type); - } - - protected void checkValidType(Class<? extends T> type) { - checkIsImplementation(type, Policy.class); - checkIsNewStyleImplementation(type); - } - - public PolicySpec<T> uniqueTag(String uniqueTag) { - flags.put("uniqueTag", uniqueTag); - return this; - } - -}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/policy/PolicyType.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/policy/PolicyType.java b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/policy/PolicyType.java deleted file mode 100644 index 2ba99c6..0000000 --- a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/policy/PolicyType.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 org.apache.brooklyn.api.policy; - -import org.apache.brooklyn.api.objs.BrooklynType; - -import com.google.common.annotations.Beta; - -/** - * Gives type information for a {@link Policy}. It is immutable. - * - * For policies that can support config keys etc being added on-the-fly, - * then this PolicyType will be a snapshot and subsequent snapshots will - * include the changes. - * - * @since 0.5 - */ -@Beta -public interface PolicyType extends BrooklynType { -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/relations/RelationshipType.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/relations/RelationshipType.java b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/relations/RelationshipType.java deleted file mode 100644 index 54162f2..0000000 --- a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/relations/RelationshipType.java +++ /dev/null @@ -1,38 +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.api.relations; - -import org.apache.brooklyn.api.relations.RelationshipType; - - -public interface RelationshipType<SourceType,TargetType> { - - public String getRelationshipTypeName(); - public Class<SourceType> getSourceType(); - public Class<TargetType> getTargetType(); - - public String getSourceName(); - public String getSourceNamePlural(); - - public String getTargetName(); - public String getTargetNamePlural(); - - public RelationshipType<TargetType,SourceType> getInverseRelationshipType(); - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/AttributeSensor.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/AttributeSensor.java b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/AttributeSensor.java deleted file mode 100644 index e200920..0000000 --- a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/AttributeSensor.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 org.apache.brooklyn.api.sensor; - -import com.google.common.annotations.Beta; - -/** - * The interface implemented by attribute sensors. - */ -public interface AttributeSensor<T> extends Sensor<T> { - - /** - * @since 0.7.0 - */ - @Beta - public enum SensorPersistenceMode { - /** - * Indicates that this sensor should be persisted, and its value should be read from - * persisted state on rebind. - */ - REQUIRED, - - /** - * Indicates that this sensor should not be persisted; therefore its value for any entity - * will be null immediately after rebind. - */ - NONE; - } - - /** - * The persistence mode of this sensor, to determine its behaviour for rebind. - * - * @since 0.7.0 - */ - SensorPersistenceMode getPersistenceMode(); -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/Enricher.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/Enricher.java b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/Enricher.java deleted file mode 100644 index 3fde2a5..0000000 --- a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/Enricher.java +++ /dev/null @@ -1,61 +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.api.sensor; - -import org.apache.brooklyn.api.mgmt.rebind.RebindSupport; -import org.apache.brooklyn.api.mgmt.rebind.Rebindable; -import org.apache.brooklyn.api.mgmt.rebind.mementos.EnricherMemento; -import org.apache.brooklyn.api.objs.Configurable; -import org.apache.brooklyn.api.objs.EntityAdjunct; -import org.apache.brooklyn.api.policy.Policy; - -import com.google.common.annotations.Beta; - -/** - * Publishes metrics for an entity, e.g. aggregating information from other sensors/entities. - * - * Has some similarities to {@link Policy}. However, enrichers specifically do not invoke - * effectors and should only function to publish new metrics. - */ -public interface Enricher extends EntityAdjunct, Rebindable, Configurable { - /** - * A unique id for this enricher. - */ - @Override - String getId(); - - /** - * Information about the type of this entity; analogous to Java's object.getClass. - */ - @Beta - EnricherType getEnricherType(); - - /** - * Users are strongly discouraged from calling or overriding this method. - * It is for internal calls only, relating to persisting/rebinding entities. - * This method may change (or be removed) in a future release without notice. - */ - @Override - @Beta - RebindSupport<EnricherMemento> getRebindSupport(); - - @Override - RelationSupport<Enricher> relations(); - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/EnricherSpec.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/EnricherSpec.java b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/EnricherSpec.java deleted file mode 100644 index ae50e2d..0000000 --- a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/EnricherSpec.java +++ /dev/null @@ -1,140 +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.api.sensor; - -import java.util.Map; - -import org.apache.brooklyn.api.internal.AbstractBrooklynObjectSpec; -import org.apache.brooklyn.api.mgmt.Task; -import org.apache.brooklyn.config.ConfigKey; -import org.apache.brooklyn.config.ConfigKey.HasConfigKey; - -/** - * Gives details of an enricher to be created. It describes the enricher's configuration, and is - * reusable to create multiple enrichers with the same configuration. - * - * To create an EnricherSpec, it is strongly encouraged to use {@code create(...)} methods. - * - * @param <T> The type of enricher to be created - * - * @author aled - */ -public class EnricherSpec<T extends Enricher> extends AbstractBrooklynObjectSpec<T,EnricherSpec<T>> { - - private static final long serialVersionUID = -6012873926010992062L; - - /** - * Creates a new {@link EnricherSpec} instance for an enricher of the given type. The returned - * {@link EnricherSpec} can then be customized. - * - * @param type A {@link Enricher} class - */ - public static <T extends Enricher> EnricherSpec<T> create(Class<? extends T> type) { - return new EnricherSpec<T>(type); - } - - /** - * Creates a new {@link EnricherSpec} instance with the given config, for an enricher of the given type. - * - * This is primarily for groovy code; equivalent to {@code EnricherSpec.create(type).configure(config)}. - * - * @param config The spec's configuration (see {@link EnricherSpec#configure(Map)}). - * @param type An {@link Enricher} class - */ - public static <T extends Enricher> EnricherSpec<T> create(Map<?,?> config, Class<? extends T> type) { - return EnricherSpec.create(type).configure(config); - } - - protected EnricherSpec(Class<? extends T> type) { - super(type); - } - - protected void checkValidType(Class<? extends T> type) { - checkIsImplementation(type, Enricher.class); - checkIsNewStyleImplementation(type); - } - - public EnricherSpec<T> uniqueTag(String uniqueTag) { - flags.put("uniqueTag", uniqueTag); - return this; - } - - public abstract static class ExtensibleEnricherSpec<T extends Enricher,K extends ExtensibleEnricherSpec<T,K>> extends EnricherSpec<T> { - private static final long serialVersionUID = -3649347642882809739L; - - protected ExtensibleEnricherSpec(Class<? extends T> type) { - super(type); - } - - @SuppressWarnings("unchecked") - protected K self() { - // we override the AbstractBrooklynObjectSpec method -- it's a different K here because - // EnricherSpec does not contain a parametrisable generic return type (Self) - return (K) this; - } - - @Override - public K uniqueTag(String uniqueTag) { - super.uniqueTag(uniqueTag); - return self(); - } - - @Override - public K configure(Map<?, ?> val) { - super.configure(val); - return self(); - } - - @Override - public K configure(CharSequence key, Object val) { - super.configure(key, val); - return self(); - } - - @Override - public <V> K configure(ConfigKey<V> key, V val) { - super.configure(key, val); - return self(); - } - - @Override - public <V> K configureIfNotNull(ConfigKey<V> key, V val) { - super.configureIfNotNull(key, val); - return self(); - } - - @Override - public <V> K configure(ConfigKey<V> key, Task<? extends V> val) { - super.configure(key, val); - return self(); - } - - @Override - public <V> K configure(HasConfigKey<V> key, V val) { - super.configure(key, val); - return self(); - } - - @Override - public <V> K configure(HasConfigKey<V> key, Task<? extends V> val) { - super.configure(key, val); - return self(); - } - } -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/EnricherType.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/EnricherType.java b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/EnricherType.java deleted file mode 100644 index e8aff97..0000000 --- a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/EnricherType.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 org.apache.brooklyn.api.sensor; - -import org.apache.brooklyn.api.objs.BrooklynType; - -import com.google.common.annotations.Beta; - -/** - * Gives type information for an {@link Enricher}. It is immutable. - * - * For enrichers that can support config keys etc being added on-the-fly, - * then this EnricherType will be a snapshot and subsequent snapshots will - * include the changes. - * - * @since 0.6 - */ -@Beta -public interface EnricherType extends BrooklynType { -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/Feed.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/Feed.java b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/Feed.java deleted file mode 100644 index d50e092..0000000 --- a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/Feed.java +++ /dev/null @@ -1,74 +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.api.sensor; - -import org.apache.brooklyn.api.mgmt.rebind.RebindSupport; -import org.apache.brooklyn.api.mgmt.rebind.Rebindable; -import org.apache.brooklyn.api.mgmt.rebind.mementos.FeedMemento; -import org.apache.brooklyn.api.objs.EntityAdjunct; - -import com.google.common.annotations.Beta; - -/** - * A sensor feed. - * These generally poll or subscribe to get sensor values for an entity. - * They make it easy to poll over http, jmx, etc. - * - * Assumes: - * <ul> - * <li>There will not be concurrent calls to start and stop. - * <li>There will only be one call to start and that will be done immediately after construction, - * in the same thread. - * <li>Once stopped, the feed will not be re-started. - * </ul> - */ -@Beta -public interface Feed extends EntityAdjunct, Rebindable { - - /** - * True if everything has been _started_ (or it is starting) but not stopped, - * even if it is suspended; see also {@link #isActive()} - */ - boolean isActivated(); - - void start(); - - /** suspends this feed (stops the poller, or indicates that the feed should start in a state where the poller is stopped) */ - void suspend(); - - boolean isSuspended(); - - /** resumes this feed if it has been suspended and not stopped */ - void resume(); - - void stop(); - - /** - * Users are strongly discouraged from calling or overriding this method. - * It is for internal calls only, relating to persisting/rebinding entities. - * This method may change (or be removed) in a future release without notice. - */ - @Override - @Beta - RebindSupport<FeedMemento> getRebindSupport(); - - @Override - RelationSupport<Feed> relations(); - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/Sensor.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/Sensor.java b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/Sensor.java deleted file mode 100644 index e658028..0000000 --- a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/Sensor.java +++ /dev/null @@ -1,77 +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.api.sensor; - -import java.io.Serializable; -import java.util.List; - -import org.apache.brooklyn.api.entity.Entity; - -import com.google.common.reflect.TypeToken; - -/** - * The interface implemented by concrete sensors. - * - * A sensor is a container for a piece of data of a particular type, and exists in a hierarchical namespace. - * The name of the sensor is described as a set of tokens separated by dots. - * - * @see SensorEvent - */ -public interface Sensor<T> extends Serializable { - /** - * Returns the Java {@link Class} for the sensor data. - * <p> - * This returns a "super" of T only in the case where T is generified, - * and in such cases it returns the Class instance for the unadorned T --- - * i.e. for List<String> this returns Class<List> --- - * this is of course because there is no actual Class<List<String>> instance. - */ - Class<? super T> getType(); - - /** - * Returns the Guava TypeToken (including generics info) - */ - TypeToken<T> getTypeToken(); - - /** - * Returns the type of the sensor data, as a {@link String} representation of the class name. - * (Useful for contexts where Type is not accessible.) - */ - String getTypeName(); - - /** - * Returns the name of the sensor, in a dot-separated namespace. - */ - String getName(); - - /** - * Returns the constituent parts of the sensor name as a {@link List}. - */ - List<String> getNameParts(); - - /** - * Returns the description of the sensor, for display. - */ - String getDescription(); - - /** - * Create a new {@link SensorEvent} object for a specific {@link Entity} and data point. - */ - SensorEvent<T> newEvent(Entity entity, T value); -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/SensorEvent.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/SensorEvent.java b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/SensorEvent.java deleted file mode 100644 index 02a7fef..0000000 --- a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/SensorEvent.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 org.apache.brooklyn.api.sensor; - -import org.apache.brooklyn.api.entity.Entity; - -/** - * A tuple representing a piece of data from a {@link Sensor} on an {@link Entity}. - */ -public interface SensorEvent<T> { - /** - * The {@link Entity} where the data originated. - */ - Entity getSource(); - - /** - * The {@link Sensor} describing the data. - */ - Sensor<T> getSensor(); - - /** - * The value for the {@link Sensor} data. - */ - T getValue(); - - /** - * The time this data was published, as a UTC time in milliseconds (e.g. as returned - * by {@link System#currentTimeMillis()}. - */ - long getTimestamp(); -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/SensorEventListener.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/SensorEventListener.java b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/SensorEventListener.java deleted file mode 100644 index 65fe81c..0000000 --- a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/sensor/SensorEventListener.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.api.sensor; - -import org.apache.brooklyn.api.entity.Entity; - -/** - * A listener for {@link SensorEvent}s on an {@link Entity}. - */ -public interface SensorEventListener<T> { - - public static final SensorEventListener<Object> NOOP = new SensorEventListener<Object>() { - @Override public void onEvent(SensorEvent<Object> event) { - } - }; - - /** - * The {@link SensorEvent} handler method. - */ - void onEvent(SensorEvent<T> event); -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/typereg/BrooklynTypeRegistry.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/typereg/BrooklynTypeRegistry.java b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/typereg/BrooklynTypeRegistry.java deleted file mode 100644 index 17a7fb3..0000000 --- a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/typereg/BrooklynTypeRegistry.java +++ /dev/null @@ -1,78 +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.api.typereg; - -import javax.annotation.Nullable; - -import org.apache.brooklyn.api.entity.Entity; -import org.apache.brooklyn.api.entity.EntitySpec; -import org.apache.brooklyn.api.internal.AbstractBrooklynObjectSpec; -import org.apache.brooklyn.util.guava.Maybe; - -import com.google.common.annotations.Beta; -import com.google.common.base.Predicate; - - -public interface BrooklynTypeRegistry { - - public enum RegisteredTypeKind { - /** a registered type which will create an {@link AbstractBrooklynObjectSpec} (e.g. {@link EntitySpec}) - * for the type registered (e.g. the {@link Entity} instance) */ - SPEC, - /** a registered type which will create the java type described */ - BEAN - // note: additional kinds should have the visitor in core/RegisteredTypeKindVisitor updated - // to flush out all places which want to implement support for all kinds - } - - Iterable<RegisteredType> getAll(); - Iterable<RegisteredType> getMatching(Predicate<? super RegisteredType> filter); - - /** @return The item matching the given given - * {@link RegisteredType#getSymbolicName() symbolicName} - * and optionally {@link RegisteredType#getVersion()}, - * taking the best version if the version is null or a default marker, - * returning null if no matches are found. */ - RegisteredType get(String symbolicName, String version); - /** as {@link #get(String, String)} but the given string here - * is allowed to match any of: - * <li>the given string as an ID including version (<code>"name:version"</code>) - * <li>the symbolic name unversioned, or - * <li>an alias */ - RegisteredType get(String symbolicNameWithOptionalVersion); - - /** as {@link #get(String)} but further filtering for the additional context */ - public RegisteredType get(String symbolicNameOrAliasWithOptionalVersion, RegisteredTypeLoadingContext context); - /** returns a wrapper of the result of {@link #get(String, RegisteredTypeLoadingContext)} - * including a detailed message if absent */ - public Maybe<RegisteredType> getMaybe(String symbolicNameOrAliasWithOptionalVersion, RegisteredTypeLoadingContext context); - - // NB the seemingly more correct generics <T,SpecT extends AbstractBrooklynObjectSpec<T,SpecT>> - // cause compile errors, not in Eclipse, but in maven (?) - // TODO do these belong here, or in a separate master TypePlanTransformer ? see also BrooklynTypePlanTransformer - @Beta - <SpecT extends AbstractBrooklynObjectSpec<?,?>> SpecT createSpec(RegisteredType type, @Nullable RegisteredTypeLoadingContext optionalContext, @Nullable Class<SpecT> optionalSpecSuperType); - @Beta - <SpecT extends AbstractBrooklynObjectSpec<?,?>> SpecT createSpecFromPlan(@Nullable String planFormat, Object planData, @Nullable RegisteredTypeLoadingContext optionalContext, @Nullable Class<SpecT> optionalSpecSuperType); - @Beta - <T> T createBean(RegisteredType type, @Nullable RegisteredTypeLoadingContext optionalContext, @Nullable Class<T> optionalResultSuperType); - @Beta - <T> T createBeanFromPlan(String planFormat, Object planData, @Nullable RegisteredTypeLoadingContext optionalConstraint, @Nullable Class<T> optionalBeanSuperType); - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/typereg/OsgiBundleWithUrl.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/typereg/OsgiBundleWithUrl.java b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/typereg/OsgiBundleWithUrl.java deleted file mode 100644 index e8b278b..0000000 --- a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/typereg/OsgiBundleWithUrl.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 org.apache.brooklyn.api.typereg; - -import com.google.common.annotations.Beta; - -@Beta -public interface OsgiBundleWithUrl { - - public String getSymbolicName(); - public String getVersion(); - - /** where this bundle can be downloaded; typically required unless we are guaranteed the bundle will be manually installed */ - public String getUrl(); - - /** @return true if we have a name and version for this bundle; - * false if not, e.g. if we only know the URL and we haven't loaded it yet */ - public boolean isNameResolved(); - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/typereg/RegisteredType.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/typereg/RegisteredType.java b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/typereg/RegisteredType.java deleted file mode 100644 index 29b64d3..0000000 --- a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/typereg/RegisteredType.java +++ /dev/null @@ -1,96 +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.api.typereg; - -import java.util.Collection; -import java.util.Set; - -import org.apache.brooklyn.api.entity.Entity; -import org.apache.brooklyn.api.entity.EntitySpec; -import org.apache.brooklyn.api.objs.BrooklynObject; -import org.apache.brooklyn.api.objs.Identifiable; -import org.apache.brooklyn.api.typereg.BrooklynTypeRegistry.RegisteredTypeKind; - -import com.google.common.annotations.Beta; - -public interface RegisteredType extends Identifiable { - - @Override String getId(); - - RegisteredTypeKind getKind(); - - String getSymbolicName(); - String getVersion(); - - Collection<OsgiBundleWithUrl> getLibraries(); - - String getDisplayName(); - String getDescription(); - String getIconUrl(); - - /** @return all declared supertypes or super-interfaces of this registered type, - * consisting of a collection of {@link Class} or {@link RegisteredType} - * <p> - * This should normally include at least one {@link Class} object: - * For beans, this should include the java type that the {@link BrooklynTypeRegistry} will create. - * For specs, this should refer to the {@link BrooklynObject} type that the created spec will point at - * (e.g. the concrete {@link Entity}, not the {@link EntitySpec}). - * <p> - * This may not necessarily return the most specific java class or classes; - * such as if the concrete type is private and callers should know only about a particular public interface, - * or if precise type details are unavailable and all that is known at creation is some higher level interface/supertype - * (e.g. this may return {@link Entity} even though the spec points at a specific subclass, - * for instance because the YAML has not yet been parsed or OSGi bundles downloaded). - * <p> - * This may include other registered types such as marker interfaces. - */ - @Beta - Set<Object> getSuperTypes(); - - /** - * @return True if the item has been deprecated (i.e. its use is discouraged) - */ - boolean isDeprecated(); - - /** - * @return True if the item has been disabled (i.e. its use is forbidden, except for pre-existing apps) - */ - boolean isDisabled(); - - /** Alias words defined for this type */ - Set<String> getAliases(); - - /** Tags attached to this item */ - Set<Object> getTags(); - - /** @return implementation details, so that the framework can find a suitable {@link BrooklynTypePlanTransformer} - * which can then use this object to instantiate this type */ - TypeImplementationPlan getPlan(); - - public interface TypeImplementationPlan { - /** hint which {@link BrooklynTypePlanTransformer} instance(s) can be used, if known; - * this may be null if the relevant transformer was not declared when created, - * but in general we should look to determine the kind as early as possible - * and use that to retrieve the appropriate such transformer */ - String getPlanFormat(); - /** data for the implementation; may be more specific */ - Object getPlanData(); - } - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/typereg/RegisteredTypeLoadingContext.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/typereg/RegisteredTypeLoadingContext.java b/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/typereg/RegisteredTypeLoadingContext.java deleted file mode 100644 index d37666e..0000000 --- a/brooklyn-server/api/src/main/java/org/apache/brooklyn/api/typereg/RegisteredTypeLoadingContext.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.brooklyn.api.typereg; - -import java.util.Set; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import org.apache.brooklyn.api.entity.Entity; -import org.apache.brooklyn.api.entity.EntitySpec; -import org.apache.brooklyn.api.mgmt.classloading.BrooklynClassLoadingContext; -import org.apache.brooklyn.api.typereg.BrooklynTypeRegistry.RegisteredTypeKind; - -public interface RegisteredTypeLoadingContext { - - /** The kind required, if specified. */ - @Nullable public RegisteredTypeKind getExpectedKind(); - - /** A java super-type or interface that should be filtered for; - * for specs, this refers to the target type, not the spec - * (eg {@link Entity} not {@link EntitySpec}). - * If nothing is specified, this returns {@link Object}'s class. */ - @Nonnull public Class<?> getExpectedJavaSuperType(); - - /** encountered types, so that during resolution, - * if we have already attempted to resolve a given type, - * the instantiator can avoid recursive cycles */ - @Nonnull public Set<String> getAlreadyEncounteredTypes(); - - /** A loader to use, supplying additional search paths */ - @Nullable public BrooklynClassLoadingContext getLoader(); - -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/README.md ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/README.md b/brooklyn-server/camp/README.md deleted file mode 100644 index 225e18e..0000000 --- a/brooklyn-server/camp/README.md +++ /dev/null @@ -1,34 +0,0 @@ -OASIS CAMP Server -================= - -The projects in this directory provide the necessary components for a server which -speaks the CAMP REST API and which understands the CAMP YAML plan language. - -It is not dependent on Brooklyn (apart from utils) and does not expose any -types. The brooklyn-camp project provides the links for Brooklyn entities -to be available through the CAMP REST API, and for Brooklyn to deploy blueprints -described using the CAMP YAML. - -The projects in this directory are designed so they could be used to build -other CAMP servers not based on Brooklyn, if desired. - -These projects are part of the Apache Software Foundation Brooklyn project -(https://brooklyn.incubator.apache.org) and released under the Apache License 2.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. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-base/notes.txt ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-base/notes.txt b/brooklyn-server/camp/camp-base/notes.txt deleted file mode 100644 index f18b5d3..0000000 --- a/brooklyn-server/camp/camp-base/notes.txt +++ /dev/null @@ -1,83 +0,0 @@ - -DONE - -SOME of these (for PCT's and ACT's) -* dto classes and endpoints (jersey resources) to have a rest server -* impl classes (abstract or composable?) which can make dto's -* connect impl classes to brooklyn - -TODO - -* remaining classes -* PDP formation - - - - - - -THOUGHTS - -* get camp.io -* project for camp-ops, camp-samp-le-server - - - - - - -COMPARISON - -CAMP -* platform offers PlatformComponentTemplates (e.g. elasttic AppServer cluster) which a user can - stitch together in an AssemblyTemplate to create an Assembly which is their application; - user can also supply ApplicationComponentTemplate and ApplicationComponent instances - (e.g. WAR files) for use in assemblies; - and Requirements and Capabilities can be defined to e.g. indicate that a 3-tier app - Template requires a WAR file and a schema (from the user) and PlatformComponents - where these will run (from the platform) which get resolved at real-time - with as little or as much guidance from the user as desired; - relies on conventions on types and tags (ie not specified in spec, yet) to facilitate re-use; -* defines REST API for interacting with these, and uploading assemblies and app components - (not platform components) -* example - -TOSCA - ServiceTemplate is the basic idea - Types - NodeType - RelationshipType - TopologyTemplate - NodeTemplate - RelationshipTemplate - GroupTemplate - internal elements - Artifacts: - "deployment artifacts" for creating nodes, - "implementation artifacts" for operations) - Container capabilities / requirements - Properties, operations, scripts, constraints - Policies - Plans - Plan - -END - - ----- -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-base/pom.xml ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-base/pom.xml b/brooklyn-server/camp/camp-base/pom.xml deleted file mode 100644 index 063f665..0000000 --- a/brooklyn-server/camp/camp-base/pom.xml +++ /dev/null @@ -1,96 +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> - <packaging>jar</packaging> - - <artifactId>camp-base</artifactId> - - <name>CAMP Base</name> - <description> - Core base classes for CAMP server implementation - </description> - - <parent> - <groupId>org.apache.brooklyn.camp</groupId> - <artifactId>camp-parent</artifactId> - <version>0.9.0-SNAPSHOT</version> <!-- BROOKLYN_VERSION --> - <relativePath>../pom.xml</relativePath> - </parent> - - <dependencies> - <dependency> - <groupId>org.apache.brooklyn</groupId> - <artifactId>brooklyn-utils-common</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.brooklyn</groupId> - <artifactId>brooklyn-utils-test-support</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.testng</groupId> - <artifactId>testng</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-compress</artifactId> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - </dependency> - <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - </dependency> - <dependency> - <groupId>com.google.code.findbugs</groupId> - <artifactId>jsr305</artifactId> - </dependency> - - <!-- just for logging, not exported --> - <!-- - <dependency> - <groupId>org.apache.brooklyn</groupId> - <artifactId>brooklyn-logback-xml</artifactId> - <version>${project.version}</version> - <optional>true</optional> - <scope>tests</scope> - </dependency> - <dependency> - <groupId>org.apache.brooklyn</groupId> - <artifactId>brooklyn-core</artifactId> - <version>${project.version}</version> - <optional>true</optional> - <scope>tests</scope> - </dependency> - --> - - </dependencies> - -</project> http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/AggregatingCampPlatform.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/AggregatingCampPlatform.java b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/AggregatingCampPlatform.java deleted file mode 100644 index 137e927..0000000 --- a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/AggregatingCampPlatform.java +++ /dev/null @@ -1,130 +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; - -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nullable; - -import org.apache.brooklyn.camp.spi.AbstractResource; -import org.apache.brooklyn.camp.spi.ApplicationComponent; -import org.apache.brooklyn.camp.spi.ApplicationComponentTemplate; -import org.apache.brooklyn.camp.spi.Assembly; -import org.apache.brooklyn.camp.spi.AssemblyTemplate; -import org.apache.brooklyn.camp.spi.PlatformComponent; -import org.apache.brooklyn.camp.spi.PlatformComponentTemplate; -import org.apache.brooklyn.camp.spi.PlatformRootSummary; -import org.apache.brooklyn.camp.spi.PlatformTransaction; -import org.apache.brooklyn.camp.spi.collection.AggregatingResourceLookup; -import org.apache.brooklyn.camp.spi.collection.ResourceLookup; -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/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/BasicCampPlatform.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/BasicCampPlatform.java b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/BasicCampPlatform.java deleted file mode 100644 index 34fc6a2..0000000 --- a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/BasicCampPlatform.java +++ /dev/null @@ -1,142 +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; - -import java.util.concurrent.atomic.AtomicBoolean; - -import org.apache.brooklyn.camp.spi.ApplicationComponent; -import org.apache.brooklyn.camp.spi.ApplicationComponentTemplate; -import org.apache.brooklyn.camp.spi.Assembly; -import org.apache.brooklyn.camp.spi.AssemblyTemplate; -import org.apache.brooklyn.camp.spi.PlatformComponent; -import org.apache.brooklyn.camp.spi.PlatformComponentTemplate; -import org.apache.brooklyn.camp.spi.PlatformRootSummary; -import org.apache.brooklyn.camp.spi.PlatformTransaction; -import org.apache.brooklyn.camp.spi.collection.BasicResourceLookup; -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/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/CampPlatform.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/CampPlatform.java b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/CampPlatform.java deleted file mode 100644 index 817dae8..0000000 --- a/brooklyn-server/camp/camp-base/src/main/java/org/apache/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 org.apache.brooklyn.camp; - -import org.apache.brooklyn.camp.spi.ApplicationComponent; -import org.apache.brooklyn.camp.spi.ApplicationComponentTemplate; -import org.apache.brooklyn.camp.spi.Assembly; -import org.apache.brooklyn.camp.spi.AssemblyTemplate; -import org.apache.brooklyn.camp.spi.PlatformComponent; -import org.apache.brooklyn.camp.spi.PlatformComponentTemplate; -import org.apache.brooklyn.camp.spi.PlatformRootSummary; -import org.apache.brooklyn.camp.spi.PlatformTransaction; -import org.apache.brooklyn.camp.spi.collection.ResourceLookup; -import org.apache.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/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/commontypes/RepresentationSkew.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/commontypes/RepresentationSkew.java b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/commontypes/RepresentationSkew.java deleted file mode 100644 index 01cece9..0000000 --- a/brooklyn-server/camp/camp-base/src/main/java/org/apache/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 org.apache.brooklyn.camp.commontypes; - -public enum RepresentationSkew { - CREATING, NONE, DESTROYING, UNKNOWN -} 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/AbstractResource.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/AbstractResource.java b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/AbstractResource.java deleted file mode 100644 index c24eab1..0000000 --- a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/AbstractResource.java +++ /dev/null @@ -1,195 +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; - -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.apache.brooklyn.camp.commontypes.RepresentationSkew; -import org.apache.brooklyn.util.collections.MutableMap; -import org.apache.brooklyn.util.text.Identifiers; -import org.apache.brooklyn.util.time.Time; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.collect.ImmutableList; - -/** 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 MutableMap.copyOf(customAttributes).asUnmodifiable(); - } - - // 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/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/ApplicationComponent.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/ApplicationComponent.java b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/ApplicationComponent.java deleted file mode 100644 index 6ece4d0..0000000 --- a/brooklyn-server/camp/camp-base/src/main/java/org/apache/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 org.apache.brooklyn.camp.spi; - -import org.apache.brooklyn.camp.spi.collection.BasicResourceLookup; -import org.apache.brooklyn.camp.spi.collection.ResourceLookup; -import org.apache.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/brooklyn-server/blob/d03f254b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/ApplicationComponentTemplate.java ---------------------------------------------------------------------- diff --git a/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/ApplicationComponentTemplate.java b/brooklyn-server/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/ApplicationComponentTemplate.java deleted file mode 100644 index bd9d69d..0000000 --- a/brooklyn-server/camp/camp-base/src/main/java/org/apache/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 org.apache.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(); } - } - -}
