@Managed
@ManagedDescription("Enumerates the routes found for the specified request")
@Impact(ImpactType.READ)
public String findRoutes(
@ManagedDescription("The request uri relative to the web application") @ManagedName("uri") String uri) {
Router router = routerRef.get();
if (router != null) {
Map<String, String[]> parameters;
String path;
int pos = uri.indexOf('?');
if (pos != -1) {
parameters = QueryStringParser.getInstance().parseQueryString(uri.substring(pos + 1));
path = uri.substring(0, pos);
} else {
parameters = Collections.emptyMap();
path = uri;
}
//
List<Map<QualifiedName, String>> results = new ArrayList<Map<QualifiedName, String>>();
Iterator<Map<QualifiedName, String>> matcher = router.matcher(path, parameters);
while (matcher.hasNext()) {
Map<QualifiedName, String> match = matcher.next();
results.add(match);
}