Searches resource loaders for one that supports the given path. If found, create a new loader with the
context of the base path.

@param basePath The path to load resources from
@return An optional resource loader
161381
public @Nonnull Optional<ResourceLoader> getLoaderForBasePath(@Nonnull String basePath) {
        ArgumentUtils.requireNonNull("basePath", basePath);
        Optional<ResourceLoader> resourceLoader = getSupportingLoader(basePath);
        return resourceLoader.map(rl -> rl.forBase(basePath));
    }
117853
public static String getResource(final String path) {
		final InputStream stream = getResourceStream(path);
		final BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
		final Stream<String> lines = reader.lines();
		return lines.collect(Collectors.joining("\n"));
	}
880037
public SourceHistory[] getSourceHistories(final String basePath) {
    final SourceHistory[] histories = new SourceHistory[this.sources.length];
    for (int i = 0; i < this.sources.length; i++) {
      final String relativeName = CUtil.getRelativePath(basePath, this.sources[i]);
      final long lastModified = this.sources[i].lastModified();
      histories[i] = new SourceHistory(relativeName, lastModified);
    }
    return histories;
  }
974746
private ResourceGenerator loadCommonGenerator(String resourcePath) {

		ResourceGenerator generator = null;

		for (Entry<ResourceGeneratorResolver, Class<?>> entry : commonGenerators.entrySet()) {
			ResourceGeneratorResolver resolver = entry.getKey();
			if (resolver.matchPath(resourcePath)) {
				generator = (ResourceGenerator) ClassLoaderResourceUtils.buildObjectInstance(entry.getValue());
				if (!generator.getResolver().isSameAs(resolver)) {
					throw new BundlingProcessException("The resolver defined for " + generator.getClass().getName()
							+ " is different from the one expected by Jawr.");
				}

				if (resolver.getType().equals(ResolverType.PREFIXED)) {
					loadGeneratorIfNeeded(resolver.getResourcePath(resourcePath));
				}
			}
		}

		if (generator != null) {
			initGenerator(generator);
		}

		return generator;
	}
20325
public InputStream getResource (String path)
        throws IOException
    {
        String localePath = getLocalePath(path);
        InputStream in;

        // first look for this resource in our default resource bundle
        for (ResourceBundle bundle : _default) {
            // Try a localized version first.
            if (localePath != null) {
                in = bundle.getResource(localePath);
                if (in != null) {
                    return in;
                }
            }
            // If that didn't work, try generic.
            in = bundle.getResource(path);
            if (in != null) {
                return in;
            }
        }

        // fallback next to an unpacked resource file
        File file = getResourceFile(path);
        if (file != null && file.exists()) {
            return new FileInputStream(file);
        }

        // if we still didn't find anything, try the classloader; first try a locale-specific file
        if (localePath != null) {
            in = getInputStreamFromClasspath(PathUtil.appendPath(_rootPath, localePath));
            if (in != null) {
                return in;
            }
        }

        // if we didn't find that, try locale-neutral
        in = getInputStreamFromClasspath(PathUtil.appendPath(_rootPath, path));
        if (in != null) {
            return in;
        }

        // if we still haven't found it, we throw an exception
        throw new FileNotFoundException("Unable to locate resource [path=" + path + "]");
    }
179834
public static InputStream getResourceStream(final String path) {
		final ClassLoader loader = Resources.class.getClassLoader();
		return loader.getResourceAsStream(path);
	}
619958
public static Resource create(@NotNull ResourceResolver resourceResolver, @Nullable String path, @NotNull String resourceType) {
    return create(resourceResolver, path, resourceType, ValueMap.EMPTY);
  }
392548
protected Loader<?> getTemplateLoaderForPath(String templateLoaderPath) {
        if (templateLoaderPath.startsWith(ResourceUtils.CLASSPATH_URL_PREFIX)) {
            String basePackagePath = templateLoaderPath.substring(ResourceUtils.CLASSPATH_URL_PREFIX.length());
            if (log.isDebugEnabled()) {
                log.debug("Template loader path [" + templateLoaderPath + "] resolved to class path [" + basePackagePath + "]");
            }
            ClasspathLoader loader = new ClasspathLoader(environment.getClassLoader());
            loader.setPrefix(basePackagePath);
            return loader;
        } else if (templateLoaderPath.startsWith(ResourceUtils.FILE_URL_PREFIX)) {
            File file = new File(templateLoaderPath.substring(ResourceUtils.FILE_URL_PREFIX.length()));
            String prefix = file.getAbsolutePath();
            if (log.isDebugEnabled()) {
                log.debug("Template loader path [" + templateLoaderPath + "] resolved to file path [" + prefix + "]");
            }
            FileLoader loader = new FileLoader();
            loader.setPrefix(prefix);
            return loader;
        } else {
            File file = new File(environment.getBasePath(), templateLoaderPath);
            String prefix = file.getAbsolutePath();
            if (log.isDebugEnabled()) {
                log.debug("Template loader path [" + templateLoaderPath + "] resolved to file path [" + prefix + "]");
            }
            FileLoader loader = new FileLoader();
            loader.setPrefix(prefix);
            return loader;
        }
    }
695316
public static String getPathForResource(final String resourcePath) {
        URL path = ResourceUtil.class.getResource(resourcePath);
        if (path == null) {
            path = ResourceUtil.class.getResource("/");
            File tmpFile = new File(path.getPath(), resourcePath);
            return tmpFile.getPath();
        }

        return path.getPath();
    }
243368
private ResourceGenerator resolveResourceGenerator(String path) {

		ResourceGenerator resourceGenerator = null;
		for (ResourceGeneratorResolverWrapper resolver : resolverRegistry) {
			if (resolver.matchPath(path)) {
				resourceGenerator = resolver.getResourceGenerator();
				if (resolver.getType().equals(ResolverType.PREFIXED)) {
					loadGeneratorIfNeeded(resolver.getResourcePath(path));
				}
				break;
			}
		}

		// Lazy load generator
		if (resourceGenerator == null) {
			resourceGenerator = loadCommonGenerator(path);
		}

		return resourceGenerator;
	}
143293
public static File getFileForResource(final String resourcePath) {
        URL path = ResourceUtil.class.getResource(resourcePath);
        if (path == null) {
            path = ResourceUtil.class.getResource("/");
            return new File(new File(path.getPath()), resourcePath);
        }

        return new File(path.getPath());
    }
647625
@Override
    public URL getResource(final String path) {
        final ResourceList resourceList = scanResult.getResourcesWithPath(path);
        if (resourceList == null || resourceList.isEmpty()) {
            return super.getResource(path);
        } else {
            return resourceList.get(0).getURL();
        }
    }
614428
public B withContextPath(String contextPath) {
        assertNotNull(contextPath, "contextPath  could not be null.");
        getConfig().setContextPath(contextPath);

        return self();
    }
527229
public Routes setBaseViewPath(String baseViewPath) {
		if (StrKit.isBlank(baseViewPath)) {
			throw new IllegalArgumentException("baseViewPath can not be blank");
		}
		
		baseViewPath = baseViewPath.trim();
		if (! baseViewPath.startsWith("/")) {			// add prefix "/"
			baseViewPath = "/" + baseViewPath;
		}
		if (baseViewPath.endsWith("/")) {				// remove "/" in the end of baseViewPath
			baseViewPath = baseViewPath.substring(0, baseViewPath.length() - 1);
		}
		
		this.baseViewPath = baseViewPath;
		return this;
	}
1143588
@Override
    public InputStream getResourceAsStream( String path )
    {
        Object in = null;
        if ( null != baseLoader )
            // classloader wants no leading slash
            in = baseLoader.getResourceAsStream( path.substring(1) );
        if ( null == in )
            return super.getResourceAsStream( path );
        return (InputStream) in;
    }
477068
public static String child(Resource base, String path) {
        Resource child = base.getChild(path);
        return child != null ? child.getPath() : path;
    }
720799
private File findPathResource(@NonNull String httpPath) {
        if ("/".equals(httpPath)) {
            File root = new File(mRootPath);
            return root.exists() ? root : null;
        } else {
            File sourceFile = new File(mRootPath, httpPath);
            if (sourceFile.exists()) {
                return sourceFile;
            }
        }
        return null;
    }