public class ResourceLoaderStrategy extends Object implements ResourceLoader
ResourceLoader that defines a strategy to load different types of resources based on
user provided values. It loads three different types of resources : ClasspathResource - Resource
representing the Classpath based resources(prefixed with classpath:)FileSystemResource - Resource
based on FileSystem (for eg. in your C: drive)UrlResource - Resource based on URL (http for eg)| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
LOG
An instance of logger associated with the test framework.
|
CLASSPATH_PREFIX, FILE_PREFIX, URL_PREFIX| Constructor and Description |
|---|
ResourceLoaderStrategy()
Construct a new ResourceLoaderStrategy
|
ResourceLoaderStrategy(Class classObj)
Construct a new ResourceLoaderStrategy
|
ResourceLoaderStrategy(ClassLoader classLoader)
Construct a new ResourceLoaderStrategy
|
ResourceLoaderStrategy(ClassLoader classLoader,
Class classObj)
Construct a new ResourceLoaderStrategy
|
| Modifier and Type | Method and Description |
|---|---|
ClassLoader |
getClassLoader()
Get the associated ClassLoader
|
Class<?> |
getClassObj() |
Resource |
getResource(String location)
Get the resource based on the location.
|
protected static final org.slf4j.Logger LOG
public ResourceLoaderStrategy()
public ResourceLoaderStrategy(Class classObj)
classObj - the class objectpublic ResourceLoaderStrategy(ClassLoader classLoader)
classLoader - the class loaderpublic ResourceLoaderStrategy(ClassLoader classLoader, Class classObj)
classLoader - classObj - public Resource getResource(String location)
ClasspathResource instance
based on the provided location.UrlResource. If the
UrlResource cannot be created due to MalformedURLException then we return a
FileSystemResource instance and pray to God that it works :)getResource in interface ResourceLoaderlocation - the location of the resourceResource instance.public ClassLoader getClassLoader()
getClassLoader in interface ResourceLoaderpublic Class<?> getClassObj()
Copyright © 2014. All rights reserved.