Java 类org.springframework.web.context.support.ServletContextResourcePatternResolver 实例源码

项目:edsutil    文件:WebResourceProcessor.java   
private List<Resource> enumerateResourcesFromWebapp(final String line,
        final String suffix) throws IOException {
    if (line.endsWith("/")) {
        ServletContextResourcePatternResolver resourceResolver = new ServletContextResourcePatternResolver(
                this.servletContext);
        String location = line + "**/*" + suffix;
        Resource[] resources = resourceResolver.getResources(location);
        return Arrays.asList(resources);
    }

    if (line.endsWith(suffix)) {
        return Collections.singletonList(new ServletContextResource(
                this.servletContext, line));
    }

    return Collections.emptyList();
}
项目:cuba    文件:ScriptScanner.java   
protected ResourcePatternResolver createAppropriateResourceResolver() {
    if (dbScriptsDirectory.startsWith(WEB_INF_LABEL)) {
        return new ServletContextResourcePatternResolver(ServletContextHolder.getServletContext());
    } else {
        return new PathMatchingResourcePatternResolver();
    }
}
项目:class-guard    文件:SpringTilesApplicationContextFactory.java   
public SpringWildcardServletTilesApplicationContext(ServletContext servletContext, Map<String, String> params) {
    super(servletContext);
    this.mergedInitParams = new LinkedHashMap<String, String>();
    Enumeration initParamNames = servletContext.getInitParameterNames();
    while (initParamNames.hasMoreElements()) {
        String initParamName = (String) initParamNames.nextElement();
        this.mergedInitParams.put(initParamName, servletContext.getInitParameter(initParamName));
    }
    if (params != null) {
        this.mergedInitParams.putAll(params);
    }
    this.resolver = new ServletContextResourcePatternResolver(servletContext);
}
项目:wmix    文件:WmixContextLoaderListener.java   
/**
 * @param componentsConfig
 * @param servletContext2
 * @return
 */
private Map<String, String> findComponents(
    ComponentsConfig componentsConfig, ServletContext servletContext) {
    String locationPattern = componentsConfig.getDiscoveryLocationPattern();
    String[] prefixAndPattern = checkComponentConfigurationLocationPattern(locationPattern);
    String prefix = prefixAndPattern[0];
    String pathPattern = prefixAndPattern[1];

    Map<String, String> componentNamesAndLocations = new TreeMap<String, String>();
    if(componentsConfig.isAutoDiscovery()){
        try {
            ResourcePatternResolver resolver = new ServletContextResourcePatternResolver(servletContext);
            Resource[] componentConfigurations = resolver.getResources(locationPattern);
            Pattern pattern = PathNameWildcardCompiler.compilePathName(pathPattern);
            if (componentConfigurations != null) {
                for (Resource resource : componentConfigurations) {
                    String path = resource.getURL().getPath();
                    Matcher matcher = pattern.matcher(path);

                    Assert.assertTrue(matcher.find(), "unknown component configuration file: %s", path);
                    String componentName = StringUtils.trimToNull(matcher.group(1));

                    if (componentName != null) {
                        componentNamesAndLocations.put(componentName,
                                                       prefix + pathPattern.replace("*", componentName));
                    }
                }
            }

        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
    return componentNamesAndLocations;
}
项目:spring4-understanding    文件:SpringWildcardServletTilesApplicationContext.java   
public SpringWildcardServletTilesApplicationContext(ServletContext servletContext) {
    super(servletContext);
    this.resolver = new ServletContextResourcePatternResolver(servletContext);
}
项目:spring4-understanding    文件:SpringWildcardServletTilesApplicationContext.java   
public SpringWildcardServletTilesApplicationContext(ServletContext servletContext) {
    super(servletContext);
    this.resolver = new ServletContextResourcePatternResolver(servletContext);
}
项目:spring4-understanding    文件:StubWebApplicationContext.java   
public StubWebApplicationContext(ServletContext servletContext) {
    this.servletContext = servletContext;
    this.resourcePatternResolver = new ServletContextResourcePatternResolver(servletContext);
}
项目:class-guard    文件:StubWebApplicationContext.java   
/**
 * Class constructor.
 */
public StubWebApplicationContext(ServletContext servletContext) {
    this.servletContext = servletContext;
    this.resourcePatternResolver = new ServletContextResourcePatternResolver(servletContext);
}
项目:class-guard    文件:SpringWildcardServletTilesApplicationContext.java   
public SpringWildcardServletTilesApplicationContext(ServletContext servletContext) {
    super(servletContext);
    this.resolver = new ServletContextResourcePatternResolver(servletContext);
}