brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #300: Location DSL Updates
Date Thu, 18 Aug 2016 11:36:41 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/300#discussion_r75292142
  
    --- 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();
    --- End diff --
    
    I don't follow what the expectation of this class is now. Do we expect the `scopeComponent`
to always be an entity? Or sometimes a location? If it calls `call()` then it will fail for
anything but an entity, I presume.


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

Mime
View raw message