Using spring DefaultAnnotationHandlerMapping how can I lookup the Controller that would ultimately handle a given url.
I currently have this, but feels like there ought to be a cleaner way than iterating over 100s of request mappings:
public static Object getControllerForAction(String actionURL) {
ApplicationContext context = getApplicationContext();
AnnotationHandlerMapping mapping = (AnnotationHandlerMapping) context.getBean("annotationMapper");
PathMatcher pathMatcher = mapping.getPathMatcher();
for (Object key: mapping.getHandlerMap().keySet()) {
if (pathMatcher.match((String) key, actionURL)){
return mapping.getHandlerMap().get(key);
}
}
return null;
}