/** Returns true if the spec is for a wrapper app with no important settings, wrapping a single child entity. * for use when adding from a plan specifying multiple entities but there is nothing significant at the application level, * and the context would like to flatten it to remove the wrapper yielding just a single entity. * (but note the result is not necessarily an {@link Application}; * see {@link #canUnwrapApplication(EntitySpec)} if that is required). * <p> * Note callers will normally use one of {@link #unwrapEntity(EntitySpec)} or {@link #unwrapApplication(EntitySpec)}. * * @see #WRAPPER_APP_MARKER for an overview */ public static boolean canUnwrapEntity(EntitySpec<? extends Entity> spec) { return isWrapperApp(spec) && hasSingleChild(spec) && // these "brooklyn.*" items on the app rather than the child absolutely prevent unwrapping // as their semantics could well be different whether they are on the parent or the child spec.getEnrichers().isEmpty() && spec.getEnricherSpecs().isEmpty() && spec.getInitializers().isEmpty() && spec.getPolicies().isEmpty() && spec.getPolicySpecs().isEmpty() && // prevent merge only if a location is defined at both levels ((spec.getLocations().isEmpty() && spec.getLocationSpecs().isEmpty()) || (Iterables.getOnlyElement(spec.getChildren()).getLocations().isEmpty()) && Iterables.getOnlyElement(spec.getChildren()).getLocationSpecs().isEmpty()) // parameters are collapsed on merge so don't need to be considered here ; } /** @deprecated since 0.9.0 use {@link #canUnwrapEntity(EntitySpec)} */ @Deprecated
boolean memberSpecHasLocation = memberSpec!=null && (!memberSpec.getLocationSpecs().isEmpty() || !memberSpec.getLocations().isEmpty()); if (memberSpecHasLocation) { LOG.warn("Cluster {} has availability-zone enabled, but memberSpec overrides location with {}; using " + "memberSpec's location; availability-zone behaviour will not apply", this, ""+memberSpec.getLocationSpecs()+"+"+memberSpec.getLocations());
wrappedChild.locations(wrapperParent.getLocations());
@Override protected EntitySpec<T> copyFrom(EntitySpec<T> otherSpec) { super.copyFrom(otherSpec) .additionalInterfaces(otherSpec.getAdditionalInterfaces()) .policySpecs(otherSpec.getPolicySpecs()) .policies(otherSpec.getPolicies()) .enricherSpecs(otherSpec.getEnricherSpecs()) .enrichers(otherSpec.getEnrichers()) .addInitializers(otherSpec.getInitializers()) .children(copyFromSpecs(otherSpec.getChildren())) .members(otherSpec.getMembers()) .groups(otherSpec.getGroups()) .locationSpecs(otherSpec.getLocationSpecs()) .locations(otherSpec.getLocations()); if (otherSpec.getParent() != null) parent(otherSpec.getParent()); if (otherSpec.getImplementation() != null) impl(otherSpec.getImplementation()); return this; }
managementContext.getLocationManager().createLocation(taggedSpec))); ((AbstractEntity)entity).addLocations(spec.getLocations());