Updated Branches: refs/heads/master 7d139086f -> 70d5addea
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/70d5adde Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/70d5adde Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/70d5adde Branch: refs/heads/master Commit: 70d5addea0e0ed19a02f0fcac0b1a81722334a26 Parents: 7d13908 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:22:46 2012 +0200 ---------------------------------------------------------------------- .../request/mapper/CompoundRequestMapper.java | 45 +++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/70d5adde/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 6dd68ff..ae13ac2 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); + /** * */ @@ -137,6 +141,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(); @@ -151,6 +160,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
