Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/300#discussion_r75293363
  
    --- Diff: 
camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java
 ---
    @@ -84,51 +89,72 @@ public DslComponent(DslComponent scopeComponent, Scope 
scope, String componentId
         }
     
         // ---------------------------
    -    
    +
         @Override
    -    public Task<Entity> newTask() {
    -        return 
TaskBuilder.<Entity>builder().displayName(toString()).tag(BrooklynTaskTags.TRANSIENT_TASK_TAG)
    -            .body(new EntityInScopeFinder(scopeComponent, scope, 
componentId)).build();
    +    public Task<O> newTask() {
    +        return TaskBuilder.<O>builder()
    +                .displayName(toString())
    +                .tag(BrooklynTaskTags.TRANSIENT_TASK_TAG)
    +                .body(new ObjectInScopeFinder(scopeComponent, scope, 
componentId))
    +                .build();
         }
    -    
    -    protected static class EntityInScopeFinder implements Callable<Entity> 
{
    +
    +    protected static class ObjectInScopeFinder<O> implements Callable<O> {
             protected final DslComponent scopeComponent;
             protected final Scope scope;
             protected final String componentId;
     
    -        public EntityInScopeFinder(DslComponent scopeComponent, Scope 
scope, String componentId) {
    +        public ObjectInScopeFinder(DslComponent scopeComponent, Scope 
scope, String componentId) {
                 this.scopeComponent = scopeComponent;
                 this.scope = scope;
                 this.componentId = componentId;
             }
     
             protected EntityInternal getEntity() {
                 if (scopeComponent!=null) {
    -                return (EntityInternal)scopeComponent.get();
    +                return (EntityInternal) scopeComponent.get();
                 } else {
                     return entity();
                 }
             }
    -        
    +
    +        protected LocationInternal getLocation() {
    +            if (scopeComponent!=null) {
    +                return (LocationInternal) scopeComponent.get();
    +            } else {
    +                throw new IllegalStateException("Scope component must be 
set");
    +            }
    +        }
    +
             @Override
    -        public Entity call() throws Exception {
    -            Iterable<Entity> entitiesToSearch = null;
    +        public O call() throws Exception {
                 EntityInternal entity = getEntity();
    +
    +            if (scope == Scope.LOCATION) {
    +                Maybe<SshMachineLocation> machine = 
Machines.findUniqueMachineLocation(entity.getLocations(), 
SshMachineLocation.class);
    --- End diff --
    
    Does this mean it will fail if used for a non-machine location? e.g. if 
called on the top-level app that has a `JcloudsLocation` instance?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to