Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package io.undertow.server.handlers.resource;
 
 
 import java.net.URL;

Author(s):
Stuart Douglas
public class ClassPathResourceManager implements ResourceManager {

    
The class loader that is used to load resources
    private final ClassLoader classLoader;
    
The prefix that is appended to resources that are to be loaded.
    private final String prefix;
    public ClassPathResourceManager(final ClassLoader loaderfinal Package p) {
        this(loaderp.getName().replace(".""/"));
    }
    public ClassPathResourceManager(final ClassLoader classLoaderfinal String prefix) {
        this. = classLoader;
        if (prefix.equals("")) {
            this. = "";
        } else if (prefix.endsWith("/")) {
            this. = prefix;
        } else {
            this. = prefix + "/";
        }
    }
    public ClassPathResourceManager(final ClassLoader classLoader) {
        this(classLoader"");
    }
    @Override
    public Resource getResource(final String paththrows IOException {
        String modPath = path;
        if(modPath.startsWith("/")) {
            modPath = path.substring(1);
        }
        final String realPath =  + modPath;
        final URL resource = .getResource(realPath);
        if(resource == null) {
            return null;
        } else {
            return new URLResource(resourceresource.openConnection(), path);
        }
    }
    @Override
    public boolean isResourceChangeListenerSupported() {
        return false;
    }
    @Override
    public void registerResourceChangeListener(ResourceChangeListener listener) {
    }
    @Override
    public void removeResourceChangeListener(ResourceChangeListener listener) {
    }
    @Override
    public void close() throws IOException {
    }
New to GrepCode? Check out our FAQ X