PortletContextResourcePatternResolver.java 文件源码

java
阅读 18 收藏 0 点赞 0 评论 0

项目:spring4-understanding 作者:
/**
 * Recursively retrieve PortletContextResources that match the given pattern,
 * adding them to the given result set.
 * @param portletContext the PortletContext to work on
 * @param fullPattern the pattern to match against,
 * with preprended root directory path
 * @param dir the current directory
 * @param result the Set of matching Resources to add to
 * @throws IOException if directory contents could not be retrieved
 * @see org.springframework.web.portlet.context.PortletContextResource
 * @see javax.portlet.PortletContext#getResourcePaths
 */
protected void doRetrieveMatchingPortletContextResources(
        PortletContext portletContext, String fullPattern, String dir, Set<Resource> result) throws IOException {

    Set<String> candidates = portletContext.getResourcePaths(dir);
    if (candidates != null) {
        boolean dirDepthNotFixed = fullPattern.contains("**");
        for (Iterator<String> it = candidates.iterator(); it.hasNext();) {
            String currPath = it.next();
            if (currPath.endsWith("/") &&
                    (dirDepthNotFixed ||
                    StringUtils.countOccurrencesOf(currPath, "/") <= StringUtils.countOccurrencesOf(fullPattern, "/"))) {
                doRetrieveMatchingPortletContextResources(portletContext, fullPattern, currPath, result);
            }
            if (getPathMatcher().match(fullPattern, currPath)) {
                result.add(new PortletContextResource(portletContext, currPath));
            }
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号