Search in sources :

Example 1 with ClassLoaderFileURLStreamHandler

use of org.springframework.boot.devtools.restart.classloader.ClassLoaderFileURLStreamHandler in project spring-boot by spring-projects.

the class ClassLoaderFilesResourcePatternResolver method getAdditionalResources.

private List<Resource> getAdditionalResources(String locationPattern) throws MalformedURLException {
    List<Resource> additionalResources = new ArrayList<>();
    String trimmedLocationPattern = trimLocationPattern(locationPattern);
    for (SourceFolder sourceFolder : this.classLoaderFiles.getSourceFolders()) {
        for (Entry<String, ClassLoaderFile> entry : sourceFolder.getFilesEntrySet()) {
            String name = entry.getKey();
            ClassLoaderFile file = entry.getValue();
            if (file.getKind() == Kind.ADDED && this.antPathMatcher.match(trimmedLocationPattern, name)) {
                URL url = new URL("reloaded", null, -1, "/" + name, new ClassLoaderFileURLStreamHandler(file));
                UrlResource resource = new UrlResource(url);
                additionalResources.add(resource);
            }
        }
    }
    return additionalResources;
}
Also used : SourceFolder(org.springframework.boot.devtools.restart.classloader.ClassLoaderFiles.SourceFolder) ClassLoaderFileURLStreamHandler(org.springframework.boot.devtools.restart.classloader.ClassLoaderFileURLStreamHandler) UrlResource(org.springframework.core.io.UrlResource) ArrayList(java.util.ArrayList) UrlResource(org.springframework.core.io.UrlResource) ServletContextResource(org.springframework.web.context.support.ServletContextResource) Resource(org.springframework.core.io.Resource) AbstractResource(org.springframework.core.io.AbstractResource) ClassLoaderFile(org.springframework.boot.devtools.restart.classloader.ClassLoaderFile) URL(java.net.URL)

Aggregations

URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 ClassLoaderFile (org.springframework.boot.devtools.restart.classloader.ClassLoaderFile)1 ClassLoaderFileURLStreamHandler (org.springframework.boot.devtools.restart.classloader.ClassLoaderFileURLStreamHandler)1 SourceFolder (org.springframework.boot.devtools.restart.classloader.ClassLoaderFiles.SourceFolder)1 AbstractResource (org.springframework.core.io.AbstractResource)1 Resource (org.springframework.core.io.Resource)1 UrlResource (org.springframework.core.io.UrlResource)1 ServletContextResource (org.springframework.web.context.support.ServletContextResource)1