Class ResourceLoader
java.lang.Object
com.espertech.esper.common.internal.util.ResourceLoader
Utility class for loading or resolving external resources via URL and class path.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic URL
getClasspathResourceAsURL
(String resourceName, String resource, ClassLoader classLoader) Returns an URL from an application resource in the classpath.static URL
resolveClassPathOrURLResource
(String resourceName, String urlOrClasspathResource, ClassLoader classLoader) Resolve a resource into a URL using the URL string or classpath-relative filename and using a name for any exceptions thrown.
-
Constructor Details
-
ResourceLoader
public ResourceLoader()
-
-
Method Details
-
resolveClassPathOrURLResource
public static URL resolveClassPathOrURLResource(String resourceName, String urlOrClasspathResource, ClassLoader classLoader) throws FileNotFoundException Resolve a resource into a URL using the URL string or classpath-relative filename and using a name for any exceptions thrown.- Parameters:
resourceName
- is the name for use in exceptionsurlOrClasspathResource
- is a URL string or classpath-relative filenameclassLoader
- class loader- Returns:
- URL or null if resolution was unsuccessful
- Throws:
FileNotFoundException
- resource not found
-
getClasspathResourceAsURL
public static URL getClasspathResourceAsURL(String resourceName, String resource, ClassLoader classLoader) throws FileNotFoundException Returns an URL from an application resource in the classpath.The method first removes the '/' character from the resource name if the first character is '/'.
The lookup order is as follows:
If a thread context class loader exists, use
Thread.currentThread().getResourceAsStream
to obtain an InputStream.If no input stream was returned, use the
Configuration.class.getResourceAsStream
. to obtain an InputStream.If no input stream was returned, use the
Configuration.class.getClassLoader().getResourceAsStream
. to obtain an InputStream.If no input stream was returned, throw an Exception.
- Parameters:
resourceName
- is the name for use in exceptionsresource
- is the classpath-relative filename to resolve into a URLclassLoader
- class loader- Returns:
- URL for resource
- Throws:
FileNotFoundException
- resource not found
-