Class ResourceFinder
- java.lang.Object
-
- org.sakaiproject.entitybroker.util.spring.ResourceFinder
-
public class ResourceFinder extends Object
Takes a path or list of paths to resources and turns them into different things (file/IS/resource), this also allows us to look on a relative or absolute path and will automatically check the typical places one might expect to put sakai config files
Checks the environmental and file paths first and then defaults to checking the classloaders
Allows us to find resources in our pack since the Sakai context classloader is wrong, too bad it is not correct, that would be cool, but it is wrong and it is not cool
Sample usage: Just call whichever get* method you want to depending on the needed output
You can also get arrays of resources at once like so:org/sakaiproject/hierarchy/dao/hbm/HierarchyPersistentNode.hbm.xml org/sakaiproject/hierarchy/dao/hbm/HierarchyNodeMetaData.hbm.xml - Author:
- Aaron Zeckoski (aaron@caret.cam.ac.uk)
-
-
Field Summary
Fields Modifier and Type Field Description static StringenvironmentPathVariablestatic StringrelativePath
-
Constructor Summary
Constructors Constructor Description ResourceFinder()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static StringgetContainerHome()protected static StringgetEnvironmentPath()static FilegetFile(String path)static File[]getFiles(List<String> paths)static InputStreamgetInputStream(String path)static InputStream[]getInputStreams(List<String> paths)protected static StringgetRelativePath()static org.springframework.core.io.ResourcegetResource(String path)Resolve a path into a resource relative to environmental defaults or relative paths or the classloaderstatic org.springframework.core.io.Resource[]getResources(List<String> paths)Resolves a list of paths into resources relative to environmental defaults or relative paths or the classloader
-
-
-
Method Detail
-
getResources
public static org.springframework.core.io.Resource[] getResources(List<String> paths)
Resolves a list of paths into resources relative to environmental defaults or relative paths or the classloader- Parameters:
paths- a list of paths to resources (org/sakaiproject/mystuff/Thing.xml)- Returns:
- an array of Spring Resource objects
-
getInputStreams
public static InputStream[] getInputStreams(List<String> paths)
-
getResource
public static org.springframework.core.io.Resource getResource(String path)
Resolve a path into a resource relative to environmental defaults or relative paths or the classloader- Parameters:
path- a path to a resource (org/sakaiproject/mystuff/Thing.xml)- Returns:
- the Spring Resource object
-
getInputStream
public static InputStream getInputStream(String path)
-
getRelativePath
protected static String getRelativePath()
-
getEnvironmentPath
protected static String getEnvironmentPath()
-
getContainerHome
protected static String getContainerHome()
-
-