brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mbarrientos <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: Adds EntityInitializers for http ...
Date Thu, 17 Jul 2014 10:03:16 GMT
Github user mbarrientos commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/48#discussion_r15049245
  
    --- Diff: core/src/main/java/brooklyn/entity/effector/AddSensor.java ---
    @@ -53,10 +52,23 @@ public AddSensor(T sensor) {
         public void apply(EntityLocal entity) {
             ((EntityInternal)entity).getMutableEntityType().addSensor(sensor);
         }
    -    
    -    public static <T> AttributeSensor<T> newSensor(Class<T> type, ConfigBag
params) {
    +
    +    public static <T> AttributeSensor<T> newSensor(Class<T> type, ConfigBag
params){
             String name = Preconditions.checkNotNull(params.get(SENSOR_NAME), "name must
be supplied when defining a sensor");
    -        return Sensors.newSensor(type, name); 
    +        return Sensors.newSensor(type, name);
    +    }
    +
    +    public static <T> AttributeSensor<T> newSensor(ConfigBag params) {
    +        String name = Preconditions.checkNotNull(params.get(SENSOR_NAME), "name must
be supplied when defining a sensor");
    +        String className = Preconditions.checkNotNull(params.get(SENSOR_TYPE), "target
class must be supplied when defining a sensor");
    +        Class<T> type = null;
    +
    +        try {
    +            type = (Class<T>) Class.forName(className);
    --- End diff --
    
    You're right, i can also add some type checking for basic types (in the end most of them
will be either String, Number or Boolean since it comes from a JSON) similar on how it's done
in `JsonFunctions.cast`.


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