@Bean
@ConditionalOnBean(JolokiaMvcEndpoint.class)
public SimpleUrlHandlerMapping hawtioUrlMapping(
final ManagementServerProperties managementServerProperties,
final HawtioEndpoint hawtioEndpoint,
final JolokiaMvcEndpoint jolokiaEndpoint) {
final String hawtioPath = Strings.webContextPath(hawtioEndpoint.getPath());
final String jolokiaPath = Strings.webContextPath(jolokiaEndpoint.getPath());
final SilentSimpleUrlHandlerMapping mapping = new SilentSimpleUrlHandlerMapping();
final Map<String, Object> urlMap = new HashMap<>();
if (!hawtioPath.isEmpty() || !"/jolokia".equals(jolokiaPath)) {
final String hawtioJolokiaPath = Strings.webContextPath(
managementServerProperties.getContextPath(), hawtioPath,
"jolokia", "**");
urlMap.put(hawtioJolokiaPath,
new JolokiaForwardingController(jolokiaEndpoint.getPath()));
mapping.setOrder(Ordered.HIGHEST_PRECEDENCE);
} else {
urlMap.put(SilentSimpleUrlHandlerMapping.DUMMY, null);
}
mapping.setUrlMap(urlMap);
return mapping;
}