brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alasdairhodge <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: Allow a UsageListener (i.e. for m...
Date Mon, 10 Nov 2014 09:30:15 GMT
Github user alasdairhodge commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/310#discussion_r20072381
  
    --- Diff: core/src/main/java/brooklyn/management/internal/NonDeploymentUsageManager.java
---
    @@ -94,4 +94,22 @@ public ApplicationUsage getApplicationUsage(String appId) {
                 throw new IllegalStateException("Non-deployment context "+this+" is not valid
for this operation");
             }
         }
    +
    +    @Override
    +    public void addUsageListener(UsageListener listener) {
    +        if (isInitialManagementContextReal()) {
    +            initialManagementContext.getUsageManager().addUsageListener(listener);
    +        } else {
    +            throw new IllegalStateException("Non-deployment context "+this+" is not valid
for this operation");
    +        }
    +    }
    +
    +    @Override
    +    public void removeUsageListener(UsageListener listener) {
    +        if (isInitialManagementContextReal()) {
    +            initialManagementContext.getUsageManager().removeUsageListener(listener);
    +        } else {
    +            throw new IllegalStateException("Non-deployment context "+this+" is not valid
for this operation");
    +        }
    +    }
    --- End diff --
    
    Those `isInitialManagementContextReal` checks are a code smell. Cleaner for the manager
to always delegate to the context, and have the `NonDeploymentManagementContext` throw `UnsupportedOperationException`
where appropriate.
    
    Happy for that to be done later,could use a TODO however.


---
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