You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by nakomis <gi...@git.apache.org> on 2015/04/15 20:04:41 UTC
[GitHub] incubator-brooklyn pull request: Adds support for ${attribute['att...
GitHub user nakomis opened a pull request:
https://github.com/apache/incubator-brooklyn/pull/601
Adds support for ${attribute['attribute.name']} sensor access in freemarker templates
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/nakomis/incubator-brooklyn feature/freemarker-attributes
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-brooklyn/pull/601.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #601
----
commit 4c3a57e5aabcb8415e57f83d2475a4df28f7ecb1
Author: Martin Harris <gi...@nakomis.com>
Date: 2015-04-15T15:13:53Z
Adds support for ${attribute['attribute.name']} sensor access in freemarker templates
----
---
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.
---
[GitHub] incubator-brooklyn pull request: Adds support for ${attribute['att...
Posted by nakomis <gi...@git.apache.org>.
Github user nakomis commented on the pull request:
https://github.com/apache/incubator-brooklyn/pull/601#issuecomment-93776057
PR comments addressed
---
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.
---
[GitHub] incubator-brooklyn pull request: Adds support for ${attribute['att...
Posted by nakomis <gi...@git.apache.org>.
Github user nakomis closed the pull request at:
https://github.com/apache/incubator-brooklyn/pull/601
---
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.
---
[GitHub] incubator-brooklyn pull request: Adds support for ${attribute['att...
Posted by grkvlt <gi...@git.apache.org>.
Github user grkvlt commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/601#discussion_r28513414
--- Diff: core/src/main/java/brooklyn/util/text/TemplateProcessor.java ---
@@ -225,6 +229,40 @@ public String toString() {
}
}
+ protected final static class EntityAttributeTemplateModel implements TemplateHashModel {
+ protected final EntityInternal entity;
+
+ protected EntityAttributeTemplateModel(EntityInternal entity) {
+ this.entity = entity;
+ }
+
+ @Override
+ public boolean isEmpty() throws TemplateModelException {
+ return false;
+ }
+
+ @Override
+ public TemplateModel get(String key) throws TemplateModelException {
+ Object result;
+ try {
+ result = Entities.submit(entity, DependentConfiguration.attributeWhenReady(entity,
+ Sensors.builder(Object.class, key).persistence(AttributeSensor.SensorPersistenceMode.NONE).build())).get();
+ } catch (Exception e) {
+ throw Exceptions.propagate(e);
--- End diff --
Do `throw new TemplateModelException("Error obtaining sensor data for " + key, e)` here instead
---
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.
---
[GitHub] incubator-brooklyn pull request: Adds support for ${attribute['att...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on the pull request:
https://github.com/apache/incubator-brooklyn/pull/601#issuecomment-122266610
I like the change - will alleviate the need for the tons of getXXX accessors on the drivers created only because the attributes can't be accessed in templates. All of them just do `entity.getAttribute(...)` so I think having the default block is sensible. Adding a non-blocking alternative could be done as well, but I haven't seen any of those accessors check for present value.
---
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.
---
[GitHub] incubator-brooklyn pull request: Adds support for ${attribute['att...
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on the pull request:
https://github.com/apache/incubator-brooklyn/pull/601#issuecomment-102179560
actually thinking about it we can always set a config key to attribute or attribute when ready and then use `${config[...]}`. so this addition isn't necessary -- though i'm happy to have it.
---
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.
---
[GitHub] incubator-brooklyn pull request: Adds support for ${attribute['att...
Posted by grkvlt <gi...@git.apache.org>.
Github user grkvlt commented on the pull request:
https://github.com/apache/incubator-brooklyn/pull/601#issuecomment-94091129
@nakomis the other issues (sorry, I forgot to mention them before) is that the `attributeWhenReady` call may block for ever, so perhaps we should add a timeout to the `get()`? Also I'd like to see a test validating what happens when the attribute is _not_ present at all, and perhaps also what happens when the attribute is present but `null`.
---
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.
---
[GitHub] incubator-brooklyn pull request: Adds support for ${attribute['att...
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on the pull request:
https://github.com/apache/incubator-brooklyn/pull/601#issuecomment-102179206
i think `${attribute[...]}` should return the current attribute value, whether or not set. it would be surprising if that blocked. we could have an analogous `${attributeWhenReady[...]}` which does wait.
no timeout necessary -- tasks should be interrupted at a higher level.
agree with a few more tests for null and blank cases.
this is a great addition btw!
---
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.
---
[GitHub] incubator-brooklyn pull request: Adds support for ${attribute['att...
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on the pull request:
https://github.com/apache/incubator-brooklyn/pull/601#issuecomment-113498813
@nakomis close this?
---
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.
---
[GitHub] incubator-brooklyn pull request: Adds support for ${attribute['att...
Posted by nakomis <gi...@git.apache.org>.
Github user nakomis commented on the pull request:
https://github.com/apache/incubator-brooklyn/pull/601#issuecomment-93773851
@grkvlt Any other comments, or should I go ahead and make the change?
---
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.
---