Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
-
Operating System: other
Platform: Other
-
35116
Description
At the moment interpolation is only supported by the getString() and
getStringArray() methods. This proposal suggests adding interpolation support
for other getter methods, too, and at the same time making it more customizable
(including the ability to disable it at all).
A first step in achieving this could be to refactor the interpolation
functionality out of AbstractConfiguration and into a new Interpolator class.
This class would provide a main interpolation method and would also maintain an
arbitrary number of objects that know how to resolve variables of certain types.
Each Configuration object would be assigned an Interpolator instance, to which
it would delegate interpolation tasks.
Customization of the interpolation features could be done by assigning an
Interpolator object to a configuration that has been initialized with a custom
set of variable resolver objects. If no Interpolator is assigned, no
interpolation will be performed.
Variable resolver objects are very simple: They define a method which takes a
variable's name and return its value. The variable resolver to use for a
concrete variable is determined by a prefix that can be set for each variable.
So a variable like ${sys:user.home} e.g. might refer to the system properties
resolver. Variables without a prefix are handled by a default resolver, which is
implemented by the Configuration object itself, so that the Configuration's
properties are used as variable values (which is backwards compatible to the
current functionality).
It should be possible to define a default Interpolator (or at least a default
set of variable resolvers) that is to be used by each Configuration object as
long as no special Interpolator is set. This could be done through a static
field in AbstractConfiguration.
Useful specific variable resolver classes could be:
- The already mentioned system properties resolver, which would make system
properties accessable in each configuration. - A resolver that would read constant values from specified classes.
- A resolver that would evaluate expressions in an expression language like EL.
Attachments
Attachments
Issue Links
- is related to
-
CONFIGURATION-266 Improving backward compatibility in ConfigurationInterpolator
- Closed