private String resolveStringValue()

in impl/src/main/java/org/apache/geronimo/config/ConfigValueImpl.java [295:344]


    private String resolveStringValue() {
        String value = null;

        if (lookupChain != null) {
            // first we resolve the value
            List<String> postfixVals = new ArrayList<>();
            for (String postfix : lookupChain) {
                if (postfix.startsWith("${") && postfix.length() > 3) {
                    String varName = postfix.substring(2, postfix.length()-1);
                    String varValue = config.getValue(varName);
                    if (varValue != null && varValue.length() > 0) {
                        postfixVals.add(varValue);
                    }
                }
                else {
                    postfixVals.add(postfix);
                }
            }

            // binary count down
            for (int mask = (1 << postfixVals.size()) - 1; mask > 0; mask--) {
                StringBuilder sb = new StringBuilder(keyOriginal);
                for (int loc = 0; loc < postfixVals.size(); loc++) {
                    int bitPos = 1 << (postfixVals.size() - loc - 1);
                    if ((mask & bitPos) > 0) {
                        sb.append('.').append(postfixVals.get(loc));
                    }
                }

                value = config.getValue(sb.toString());
                if (value != null && value.length() > 0) {
                    keyResolved = sb.toString();
                    break;
                }
            }

        }

        if (value == null) {
            value = config.getValue(keyOriginal);
            this.keyResolved = keyOriginal;
        }

        if (evaluateVariables && value != null)
        {
            value = replaceVariables(value);

        }
        return value;
    }