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(); }
protected ResourcePatternResolver createAppropriateResourceResolver() { if (dbScriptsDirectory.startsWith(WEB_INF_LABEL)) { return new ServletContextResourcePatternResolver(ServletContextHolder.getServletContext()); } else { return new PathMatchingResourcePatternResolver(); } }
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); }
/** * @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; }
public SpringWildcardServletTilesApplicationContext(ServletContext servletContext) { super(servletContext); this.resolver = new ServletContextResourcePatternResolver(servletContext); }
public StubWebApplicationContext(ServletContext servletContext) { this.servletContext = servletContext; this.resourcePatternResolver = new ServletContextResourcePatternResolver(servletContext); }
/** * Class constructor. */ public StubWebApplicationContext(ServletContext servletContext) { this.servletContext = servletContext; this.resourcePatternResolver = new ServletContextResourcePatternResolver(servletContext); }