JMXLocationResolver implements LocationResolver<JMXNodeLocation> { @Override public String applyTemplate(String nameTemplate, JMXNodeLocation location, String endpointName) { nameTemplate = nameTemplate.replace("%_ManagedServerName%", endpointName); for (Map.Entry<String, String> entry : location.getObjectName().getKeyPropertyList().entrySet()) { if (nameTemplate.indexOf("%") == -1) { break; } String key = entry.getKey(); String value = entry.getValue(); nameTemplate = nameTemplate.replace("%" + key + "%", value); } return nameTemplate; }  @Override JMXNodeLocation buildLocation(String path); @Override String findWildcardMatch(JMXNodeLocation multiTargetLocation, JMXNodeLocation singleLocation); @Override boolean isMultiTarget(JMXNodeLocation location); @Override JMXNodeLocation absolutize(JMXNodeLocation base, JMXNodeLocation location); @Override boolean isParent(JMXNodeLocation parent, JMXNodeLocation child); @Override boolean matches(JMXNodeLocation query, JMXNodeLocation location); @Override String applyTemplate(String nameTemplate, JMXNodeLocation location, String endpointName);  }
@Test public void testApplyTemplate() throws Exception { JMXLocationResolver resolver = new JMXLocationResolver(); JMXNodeLocation location = new JMXNodeLocation("domain:one=1,two=2"); String endpointName = "eName"; String str = resolver.applyTemplate("hello", location, endpointName); Assert.assertEquals("hello", str); str = resolver.applyTemplate("hello %two%", location, endpointName); Assert.assertEquals("hello 2", str); str = resolver.applyTemplate("hello %one% %two%", location, endpointName); Assert.assertEquals("hello 1 2", str); str = resolver.applyTemplate("hello %one%.%two%.[%_ManagedServerName%]", location, endpointName); Assert.assertEquals("hello 1.2.[eName]", str); }