Commons Configuration
  1. Commons Configuration
  2. CONFIGURATION-364

Enhance StrSubstitutor to support nested ${var-${subvr}} expansion

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      It would be really handy of StrSubstitutor could support nested variable interpolation:

      org.osgi.framework.system.packages=org.osgi.framework; version=1.4.0, \
      org.osgi.service.packageadmin; version=1.2.0, \
      org.osgi.service.startlevel; version=1.1.0, \
      org.osgi.service.url; version=1.0.0, \
      org.osgi.util.tracker; version=1.3.3 \
      ${jre-${java.specification.version}}

      The process being to expand innermost variable references first and work outwards - this allows for very advance config, such as the above, which can dynamically detect the Java version and expand a JRE version specific property into the property being defined.

      Looking at the implementation, it seems it might be a fairly straightforward enhancement to:

      private int substitute(StrBuilder buf, int offset, int length, List priorVariables)

      The code already has the cyclic map in place.

      I already have code that achieves this within Apache Felix, so I will see if I can retro-fit a similar model to the above and if so submit a patch.

        Activity

        Rob Walker created issue -
        Rob Walker made changes -
        Field Original Value New Value
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Closed [ 6 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Rob Walker
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development