http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/entity/basic/EntityLocal.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/entity/basic/EntityLocal.java b/api/src/main/java/brooklyn/entity/basic/EntityLocal.java deleted file mode 100644 index a302768..0000000 --- a/api/src/main/java/brooklyn/entity/basic/EntityLocal.java +++ /dev/null @@ -1,180 +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 brooklyn.entity.basic; - -import java.util.Map; - -import org.apache.brooklyn.management.SubscriptionContext; -import org.apache.brooklyn.management.SubscriptionHandle; -import org.apache.brooklyn.management.SubscriptionManager; -import org.apache.brooklyn.management.Task; - -import brooklyn.config.ConfigKey; -import brooklyn.config.ConfigKey.HasConfigKey; -import brooklyn.entity.Entity; -import brooklyn.entity.Group; -import brooklyn.entity.trait.Configurable; -import brooklyn.event.AttributeSensor; -import brooklyn.event.Sensor; -import brooklyn.event.SensorEvent; -import brooklyn.event.SensorEventListener; -import brooklyn.util.guava.Maybe; - -import com.google.common.annotations.Beta; -import com.google.common.base.Function; - -/** - * Extended Entity interface for use in places where the caller should have certain privileges, - * such as setting attribute values, adding policies, etc. - * - * FIXME Moved from core project to api project because of bug in groovy's covariant return types. - * EntityDriver needs to return EntityLocal rather than Entity, to avoid changing a whole load - * of sub-types. - * FIXME Add {@link setAttribute(AttributeSensorAndConfigKey<?,T>)} back in if/when move it back, - * or if we extract an interface for AttributeSensorAndConfigKey. - */ -public interface EntityLocal extends Entity { - - // FIXME Rename to something other than EntityLocal. - // Separate out what is specific to "local jvm", and what is here for an SPI rather than API. - - /** - * Sets the entity's display name. - * Must be called before the entity is managed. - */ - void setDisplayName(String displayName); - - /** - * @deprecated since 0.7.0; use {@link #config()}, such as {@code entity.config().set(key, val)} - */ - @Deprecated - <T> T setConfig(ConfigKey<T> key, T val); - - /** - * @deprecated since 0.7.0; use {@link #config()}, such as {@code entity.config().set(key, val)} - */ - @Deprecated - <T> T setConfig(ConfigKey<T> key, Task<T> val); - - /** - * @deprecated since 0.7.0; use {@link #config()}, such as {@code entity.config().set(key, val)} - */ - @Deprecated - <T> T setConfig(HasConfigKey<T> key, T val); - - /** - * @deprecated since 0.7.0; use {@link #config()}, such as {@code entity.config().set(key, val)} - */ - @Deprecated - <T> T setConfig(HasConfigKey<T> key, Task<T> val); - - /** - * Sets the {@link AttributeSensor} data for the given attribute to the specified value. - * - * This can be used to "enrich" the entity, such as adding aggregated information, - * rolling averages, etc. - * - * @return the old value for the attribute (possibly {@code null}) - */ - <T> T setAttribute(AttributeSensor<T> attribute, T val); - - /** - * Atomically modifies the {@link AttributeSensor}, ensuring that only one modification is done - * at a time. - * - * If the modifier returns {@link Maybe#absent()} then the attribute will be - * left unmodified, and the existing value will be returned. - * - * For details of the synchronization model used to achieve this, refer to the underlying - * attribute store (e.g. AttributeMap). - * - * @return the old value for the attribute (possibly {@code null}) - * @since 0.7.0-M2 - */ - @Beta - <T> T modifyAttribute(AttributeSensor<T> attribute, Function<? super T, Maybe<T>> modifier); - - /** - * @deprecated in 0.5; use {@link #getConfig(ConfigKey)} - */ - <T> T getConfig(ConfigKey<T> key, T defaultValue); - - /** - * @deprecated in 0.5; use {@link #getConfig(HasConfigKey)} - */ - <T> T getConfig(HasConfigKey<T> key, T defaultValue); - - /** - * Emits a {@link SensorEvent} event on behalf of this entity (as though produced by this entity). - * <p> - * Note that for attribute sensors it is nearly always recommended to use setAttribute, - * as this method will not update local values. - */ - <T> void emit(Sensor<T> sensor, T value); - - /** - * Allow us to subscribe to data from a {@link Sensor} on another entity. - * - * @return a subscription id which can be used to unsubscribe - * - * @see SubscriptionManager#subscribe(Map, Entity, Sensor, SensorEventListener) - */ - // FIXME remove from interface? - @Beta - <T> SubscriptionHandle subscribe(Entity producer, Sensor<T> sensor, SensorEventListener<? super T> listener); - - /** @see SubscriptionManager#subscribeToChildren(Map, Entity, Sensor, SensorEventListener) */ - // FIXME remove from interface? - @Beta - <T> SubscriptionHandle subscribeToChildren(Entity parent, Sensor<T> sensor, SensorEventListener<? super T> listener); - - /** @see SubscriptionManager#subscribeToMembers(Group, Sensor, SensorEventListener) */ - // FIXME remove from interface? - @Beta - <T> SubscriptionHandle subscribeToMembers(Group group, Sensor<T> sensor, SensorEventListener<? super T> listener); - - /** - * Unsubscribes from the given producer. - * - * @see SubscriptionContext#unsubscribe(SubscriptionHandle) - */ - @Beta - boolean unsubscribe(Entity producer); - - /** - * Unsubscribes the given handle. - * - * @see SubscriptionContext#unsubscribe(SubscriptionHandle) - */ - @Beta - boolean unsubscribe(Entity producer, SubscriptionHandle handle); - - /** - * Removes all policy from this entity. - * @return True if any policies existed at this entity; false otherwise - */ - boolean removeAllPolicies(); - - /** - * Removes all enricher from this entity. - * Use with caution as some entities automatically register enrichers; this will remove those enrichers as well. - * @return True if any enrichers existed at this entity; false otherwise - */ - boolean removeAllEnrichers(); -}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/entity/drivers/DriverDependentEntity.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/entity/drivers/DriverDependentEntity.java b/api/src/main/java/brooklyn/entity/drivers/DriverDependentEntity.java deleted file mode 100644 index 93cb889..0000000 --- a/api/src/main/java/brooklyn/entity/drivers/DriverDependentEntity.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 brooklyn.entity.drivers; - -import javax.annotation.Nullable; - -import brooklyn.entity.Entity; - -/** - * An Entity that needs to have a driver. - * - * @param <D> - */ -public interface DriverDependentEntity<D extends EntityDriver> extends Entity { - - Class<D> getDriverInterface(); - - @Nullable D getDriver(); - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/entity/drivers/EntityDriver.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/entity/drivers/EntityDriver.java b/api/src/main/java/brooklyn/entity/drivers/EntityDriver.java deleted file mode 100644 index 600f49b..0000000 --- a/api/src/main/java/brooklyn/entity/drivers/EntityDriver.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 brooklyn.entity.drivers; - -import brooklyn.entity.basic.EntityLocal; -import brooklyn.location.Location; - -import com.google.common.annotations.Beta; - -/** - * The EntityDriver provides an abstraction between the Entity and the environment (the {@link Location} it is running - * in, so that an entity is not tightly coupled to a specific Location. E.g. you could have a TomcatEntity that uses - * a TomcatDriver (an interface) and you could have different driver implementations like the - * TomcatSshDriver/TomcatWindowsDriver and if in the future support for Puppet needs to be added, a TomcatPuppetDriver - * could be added. - * - * @author Peter Veentjer. - * @see DriverDependentEntity - * @see EntityDriverManager - */ -public interface EntityDriver { - - /** - * The entity instance that this is a driver for. - * - * FIXME The signature of this will change to return Entity instead of EntityLocal. - * This is a temporary workaround for groovy not supporting covariant return types, - * see http://jira.codehaus.org/browse/GROOVY-5418. It is fixed in groovy 2.0.4 so - * we will need to upgrade from 1.8.6 first. - */ - @Beta - EntityLocal getEntity(); - - /** - * The location the entity is running in. - */ - Location getLocation(); -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/entity/drivers/EntityDriverManager.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/entity/drivers/EntityDriverManager.java b/api/src/main/java/brooklyn/entity/drivers/EntityDriverManager.java deleted file mode 100644 index c0d2d95..0000000 --- a/api/src/main/java/brooklyn/entity/drivers/EntityDriverManager.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 brooklyn.entity.drivers; - -import brooklyn.location.Location; - -/** - * Responsible for creating a driver for a given entity/location. Also used for customizing which - * type of driver should be used by entities in given locations. - * - * The idea is that an entity should not be tightly coupled to a specific driver implementation, - * so that there is flexibility for driver changes, without changing the entity itself. The - * advantage is that drivers can easily be reconfigured, replaced or new drivers for different - * environments can be added, without needing to modify Brooklyn. - * - * To obtain an instance of a driver, use {@link #build(DriverDependentEntity, Location)}. - * This will use the registered driver types, or if one is not registered will fallback to the - * default strategy. - */ -public interface EntityDriverManager { - - /** - * Builds a new {@link EntityDriver} for the given entity/location. - * - * @param entity the {@link DriverDependentEntity} to create the {@link EntityDriver} for. - * @param location the {@link Location} where the {@link DriverDependentEntity} is running. - * @param <D> - * @return the creates EntityDriver. - */ - <D extends EntityDriver> D build(DriverDependentEntity<D> entity, Location location); - - <D extends EntityDriver> void registerDriver(Class<D> driverInterface, Class<? extends Location> locationClazz, Class<? extends D> driverClazz); -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/entity/drivers/downloads/DownloadResolver.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/entity/drivers/downloads/DownloadResolver.java b/api/src/main/java/brooklyn/entity/drivers/downloads/DownloadResolver.java deleted file mode 100644 index 430a42c..0000000 --- a/api/src/main/java/brooklyn/entity/drivers/downloads/DownloadResolver.java +++ /dev/null @@ -1,58 +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 brooklyn.entity.drivers.downloads; - -import java.util.List; - -import com.google.common.annotations.Beta; - -/** - * Gives download details for an entity or an entity add-on. - * Returned by the {@link DownloadResolverManager}, when queried for a specific entity or entity add-on. - * - * @author aled - */ -public interface DownloadResolver { - /** - * The targets (normally URLs) for downloading the artifact. These should be tried in-order - * until one works. - */ - public List<String> getTargets(); - - /** - * The name of the artifact. - * The caller is free to use this name, or not. But using this name gives consistency particularly - * between brooklyn local-repos and brooklyn install directories. - */ - public String getFilename(); - - /** - * The name of the directory in the expanded artifact (e.g. if it's a tar.gz file then the name of - * the directory within it). If no value is known, the defaultVal will be returned. - * - * This can return null if the artifact is not an archive (and if defaultVal is null). - * - * TODO The driver needs to know what will happen when an install archive is unpacked (e.g. an - * AS7 install tgz may be automatically expanded into a directory named "jboss-as-7.1.1-FINAL"). - * However, it's unclear where the best place to encode that is. The driver supplying the default - * seems sensible. - */ - @Beta - public String getUnpackedDirectoryName(String defaultVal); -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/entity/drivers/downloads/DownloadResolverManager.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/entity/drivers/downloads/DownloadResolverManager.java b/api/src/main/java/brooklyn/entity/drivers/downloads/DownloadResolverManager.java deleted file mode 100644 index 9b8ed66..0000000 --- a/api/src/main/java/brooklyn/entity/drivers/downloads/DownloadResolverManager.java +++ /dev/null @@ -1,158 +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 brooklyn.entity.drivers.downloads; - -import java.util.List; -import java.util.Map; - -import brooklyn.entity.drivers.EntityDriver; - -import com.google.common.base.Function; - -/** - * Used by an {@link EntityDriver} to obtain the download locations when installing an entity. - * - * Most commonly, the {@link DownloadResolver}'s targets are URIs. However, an EntityDriver - * implementation is free to interpret the String however is appropriate (e.g. the name of a - * custom package to install from the enterprise's package manager repository). - - * Also supports registering other "resolvers" for determining where to download the installers - * from, for different entities. - * - * When using {@link resolve(EntityDriver)} to get the list of things to try (in-order until one succeeds), - * the manager will go through each of the registered resolvers in-order to get their contributions. - * These contributions are split into "primary" and "fallback". All of the primaries will be added to the - * list first, and then all of the fallbacks. - * - * @author aled - */ -public interface DownloadResolverManager { - - /** - * For installing the main entity. - * Returns a list of options, to be tried in order until one of them works. - */ - public DownloadResolver newDownloader(EntityDriver driver); - - /** - * For installing the main entity. - * Returns a list of options, to be tried in order until one of them works. - */ - public DownloadResolver newDownloader(EntityDriver driver, Map<String,?> properties); - - /** - * For installing an entity add-on. - * Returns a list of options, to be tried in order until one of them works. - * This is used for resolving the download for an "add-on" - e.g. an additional module required - * during an entity's installation. Common properties include: - * <ul> - * <li>addonversion: the required version of the add-on - * </ul> - */ - public DownloadResolver newDownloader(EntityDriver driver, String addonName, Map<String,?> addonProperties); - - /** - * Registers a producer, to be tried before all other producers. - * - * A "producer" will generate the download targets to be tried, when installing a given entity - * or entity add-on. - * - * The function should not return null (instead see {@code BasicDownloadTargets.empty()}). - * - * @see registerResolver(Function) - */ - public void registerPrimaryProducer(Function<? super DownloadRequirement, ? extends DownloadTargets> resolver); - - /** - * Registers a producer, to be tried after all other registered producers have been tried. - * The function should not return null (instead see {@code BasicDownloadTargets.empty()}). - */ - public void registerProducer(Function<? super DownloadRequirement, ? extends DownloadTargets> resolver); - - /** - * Registers a producer for generating the expected filename of the download artifact. - * - * If all such registered producers return null, then default behaviour is to infer the download - * name from the first target in the {@link resolve(EntityDriver)} result. - */ - public void registerFilenameProducer(Function<? super DownloadRequirement, String> producer); - - /** - * Gives artifact meta-data for what is required to be downloaded. - * - * @author aled - */ - public interface DownloadRequirement { - /** - * The {@link EntityDriver} that this download is for. - */ - public EntityDriver getEntityDriver(); - - /** - * The name of the add-on to be downloaded, or null if it is the main installed. - * For example, can be used to specify nginx sticky-module or pcre download. - */ - public String getAddonName(); - - /** - * Default properties for this download. These will be made available when resolving the - * download template. - * - * For the main entity download, properties include: - * <ul> - * <li>fileSuffix: expected file suffix - * </ul> - * - * For an add-on, common properties include: - * <ul> - * <li>version: version of the add-on to be used - * <li>fileSuffix: expected file suffix - * </ul> - */ - public Map<String, ?> getProperties(); - } - - - /** - * Describes the download locations, and their order, to try. - * - * @author aled - */ - public interface DownloadTargets { - /** - * Gets the locations to try (in-order). - */ - public List<String> getPrimaryLocations(); - - /** - * Gets the locations to try (in-order), to be used only after all primary locations - * have been tried. - */ - public List<String> getFallbackLocations(); - - /** - * Indicates whether or not the results of this resolver are the last that should be used. - * If returns false, {@link resolve(EntityDriver)} will not iterate over any other resolvers. - * - * For example, useful in an enterprise to disable any other resolvers that would have - * resulted in going out to the public internet. - */ - public boolean canContinueResolving(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/entity/proxying/EntityInitializer.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/entity/proxying/EntityInitializer.java b/api/src/main/java/brooklyn/entity/proxying/EntityInitializer.java deleted file mode 100644 index 2954451..0000000 --- a/api/src/main/java/brooklyn/entity/proxying/EntityInitializer.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 brooklyn.entity.proxying; - -import java.util.Map; - -import brooklyn.entity.basic.EntityLocal; - -/** - * Instances of this class supply logic which can be used to initialize entities. - * These can be added to an {@link EntitySpec} programmatically, or declared as part - * of YAML recipes in a <code>brooklyn.initializers</code> section. - * In the case of the latter, implementing classes should define a no-arg constructor - * or a {@link Map} constructor so that YAML parameters can be supplied. - **/ -public interface EntityInitializer { - - /** Applies initialization logic to a just-built entity. - * Invoked immediately after the "init" call on the AbstractEntity constructed. - * - * @param entity guaranteed to be the actual implementation instance, - * thus guaranteed to be castable to EntityInternal which is often desired, - * or to the type at hand (it is not even a proxy) - */ - public void apply(EntityLocal entity); - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/entity/proxying/EntitySpec.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/entity/proxying/EntitySpec.java b/api/src/main/java/brooklyn/entity/proxying/EntitySpec.java deleted file mode 100644 index ebbf486..0000000 --- a/api/src/main/java/brooklyn/entity/proxying/EntitySpec.java +++ /dev/null @@ -1,473 +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 brooklyn.entity.proxying; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.annotation.Nullable; - -import org.apache.brooklyn.api.basic.AbstractBrooklynObjectSpec; -import org.apache.brooklyn.management.Task; -import org.apache.brooklyn.policy.Enricher; -import org.apache.brooklyn.policy.EnricherSpec; -import org.apache.brooklyn.policy.Policy; -import org.apache.brooklyn.policy.PolicySpec; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import brooklyn.config.ConfigKey; -import brooklyn.config.ConfigKey.HasConfigKey; -import brooklyn.entity.Entity; -import brooklyn.entity.Group; -import brooklyn.location.Location; -import brooklyn.util.collections.MutableList; - -import com.google.common.base.Supplier; -import com.google.common.base.Throwables; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - -/** - * Gives details of an entity to be created. It describes the entity's configuration, and is - * reusable to create multiple entities with the same configuration. - * - * To create an EntitySpec, it is strongly encouraged to use {@link #create(Class)} etc. - * Users who need to implement this are strongly encouraged to extend - * {@link brooklyn.entity.proxying.EntitySpec}. - * - * @param <T> The type of entity to be created - * - * @author aled - */ -public class EntitySpec<T extends Entity> extends AbstractBrooklynObjectSpec<T,EntitySpec<T>> { - - private static final long serialVersionUID = -2247153452919128990L; - - private static final Logger log = LoggerFactory.getLogger(EntitySpec.class); - - /** - * Creates a new {@link EntitySpec} instance for an entity of the given type. The returned - * {@link EntitySpec} can then be customized. - * - * @param type An {@link Entity} interface - */ - public static <T extends Entity> EntitySpec<T> create(Class<T> type) { - return new EntitySpec<T>(type); - } - - /** - * Creates a new {@link EntitySpec} instance for an entity of the given type. The returned - * {@link EntitySpec} can then be customized. - * - * @param type An {@link Entity} interface - * @param implType An {@link Entity} implementation, which implements the {@code type} interface - */ - public static <T extends Entity, U extends T> EntitySpec<T> create(Class<T> type, Class<U> implType) { - return new EntitySpec<T>(type).impl(implType); - } - - /** - * Creates a new {@link EntitySpec} instance with the given config, for an entity of the given type. - * - * This is primarily for groovy code; equivalent to {@code EntitySpec.create(type).configure(config)}. - * - * @param config The spec's configuration (see {@link EntitySpec#configure(Map)}). - * @param type An {@link Entity} interface - */ - public static <T extends Entity> EntitySpec<T> create(Map<?,?> config, Class<T> type) { - return EntitySpec.create(type).configure(config); - } - - /** - * Copies entity spec so its configuration can be overridden without modifying the - * original entity spec. - */ - public static <T extends Entity> EntitySpec<T> create(EntitySpec<T> spec) { - EntitySpec<T> result = create(spec.getType()) - .displayName(spec.getDisplayName()) - .tags(spec.getTags()) - .additionalInterfaces(spec.getAdditionalInterfaces()) - .configure(spec.getConfig()) - .configure(spec.getFlags()) - .policySpecs(spec.getPolicySpecs()) - .policies(spec.getPolicies()) - .enricherSpecs(spec.getEnricherSpecs()) - .enrichers(spec.getEnrichers()) - .addInitializers(spec.getInitializers()) - .children(spec.getChildren()) - .members(spec.getMembers()) - .groups(spec.getGroups()) - .catalogItemId(spec.getCatalogItemId()) - .locations(spec.getLocations()); - - if (spec.getParent() != null) result.parent(spec.getParent()); - if (spec.getImplementation() != null) result.impl(spec.getImplementation()); - - return result; - } - - public static <T extends Entity> EntitySpec<T> newInstance(Class<T> type) { - return new EntitySpec<T>(type); - } - - private Class<? extends T> impl; - private Entity parent; - private final Map<String, Object> flags = Maps.newLinkedHashMap(); - private final Map<ConfigKey<?>, Object> config = Maps.newLinkedHashMap(); - private final List<Policy> policies = Lists.newArrayList(); - private final List<PolicySpec<?>> policySpecs = Lists.newArrayList(); - private final List<Enricher> enrichers = Lists.newArrayList(); - private final List<EnricherSpec<?>> enricherSpecs = Lists.newArrayList(); - private final List<Location> locations = Lists.newArrayList(); - private final Set<Class<?>> additionalInterfaces = Sets.newLinkedHashSet(); - private final List<EntityInitializer> entityInitializers = Lists.newArrayList(); - private final List<EntitySpec<?>> children = Lists.newArrayList(); - private final List<Entity> members = Lists.newArrayList(); - private final List<Group> groups = Lists.newArrayList(); - private volatile boolean immutable; - - public EntitySpec(Class<T> type) { - super(type); - } - - @SuppressWarnings("unchecked") - public Class<T> getType() { - return (Class<T>)super.getType(); - } - - @Override - protected void checkValidType(Class<? extends T> type) { - // EntitySpec does nothing. Other specs do check it's an implementation etc. - } - - /** - * @return The implementation of the entity; if not null. this overrides any defaults or other configuration - * - * @see ImplementedBy on the entity interface classes for how defaults are defined. - * @see EntityTypeRegistry for how implementations can be defined globally - */ - @Nullable - public Class<? extends T> getImplementation() { - return impl; - } - - /** - * @return Additional interfaces (other than just {@link #getType()}) that this entity implements; - * important for when accessing entity through a proxy to determine which interfaces the proxy exposes. - */ - public Set<Class<?>> getAdditionalInterfaces() { - return additionalInterfaces; - } - - /** @return {@link EntityInitializer} objects which customize the entity to be created */ - public List<EntityInitializer> getInitializers() { - return entityInitializers; - } - - public List<EntitySpec<?>> getChildren() { - return children; - } - - public List<Entity> getMembers() { - return members; - } - - public List<Group> getGroups() { - return groups; - } - - /** - * @return The entity's parent - */ - public Entity getParent() { - return parent; - } - - /** - * @return Read-only construction flags - * @see SetFromFlag declarations on the entity type - */ - public Map<String, ?> getFlags() { - return Collections.unmodifiableMap(flags); - } - - /** - * @return Read-only configuration values - */ - public Map<ConfigKey<?>, Object> getConfig() { - return Collections.unmodifiableMap(config); - } - - /** Clears the config map, removing any config previously set. */ - public void clearConfig() { - config.clear(); - } - - public List<PolicySpec<?>> getPolicySpecs() { - return policySpecs; - } - - public List<Policy> getPolicies() { - return policies; - } - - public List<EnricherSpec<?>> getEnricherSpecs() { - return enricherSpecs; - } - - public List<Enricher> getEnrichers() { - return enrichers; - } - - public List<Location> getLocations() { - return locations; - } - - public EntitySpec<T> impl(Class<? extends T> val) { - checkMutable(); - checkIsImplementation(checkNotNull(val, "impl"), getType()); - checkIsNewStyleImplementation(val); - impl = val; - return this; - } - - public EntitySpec<T> additionalInterfaces(Class<?>... vals) { - checkMutable(); - for (Class<?> val : vals) { - additionalInterfaces.add(val); - } - return this; - } - - public EntitySpec<T> additionalInterfaces(Iterable<Class<?>> val) { - checkMutable(); - additionalInterfaces.addAll(Sets.newLinkedHashSet(val)); - return this; - } - - public EntitySpec<T> addInitializer(EntityInitializer initializer) { - checkMutable(); - entityInitializers.add(initializer); - return this; - } - - public EntitySpec<T> addInitializers(Iterable<? extends EntityInitializer> initializers) { - checkMutable(); - Iterables.addAll(entityInitializers, initializers); - return this; - } - - /** The supplied class must have a public no-arg constructor. */ - public EntitySpec<T> addInitializer(Class<? extends EntityInitializer> initializerType) { - checkMutable(); - try { - entityInitializers.add(initializerType.newInstance()); - } catch (Exception e) { - throw Throwables.propagate(e); - } - return this; - } - - public EntitySpec<T> children(Iterable<? extends EntitySpec<?>> children) { - checkMutable(); - Iterables.addAll(this.children, children); - return this; - } - - /** The supplied class must have a public no-arg constructor. */ - public EntitySpec<T> child(EntitySpec<?> child) { - checkMutable(); - children.add(child); - return this; - } - - public EntitySpec<T> members(Iterable<? extends Entity> members) { - checkMutable(); - Iterables.addAll(this.members, members); - return this; - } - - public EntitySpec<T> member(Entity member) { - checkMutable(); - members.add(member); - return this; - } - - public EntitySpec<T> groups(Iterable<? extends Group> groups) { - checkMutable(); - Iterables.addAll(this.groups, groups); - return this; - } - - public EntitySpec<T> group(Group group) { - checkMutable(); - groups.add(group); - return this; - } - - public EntitySpec<T> parent(Entity val) { - checkMutable(); - parent = checkNotNull(val, "parent"); - return this; - } - - /** strings inserted as flags, config keys inserted as config keys; - * if you want to force one or the other, create a ConfigBag and convert to the appropriate map type */ - public EntitySpec<T> configure(Map<?,?> val) { - checkMutable(); - for (Map.Entry<?, ?> entry: val.entrySet()) { - if (entry.getKey()==null) throw new NullPointerException("Null key not permitted"); - if (entry.getKey() instanceof CharSequence) - flags.put(entry.getKey().toString(), entry.getValue()); - else if (entry.getKey() instanceof ConfigKey<?>) - config.put((ConfigKey<?>)entry.getKey(), entry.getValue()); - else if (entry.getKey() instanceof HasConfigKey<?>) - config.put(((HasConfigKey<?>)entry.getKey()).getConfigKey(), entry.getValue()); - else { - log.warn("Spec "+this+" ignoring unknown config key "+entry.getKey()); - } - } - return this; - } - - public EntitySpec<T> configure(CharSequence key, Object val) { - checkMutable(); - flags.put(checkNotNull(key, "key").toString(), val); - return this; - } - - public <V> EntitySpec<T> configure(ConfigKey<V> key, V val) { - checkMutable(); - config.put(checkNotNull(key, "key"), val); - return this; - } - - public <V> EntitySpec<T> configure(ConfigKey<V> key, Task<? extends V> val) { - checkMutable(); - config.put(checkNotNull(key, "key"), val); - return this; - } - - public <V> EntitySpec<T> configure(ConfigKey<V> key, Supplier<? extends V> val) { - checkMutable(); - config.put(checkNotNull(key, "key"), val); - return this; - } - - public <V> EntitySpec<T> configure(HasConfigKey<V> key, V val) { - checkMutable(); - config.put(checkNotNull(key, "key").getConfigKey(), val); - return this; - } - - public <V> EntitySpec<T> configure(HasConfigKey<V> key, Task<? extends V> val) { - checkMutable(); - config.put(checkNotNull(key, "key").getConfigKey(), val); - return this; - } - - - /** adds a policy to the spec */ - public <V> EntitySpec<T> policy(Policy val) { - checkMutable(); - policies.add(checkNotNull(val, "policy")); - return this; - } - - /** adds a policy to the spec */ - public <V> EntitySpec<T> policy(PolicySpec<?> val) { - checkMutable(); - policySpecs.add(checkNotNull(val, "policySpec")); - return this; - } - - /** adds the supplied policies to the spec */ - public <V> EntitySpec<T> policySpecs(Iterable<? extends PolicySpec<?>> val) { - checkMutable(); - policySpecs.addAll(MutableList.copyOf(checkNotNull(val, "policySpecs"))); - return this; - } - - /** adds the supplied policies to the spec */ - public <V> EntitySpec<T> policies(Iterable<? extends Policy> val) { - checkMutable(); - policies.addAll(MutableList.copyOf(checkNotNull(val, "policies"))); - return this; - } - - /** adds a policy to the spec */ - public <V> EntitySpec<T> enricher(Enricher val) { - checkMutable(); - enrichers.add(checkNotNull(val, "enricher")); - return this; - } - - /** adds a policy to the spec */ - public <V> EntitySpec<T> enricher(EnricherSpec<?> val) { - checkMutable(); - enricherSpecs.add(checkNotNull(val, "enricherSpec")); - return this; - } - - /** adds the supplied policies to the spec */ - public <V> EntitySpec<T> enricherSpecs(Iterable<? extends EnricherSpec<?>> val) { - checkMutable(); - enricherSpecs.addAll(MutableList.copyOf(checkNotNull(val, "enricherSpecs"))); - return this; - } - - /** adds the supplied policies to the spec */ - public <V> EntitySpec<T> enrichers(Iterable<? extends Enricher> val) { - checkMutable(); - enrichers.addAll(MutableList.copyOf(checkNotNull(val, "enrichers"))); - return this; - } - - /** adds a location to the spec */ - public <V> EntitySpec<T> location(Location val) { - checkMutable(); - locations.add(checkNotNull(val, "location")); - return this; - } - - /** adds the supplied locations to the spec */ - public <V> EntitySpec<T> locations(Iterable<? extends Location> val) { - checkMutable(); - locations.addAll(MutableList.copyOf(checkNotNull(val, "locations"))); - return this; - } - - /** "seals" this spec, preventing any future changes */ - public EntitySpec<T> immutable() { - immutable = true; - return this; - } - - private void checkMutable() { - if (immutable) throw new IllegalStateException("Cannot modify immutable entity spec "+this); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/entity/proxying/EntityTypeRegistry.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/entity/proxying/EntityTypeRegistry.java b/api/src/main/java/brooklyn/entity/proxying/EntityTypeRegistry.java deleted file mode 100644 index 13883e2..0000000 --- a/api/src/main/java/brooklyn/entity/proxying/EntityTypeRegistry.java +++ /dev/null @@ -1,64 +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 brooklyn.entity.proxying; - -import brooklyn.entity.Entity; -import brooklyn.entity.drivers.DriverDependentEntity; -import brooklyn.entity.drivers.EntityDriver; -import brooklyn.location.Location; - -/** - * A registry of the entity implementations to be used when creating an entity of a given type. - * - * A given implementation can only be associated with one entity type interface. - */ -public interface EntityTypeRegistry { - - /** - * Returns the implementation to be used for the given entity type. - * - * @param entity the {@link DriverDependentEntity} to create the {@link EntityDriver} for. - * @param location the {@link Location} where the {@link DriverDependentEntity} is running. - * @param <D> - * @return the creates EntityDriver. - * @throws IllegalArgumentException If no implementation registered, and the given interface is not annotated with {@link ImplementedBy} - * @throws IllegalStateException If the given type is not an interface, or if the implementation class is not a concrete class implementing it - */ - <T extends Entity> Class<? extends T> getImplementedBy(Class<T> type); - - /** - * Returns the interface of this entity implementation. - * E.g. for use as the fully qualified name in {@code entity.getEntityType().getName()}. - * - * @throws IllegalArgumentException If no interface is registered against this implementation, - * and no super-type of the class is annotated with {@link ImplementedBy} to point at the given class - */ - <T extends Entity> Class<? super T> getEntityTypeOf(Class<T> type); - - /** - * Registers the implementation to use for a given entity type. - * - * The implementation must be a non-abstract class implementing the given type, and must - * have a no-argument constructor. - * - * @throws IllegalArgumentException If this implementation has already been registered for a different type - * @throws IllegalStateException If the implClazz is not a concrete class, or does not implement type - */ - <T extends Entity> EntityTypeRegistry registerImplementation(Class<T> type, Class<? extends T> implClazz); -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/entity/proxying/ImplementedBy.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/entity/proxying/ImplementedBy.java b/api/src/main/java/brooklyn/entity/proxying/ImplementedBy.java deleted file mode 100644 index 8e96fdd..0000000 --- a/api/src/main/java/brooklyn/entity/proxying/ImplementedBy.java +++ /dev/null @@ -1,48 +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 brooklyn.entity.proxying; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import brooklyn.entity.Entity; - -/** - * A pointer to the default implementation of an entity. - * - * A common naming convention is for the implementation class to have the suffix "Impl", - * but this is not required. - * - * See {@link EntityTypeRegistry} for how to override the implementation to be used, if - * the class referenced by this annotation is not desired. - * - * @author aled - */ -@Retention(RUNTIME) -@Target(TYPE) -public @interface ImplementedBy { - - /** - * The implementation type. - */ - Class<? extends Entity> value(); -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/entity/rebind/BrooklynObjectType.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/entity/rebind/BrooklynObjectType.java b/api/src/main/java/brooklyn/entity/rebind/BrooklynObjectType.java deleted file mode 100644 index bc3276e..0000000 --- a/api/src/main/java/brooklyn/entity/rebind/BrooklynObjectType.java +++ /dev/null @@ -1,69 +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 brooklyn.entity.rebind; - -import org.apache.brooklyn.api.basic.BrooklynObject; -import org.apache.brooklyn.catalog.CatalogItem; -import org.apache.brooklyn.policy.Enricher; -import org.apache.brooklyn.policy.Policy; - -import brooklyn.entity.Entity; -import brooklyn.entity.Feed; -import brooklyn.location.Location; - -import com.google.common.annotations.Beta; -import com.google.common.base.CaseFormat; - -@Beta -public enum BrooklynObjectType { - ENTITY(Entity.class, "entities"), - LOCATION(Location.class, "locations"), - POLICY(Policy.class, "policies"), - ENRICHER(Enricher.class, "enrichers"), - FEED(Feed.class, "feeds"), - CATALOG_ITEM(CatalogItem.class, "catalog"), - UNKNOWN(null, "unknown"); - - private Class<? extends BrooklynObject> interfaceType; - private final String subPathName; - - BrooklynObjectType(Class<? extends BrooklynObject> interfaceType, String subPathName) { - this.interfaceType = interfaceType; - this.subPathName = subPathName; - } - public String toCamelCase() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, this.name()); - } - - public String getSubPathName() { - return subPathName; - } - - public Class<? extends BrooklynObject> getInterfaceType() { - return interfaceType; - } - - public static BrooklynObjectType of(BrooklynObject instance) { - for (BrooklynObjectType t: values()) { - if (t.getInterfaceType()!=null && t.getInterfaceType().isInstance(instance)) - return t; - } - return UNKNOWN; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/entity/rebind/ChangeListener.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/entity/rebind/ChangeListener.java b/api/src/main/java/brooklyn/entity/rebind/ChangeListener.java deleted file mode 100644 index b54af1a..0000000 --- a/api/src/main/java/brooklyn/entity/rebind/ChangeListener.java +++ /dev/null @@ -1,44 +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 brooklyn.entity.rebind; - -import org.apache.brooklyn.api.basic.BrooklynObject; - -/** - * Listener to be notified of changes within brooklyn, so that the new state - * of the entity/location/policy can be persisted. - * - * Users are not expected to implement this class. It is for use by the {@link RebindManager}. - * - * @author aled - */ -public interface ChangeListener { - - public static final ChangeListener NOOP = new ChangeListener() { - @Override public void onChanged(BrooklynObject instance) {} - @Override public void onManaged(BrooklynObject instance) {} - @Override public void onUnmanaged(BrooklynObject instance) {} - }; - - void onManaged(BrooklynObject instance); - - void onUnmanaged(BrooklynObject instance); - - void onChanged(BrooklynObject instance); -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/entity/rebind/PersistenceExceptionHandler.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/entity/rebind/PersistenceExceptionHandler.java b/api/src/main/java/brooklyn/entity/rebind/PersistenceExceptionHandler.java deleted file mode 100644 index d7903c4..0000000 --- a/api/src/main/java/brooklyn/entity/rebind/PersistenceExceptionHandler.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 brooklyn.entity.rebind; - -import org.apache.brooklyn.api.basic.BrooklynObject; -import org.apache.brooklyn.mementos.Memento; - -import com.google.common.annotations.Beta; - -/** - * Handler called on all exceptions to do with persistence. - * - * @author aled - */ -@Beta -public interface PersistenceExceptionHandler { - - void stop(); - - void onGenerateMementoFailed(BrooklynObjectType type, BrooklynObject instance, Exception e); - - void onPersistMementoFailed(Memento memento, Exception e); - - void onPersistRawMementoFailed(BrooklynObjectType type, String id, Exception e); - - void onDeleteMementoFailed(String id, Exception e); -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/entity/rebind/RebindContext.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/entity/rebind/RebindContext.java b/api/src/main/java/brooklyn/entity/rebind/RebindContext.java deleted file mode 100644 index 13b0a30..0000000 --- a/api/src/main/java/brooklyn/entity/rebind/RebindContext.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 brooklyn.entity.rebind; - -import java.util.Map; - -import org.apache.brooklyn.api.basic.BrooklynObject; -import org.apache.brooklyn.mementos.BrooklynMementoPersister.LookupContext; - -import com.google.common.annotations.Beta; - -/** - * Gives access to things that are being currently rebinding. This is used during a - * rebind to wire everything back together again, e.g. to find the necessary entity - * instances even before they are available through - * {@code managementContext.getEntityManager().getEnties()}. - * <p> - * Users are not expected to implement this class. It is for use by {@link Rebindable} - * instances, and will generally be created by the {@link RebindManager}. - * <p> - */ -@Beta -public interface RebindContext { - - /** Returns an unmodifiable view of all objects by ID */ - Map<String,BrooklynObject> getAllBrooklynObjects(); - - Class<?> loadClass(String typeName) throws ClassNotFoundException; - - RebindExceptionHandler getExceptionHandler(); - - boolean isReadOnly(BrooklynObject item); - - LookupContext lookup(); - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/entity/rebind/RebindExceptionHandler.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/entity/rebind/RebindExceptionHandler.java b/api/src/main/java/brooklyn/entity/rebind/RebindExceptionHandler.java deleted file mode 100644 index 932a32f..0000000 --- a/api/src/main/java/brooklyn/entity/rebind/RebindExceptionHandler.java +++ /dev/null @@ -1,110 +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 brooklyn.entity.rebind; - -import java.util.List; - -import org.apache.brooklyn.api.basic.BrooklynObject; -import org.apache.brooklyn.catalog.CatalogItem; -import org.apache.brooklyn.policy.Enricher; -import org.apache.brooklyn.policy.Policy; - -import brooklyn.entity.Entity; -import brooklyn.entity.Feed; -import brooklyn.entity.basic.EntityLocal; -import brooklyn.location.Location; - -import com.google.common.annotations.Beta; - -/** - * Handler called on all exceptions to do with rebind. - * A handler instance is linked to a single rebind pass; - * it should not be invoked after {@link #onDone()}. - * <p> - * {@link #onStart()} must be invoked before the run. - * {@link #onDone()} must be invoked after a successful run, and it may throw. - * <p> - * Implementations may propagate errors or may catch them until {@link #onDone()} is invoked, - * and that may throw or report elsewhere, as appropriate. - * - * @author aled - */ -@Beta -public interface RebindExceptionHandler { - - void onLoadMementoFailed(BrooklynObjectType type, String msg, Exception e); - - /** - * @return the entity to use in place of the missing one, or null (if hasn't thrown an exception) - */ - Entity onDanglingEntityRef(String id); - - /** - * @return the location to use in place of the missing one, or null (if hasn't thrown an exception) - */ - Location onDanglingLocationRef(String id); - - /** - * @return the policy to use in place of the missing one, or null (if hasn't thrown an exception) - */ - Policy onDanglingPolicyRef(String id); - - /** - * @return the enricher to use in place of the missing one, or null (if hasn't thrown an exception) - */ - Enricher onDanglingEnricherRef(String id); - - /** - * @return the feed to use in place of the missing one, or null (if hasn't thrown an exception) - */ - Feed onDanglingFeedRef(String id); - - /** - * @return the catalog item to use in place of the missing one - */ - CatalogItem<?, ?> onDanglingCatalogItemRef(String id); - - void onCreateFailed(BrooklynObjectType type, String id, String instanceType, Exception e); - - void onNotFound(BrooklynObjectType type, String id); - - void onRebindFailed(BrooklynObjectType type, BrooklynObject instance, Exception e); - - void onAddPolicyFailed(EntityLocal entity, Policy policy, Exception e); - - void onAddEnricherFailed(EntityLocal entity, Enricher enricher, Exception e); - - void onAddFeedFailed(EntityLocal entity, Feed feed, Exception e); - - void onManageFailed(BrooklynObjectType type, BrooklynObject instance, Exception e); - - /** invoked for any high-level, unexpected, or otherwise uncaught failure; - * may be invoked on catching above errors */ - RuntimeException onFailed(Exception e); - - /** invoked before the rebind pass */ - void onStart(RebindContext context); - - /** invoked after the complete rebind pass, always on success and possibly on failure */ - void onDone(); - - List<Exception> getExceptions(); - List<String> getWarnings(); - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/entity/rebind/RebindManager.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/entity/rebind/RebindManager.java b/api/src/main/java/brooklyn/entity/rebind/RebindManager.java deleted file mode 100644 index 7e99a8e..0000000 --- a/api/src/main/java/brooklyn/entity/rebind/RebindManager.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package brooklyn.entity.rebind; - -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeoutException; - -import javax.annotation.Nullable; - -import org.apache.brooklyn.management.ha.ManagementNodeState; -import org.apache.brooklyn.mementos.BrooklynMementoPersister; -import org.apache.brooklyn.mementos.BrooklynMementoRawData; - -import brooklyn.entity.Application; -import brooklyn.util.time.Duration; - -import com.google.common.annotations.Beta; -import com.google.common.annotations.VisibleForTesting; - -/** - * Manages the persisting of brooklyn's state, and recreating that state, e.g. on - * brooklyn restart. - * - * Users are not expected to implement this class, or to call methods on it directly. - */ -public interface RebindManager { - - // FIXME Should we be calling managementContext.getRebindManager().rebind, using a - // new empty instance of managementContext? - // - // Or is that a risky API because you could call it on a non-empty managementContext? - - public enum RebindFailureMode { - FAIL_FAST, - FAIL_AT_END, - CONTINUE; - } - - public void setPersister(BrooklynMementoPersister persister); - - public void setPersister(BrooklynMementoPersister persister, PersistenceExceptionHandler exceptionHandler); - - @VisibleForTesting - public BrooklynMementoPersister getPersister(); - - /** @deprecated since 0.7; use {@link #rebind(ClassLoader, RebindExceptionHandler, ManagementNodeState)} */ @Deprecated - public List<Application> rebind(); - - /** @deprecated since 0.7; use {@link #rebind(ClassLoader, RebindExceptionHandler, ManagementNodeState)} */ @Deprecated - public List<Application> rebind(ClassLoader classLoader); - /** @deprecated since 0.7; use {@link #rebind(ClassLoader, RebindExceptionHandler, ManagementNodeState)} */ @Deprecated - public List<Application> rebind(ClassLoader classLoader, RebindExceptionHandler exceptionHandler); - /** Causes this management context to rebind, loading data from the given backing store. - * use wisely, as this can cause local entities to be completely lost, or will throw in many other situations. - * in general it may be invoked for a new node becoming {@link ManagementNodeState#MASTER} - * or periodically for a node in {@link ManagementNodeState#HOT_STANDBY} or {@link ManagementNodeState#HOT_BACKUP}. */ - @Beta - public List<Application> rebind(ClassLoader classLoader, RebindExceptionHandler exceptionHandler, ManagementNodeState mode); - - public BrooklynMementoRawData retrieveMementoRawData(); - - public ChangeListener getChangeListener(); - - /** - * Starts the background persisting of state - * (if persister is set; otherwise will start persisting as soon as persister is set). - * Until this is called, no data will be persisted although entities can be rebinded. - */ - public void startPersistence(); - - /** Stops the background persistence of state. - * Waits for any current persistence to complete. */ - public void stopPersistence(); - - /** - * Perform an initial load of state read-only and starts a background process - * reading (mirroring) state periodically. - */ - public void startReadOnly(ManagementNodeState mode); - /** Stops the background reading (mirroring) of state. - * Interrupts any current activity and waits for it to cease. */ - public void stopReadOnly(); - - /** Starts the appropriate background processes, {@link #startPersistence()} if {@link ManagementNodeState#MASTER}, - * {@link #startReadOnly()} if {@link ManagementNodeState#HOT_STANDBY} or {@link ManagementNodeState#HOT_BACKUP} */ - public void start(); - /** Stops the appropriate background processes, {@link #stopPersistence()} or {@link #stopReadOnly()}, - * waiting for activity there to cease (interrupting in the case of {@link #stopReadOnly()}). */ - public void stop(); - - @VisibleForTesting - /** waits for any needed or pending writes to complete */ - public void waitForPendingComplete(Duration duration, boolean canTrigger) throws InterruptedException, TimeoutException; - /** Forcibly performs persistence, in the foreground - * @deprecated since 0.7.0; use {@link #forcePersistNow(boolean, PersistenceExceptionHandler)}, - * default parameter here is false to mean incremental, with null/default exception handler */ - @VisibleForTesting - public void forcePersistNow(); - /** Forcibly performs persistence, in the foreground, either full (all entities) or incremental; - * if no exception handler specified, the default one from the persister is used. - * <p> - * Note that full persistence does *not* delete items; incremental should normally be sufficient. - * (A clear then full persistence would have the same effect, but that is risky in a production - * setting if the process fails after the clear!) */ - @VisibleForTesting - public void forcePersistNow(boolean full, @Nullable PersistenceExceptionHandler exceptionHandler); - - /** Whether the management state has changed to a state where a rebind is needed - * but we are still awaiting the first run; - * ie state is master or hot, but list of apps is not yet accurate */ - public boolean isAwaitingInitialRebind(); - - /** Metrics about rebind, last success, etc. */ - public Map<String,Object> getMetrics(); - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/entity/rebind/RebindSupport.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/entity/rebind/RebindSupport.java b/api/src/main/java/brooklyn/entity/rebind/RebindSupport.java deleted file mode 100644 index e896c0f..0000000 --- a/api/src/main/java/brooklyn/entity/rebind/RebindSupport.java +++ /dev/null @@ -1,57 +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 brooklyn.entity.rebind; - -import org.apache.brooklyn.mementos.BrooklynMementoPersister; -import org.apache.brooklyn.mementos.Memento; - -/** - * Supporter instance for behaviour related to rebinding a given entity/location/policy. - * - * For example, the brooklyn framework may call {@code entity.getRebindSupport().getMemento()} - * and persist this using a {@link BrooklynMementoPersister}. Later (e.g. after a brooklyn - * restart) a new entity instance may be created and populated by the framework calling - * {@code entity.getRebindSupport().reconstruct(rebindContext, memento)}. - * - * @author aled - */ -public interface RebindSupport<T extends Memento> { - - /** - * Creates a memento representing this entity's current state. This is useful for when restarting brooklyn. - */ - T getMemento(); - - /** - * Reconstructs this entity, given a memento of its state. Sets the internal state - * (including id and config keys), and sets the parent/children/locations of this entity. - * - * Implementations should be very careful to not invoke or inspect these other entities/locations, - * as they may also be being reconstructed at this time. - * - * Called during rebind, after creation and before the call to start management. - */ - void reconstruct(RebindContext rebindContext, T memento); - - void addPolicies(RebindContext rebindContext, T Memento); - - void addEnrichers(RebindContext rebindContext, T Memento); - - void addFeeds(RebindContext rebindContext, T Memento); -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/entity/rebind/Rebindable.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/entity/rebind/Rebindable.java b/api/src/main/java/brooklyn/entity/rebind/Rebindable.java deleted file mode 100644 index b5134b9..0000000 --- a/api/src/main/java/brooklyn/entity/rebind/Rebindable.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package brooklyn.entity.rebind; - -import org.apache.brooklyn.mementos.Memento; - -import com.google.common.annotations.Beta; - -/** - * Indicates that this can be recreated, e.g. after a brooklyn restart, and by - * using a {@link Memento} it can repopulate the brooklyn objects. The purpose - * of the rebind is to reconstruct and reconnect the brooklyn objects, including - * binding them to external resources. - * - * Users are strongly discouraged to call or use this interface. - * It is for internal use only, relating to persisting/rebinding entities. - * This interface may change (or be removed) in a future release without notice. - */ -@Beta -public interface Rebindable { - - public RebindSupport getRebindSupport(); - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/entity/trait/Configurable.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/entity/trait/Configurable.java b/api/src/main/java/brooklyn/entity/trait/Configurable.java deleted file mode 100644 index f72a0da..0000000 --- a/api/src/main/java/brooklyn/entity/trait/Configurable.java +++ /dev/null @@ -1,94 +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 brooklyn.entity.trait; - -import org.apache.brooklyn.management.Task; - -import brooklyn.config.ConfigKey; -import brooklyn.config.ConfigKey.HasConfigKey; - -import com.google.common.annotations.Beta; - -/** - * Something that has mutable config, such as an entity or policy. - * - * @author aled - */ -public interface Configurable { - - // FIXME Moved from core project to api project, as part of moving EntityLocal. - // (though maybe it's fine here?) - - /** - * @return the old value, or null if there was not one - * @deprecated since 0.7.0; use {@link ConfigurationSupport#set(ConfigKey, Object)}, such as {@code config().set(key, val)} - */ - @Deprecated - public <T> T setConfig(ConfigKey<T> key, T val); - - ConfigurationSupport config(); - - @Beta - public interface ConfigurationSupport { - - /** - * Gets the given configuration value for this entity, in the following order of precedence: - * <ol> - * <li> value (including null) explicitly set on the entity - * <li> value (including null) explicitly set on an ancestor (inherited) - * <li> a default value (including null) on the best equivalent static key of the same name declared on the entity - * (where best equivalence is defined as preferring a config key which extends another, - * as computed in EntityDynamicType.getConfigKeys) - * <li> a default value (including null) on the key itself - * <li> null - * </ol> - */ - <T> T get(ConfigKey<T> key); - - /** - * @see {@link #getConfig(ConfigKey)} - */ - <T> T get(HasConfigKey<T> key); - - /** - * Sets the config to the given value. - */ - <T> T set(ConfigKey<T> key, T val); - - /** - * @see {@link #setConfig(HasConfigKey, Object)} - */ - <T> T set(HasConfigKey<T> key, T val); - - /** - * Sets the config to the value returned by the task. - * - * Returns immediately without blocking; subsequent calls to {@link #getConfig(ConfigKey)} - * will execute the task, and block until the task completes. - * - * @see {@link #setConfig(ConfigKey, Object)} - */ - <T> T set(ConfigKey<T> key, Task<T> val); - - /** - * @see {@link #setConfig(ConfigKey, Task)} - */ - <T> T set(HasConfigKey<T> key, Task<T> val); - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/entity/trait/HasShortName.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/entity/trait/HasShortName.java b/api/src/main/java/brooklyn/entity/trait/HasShortName.java deleted file mode 100644 index 36606f3..0000000 --- a/api/src/main/java/brooklyn/entity/trait/HasShortName.java +++ /dev/null @@ -1,26 +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 brooklyn.entity.trait; - -public interface HasShortName { - - /** gets a short name, for human-friendly identification e.g. inside the name of a VM */ - String getShortName(); - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/entity/trait/Identifiable.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/entity/trait/Identifiable.java b/api/src/main/java/brooklyn/entity/trait/Identifiable.java deleted file mode 100644 index 10dc612..0000000 --- a/api/src/main/java/brooklyn/entity/trait/Identifiable.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 brooklyn.entity.trait; - -public interface Identifiable { - - String getId(); -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/event/Sensor.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/event/Sensor.java b/api/src/main/java/brooklyn/event/Sensor.java index 2057020..f58f064 100644 --- a/api/src/main/java/brooklyn/event/Sensor.java +++ b/api/src/main/java/brooklyn/event/Sensor.java @@ -21,9 +21,9 @@ package brooklyn.event; import java.io.Serializable; import java.util.List; -import com.google.common.reflect.TypeToken; +import org.apache.brooklyn.api.entity.Entity; -import brooklyn.entity.Entity; +import com.google.common.reflect.TypeToken; /** * The interface implemented by concrete sensors. http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/event/SensorEvent.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/event/SensorEvent.java b/api/src/main/java/brooklyn/event/SensorEvent.java index 4bb819a..14c5ea4 100644 --- a/api/src/main/java/brooklyn/event/SensorEvent.java +++ b/api/src/main/java/brooklyn/event/SensorEvent.java @@ -18,7 +18,7 @@ */ package brooklyn.event; -import brooklyn.entity.Entity; +import org.apache.brooklyn.api.entity.Entity; /** * A tuple representing a piece of data from a {@link Sensor} on an {@link Entity}. http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/brooklyn/event/SensorEventListener.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/brooklyn/event/SensorEventListener.java b/api/src/main/java/brooklyn/event/SensorEventListener.java index b6959c7..ea4d528 100644 --- a/api/src/main/java/brooklyn/event/SensorEventListener.java +++ b/api/src/main/java/brooklyn/event/SensorEventListener.java @@ -18,7 +18,7 @@ */ package brooklyn.event; -import brooklyn.entity.Entity; +import org.apache.brooklyn.api.entity.Entity; /** * A listener for {@link SensorEvent}s on an {@link Entity}. http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/org/apache/brooklyn/api/basic/BrooklynObject.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/basic/BrooklynObject.java b/api/src/main/java/org/apache/brooklyn/api/basic/BrooklynObject.java index 8c05ad0..2901e46 100644 --- a/api/src/main/java/org/apache/brooklyn/api/basic/BrooklynObject.java +++ b/api/src/main/java/org/apache/brooklyn/api/basic/BrooklynObject.java @@ -22,8 +22,8 @@ import java.util.Set; import javax.annotation.Nonnull; -import brooklyn.entity.trait.Configurable; -import brooklyn.entity.trait.Identifiable; +import org.apache.brooklyn.api.entity.trait.Configurable; +import org.apache.brooklyn.api.entity.trait.Identifiable; import com.google.common.collect.ImmutableMap; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/org/apache/brooklyn/api/entity/Application.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/entity/Application.java b/api/src/main/java/org/apache/brooklyn/api/entity/Application.java new file mode 100644 index 0000000..21e0800 --- /dev/null +++ b/api/src/main/java/org/apache/brooklyn/api/entity/Application.java @@ -0,0 +1,34 @@ +/* + * 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.entity; + +import org.apache.brooklyn.management.ManagementContext; + + +/** + * An application is the root of the entity hierarchy. In the parent-child relationship, it is + * the top-level entity under which the application's entities are all places. + * + * The recommended ways to write a new application are to either extend {@link brooklyn.entity.basic.ApplicationBuilder} + * or to extend {@link brooklyn.entity.basic.AbstractApplication}. + */ +public interface Application extends Entity { + + ManagementContext getManagementContext(); +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a76dac4f/api/src/main/java/org/apache/brooklyn/api/entity/Effector.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/brooklyn/api/entity/Effector.java b/api/src/main/java/org/apache/brooklyn/api/entity/Effector.java new file mode 100644 index 0000000..3fe3014 --- /dev/null +++ b/api/src/main/java/org/apache/brooklyn/api/entity/Effector.java @@ -0,0 +1,54 @@ +/* + * 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.entity; + +import java.io.Serializable; +import java.util.List; + +import javax.management.MBeanOperationInfo; + +/** + * An operation of some kind, carried out by an {@link Entity}. + * + * Similar to the concepts in the JMX {@link MBeanOperationInfo} class. + */ +public interface Effector<T> extends Serializable { + /** + * human-friendly name of the effector (although frequently this uses java method naming convention) + */ + String getName(); + + Class<T> getReturnType(); + + /** + * canonical name of return type (in case return type does not resolve after serialization) + */ + String getReturnTypeName(); + + /** + * parameters expected by method, including name and type, optional description and default value + */ + List<ParameterType<?>> getParameters(); + + /** + * optional description for the effector + */ + String getDescription(); + +}
