src/main/java/com/amlinv/jmxutil/polling/ParameterReplacer.java
public String replaceObjectNameParameters (String pattern, MBeanLocationParameterSource parameterSource) {
        Matcher matcher = replaceParamPattern.matcher(pattern);
        StringBuffer result = new StringBuffer();

        while ( matcher.find() ) {
            String name = matcher.group("paramName");
            String value = parameterSource.getParameter(name);

            if ( value != null ) {
                matcher.appendReplacement(result, value);
            } else {
                matcher.appendReplacement(result, Matcher.quoteReplacement(matcher.group()));
            }
        }

        matcher.appendTail(result);

        return  result.toString();
    }
public String replaceObjectNameParameters (String pattern, MBeanLocationParameterSource parameterSource) {
        Matcher matcher = replaceParamPattern.matcher(pattern);
        StringBuffer result = new StringBuffer();

        while ( matcher.find() ) {
            String name = matcher.group("paramName");
            String value = parameterSource.getParameter(name);

            if ( value != null ) {
                matcher.appendReplacement(result, value);
            } else {
                matcher.appendReplacement(result, Matcher.quoteReplacement(matcher.group()));
            }
        }

        matcher.appendTail(result);

        return  result.toString();
    }
Given a string potentially containing one or more copies of the replacement pattern, ${name}, where name may be
any value identifier (e.g. home_dir1), replace each occurrence with the value of the parameter with the enclosed
name.

@param pattern string potentially containing one or more copies of the replacement pattern.
@param parameterSource source of values for parameters for replacement into the given pattern.
@return resulting string after replacing parameter values for the replacement pattern.