Closed allenxwang closed 11 years ago
This type of new PropertyWrapper will also be made to understand single textual property value, same as DynamicIntProperty, DynamicBooleanProperty, etc, with a slight performance penalty compared with the latter on single textual value.
This enhancement will also provide solutions for Issue #74, since all possible values of the property are encoded as one JSON blob and a predicate can be used to select the most appropriate value.
added in 0.5.9.
Currently dynamic property can change value based on changes in configuration and changes in deployment context. There is a need to further extend this capability to make the property value change based on other context at runtime like user input. For example, a web application may want certain dynamic property value changed based on one or more parameters in the http request.
The current proposal consists of the following component:
This blob means that
If dimension "d1" has value of either "v1" or "v2", the value of the property is integer 5; Else if dimension "d1" has value "v3" and dimension "d2" has value "x1", the value of the property is 10; Otherwise, the value of the property is 2
Map<String, Collection<String>>
(corresponds to "dimensions" in the above example) and determine if the current runtime context matches the condition described in the Map.PropertyWrapper<T>
that takes the above two components and returns the dynamic value in its getValue() method. Assuming each element in the JSON array above is of type Value, the getValue() can be implemented as: