Updated Branches: refs/heads/wicket-1.5.x f5e22ae3b -> 2716aa945
WICKET-4835 Add debug log messages in CompoundRequestMapper#mapRequest Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/2716aa94 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/2716aa94 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/2716aa94 Branch: refs/heads/wicket-1.5.x Commit: 2716aa9450c270ebdb7e47c0dfdd2bc462246c75 Parents: f5e22ae Author: Martin Tzvetanov Grigorov <[email protected]> Authored: Fri Nov 2 17:22:46 2012 +0200 Committer: Martin Tzvetanov Grigorov <[email protected]> Committed: Fri Nov 2 17:23:20 2012 +0200 ---------------------------------------------------------------------- .../request/mapper/CompoundRequestMapper.java | 45 +++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/2716aa94/wicket-request/src/main/java/org/apache/wicket/request/mapper/CompoundRequestMapper.java ---------------------------------------------------------------------- diff --git a/wicket-request/src/main/java/org/apache/wicket/request/mapper/CompoundRequestMapper.java b/wicket-request/src/main/java/org/apache/wicket/request/mapper/CompoundRequestMapper.java index 535ccc8..c33d7e3 100644 --- a/wicket-request/src/main/java/org/apache/wicket/request/mapper/CompoundRequestMapper.java +++ b/wicket-request/src/main/java/org/apache/wicket/request/mapper/CompoundRequestMapper.java @@ -28,6 +28,8 @@ import org.apache.wicket.request.IRequestHandler; import org.apache.wicket.request.IRequestMapper; import org.apache.wicket.request.Request; import org.apache.wicket.request.Url; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** @@ -40,6 +42,8 @@ import org.apache.wicket.request.Url; */ public class CompoundRequestMapper implements ICompoundRequestMapper { + private static final Logger LOG = LoggerFactory.getLogger(CompoundRequestMapper.class); + /** * */ @@ -126,6 +130,11 @@ public class CompoundRequestMapper implements ICompoundRequestMapper Collections.sort(list); + if (LOG.isDebugEnabled()) + { + logMappers(list, request.getUrl().toString()); + } + for (MapperWithScore mapperWithScore : list) { IRequestMapper mapper = mapperWithScore.getMapper(); @@ -140,6 +149,42 @@ public class CompoundRequestMapper implements ICompoundRequestMapper } /** + * Logs all mappers with a positive compatibility score + * + * @param mappersWithScores + * the list of all mappers + * @param url + * the url to match by these mappers + */ + private void logMappers(final List<MapperWithScore> mappersWithScores, final String url) + { + final List<MapperWithScore> compatibleMappers = new ArrayList<MapperWithScore>(); + for (MapperWithScore mapperWithScore : mappersWithScores) + { + if (mapperWithScore.compatibilityScore > 0) + { + compatibleMappers.add(mapperWithScore); + } + } + if (compatibleMappers.size() == 0) + { + LOG.debug("No compatible mapper found for URL '{}'", url); + } + else if (compatibleMappers.size() == 1) + { + LOG.debug("One compatible mapper found for URL '{}' -> '{}'", url, compatibleMappers.get(0)); + } + else + { + LOG.debug("Multiple compatible mappers found for URL '{}'", url); + for (MapperWithScore compatibleMapper : compatibleMappers) + { + LOG.debug(" * {}", compatibleMapper); + } + } + } + + /** * Searches the registered {@link IRequestMapper}s to find one that can map the * {@link IRequestHandler}. Each registered {@link IRequestMapper} is asked to map the * {@link IRequestHandler} until a mapper which can map the {@link IRequestHandler} is found or
