This is an automated email from the ASF dual-hosted git repository. heneveld pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git
commit ee64a18c4ea2539cb7a00698eebe42b34ac06b9f Author: Alex Heneveld <[email protected]> AuthorDate: Thu Jul 14 14:24:38 2022 +0100 allow `groups` to be omitted for GroupsChangePolicy --- .../org/apache/brooklyn/entity/group/GroupsChangePolicy.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/src/main/java/org/apache/brooklyn/entity/group/GroupsChangePolicy.java b/core/src/main/java/org/apache/brooklyn/entity/group/GroupsChangePolicy.java index 23055bd14e..ab6adfd17e 100644 --- a/core/src/main/java/org/apache/brooklyn/entity/group/GroupsChangePolicy.java +++ b/core/src/main/java/org/apache/brooklyn/entity/group/GroupsChangePolicy.java @@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.reflect.TypeToken; import org.apache.brooklyn.api.entity.Entity; import org.apache.brooklyn.api.entity.EntityInitializer; +import org.apache.brooklyn.api.entity.Group; import org.apache.brooklyn.api.location.Location; import org.apache.brooklyn.api.location.LocationSpec; import org.apache.brooklyn.api.mgmt.ExecutionContext; @@ -233,4 +234,13 @@ public class GroupsChangePolicy extends AbstractMembershipTrackingPolicy { Maybe<Object> rawInitializers = config().getRaw(key); return rawInitializers.isPresent() ? (List<Map<String, Object>>) rawInitializers.get() : ImmutableList.of(); } + + /** default to the entity where attached, eg if attached to a group no need to specify $brooklyn:self() */ + protected Group getGroup() { + Group result = super.getGroup(); + if (result!=null) return result; + if (entity instanceof Group) return (Group)entity; + return null; + } + }
