Github user aledsage commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/155#discussion_r64440692
--- Diff:
camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java
---
@@ -227,6 +230,53 @@ public String toString() {
}
}
+ public BrooklynDslDeferredSupplier<?> effector(final String
effectorName) {
+ return new ExecuteEffector(this, effectorName,
ImmutableMap.<String, Object>of());
+ }
+ public BrooklynDslDeferredSupplier<?> effector(final String
effectorName, final Map<String, ?> args) {
+ return new ExecuteEffector(this, effectorName, args);
+ }
+ // class simply makes the memento XML files nicer
+ protected static class ExecuteEffector extends
BrooklynDslDeferredSupplier<Object> {
+ private static final long serialVersionUID = 1740899524088902383L;
+ private final DslComponent component;
+ private final String effectorName;
+ private final Map<String, ?> args;
+ public ExecuteEffector(DslComponent component, String
effectorName, Map<String, ?> args) {
+ this.component = Preconditions.checkNotNull(component);
+ this.effectorName = effectorName;
+ this.args = args;
+ }
+ @SuppressWarnings("unchecked")
+ @Override
+ public Task<Object> newTask() {
+ Entity targetEntity = component.get();
+ Maybe<Effector<?>> targetEffector =
targetEntity.getEntityType().getEffectorByName(effectorName);
+ if (targetEffector.isAbsentOrNull()) {
+ throw new IllegalArgumentException("Effector " +
effectorName + " not found on entity: " + targetEntity);
+ }
+ return (Task<Object>) Entities.invokeEffector(targetEntity,
targetEntity, targetEffector.get(), args);
+ }
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(component, effectorName);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
--- End diff --
Should equals include the `args`? Not sure when equals would actually be
used in anger.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---