org.sakaiproject.entitybroker.util.spring
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)
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
relativePath
public static String relativePath
environmentPathVariable
public static String environmentPathVariable
ResourceFinder
public ResourceFinder()
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
getFiles
public static File[] getFiles(List<String> paths)
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
getFile
public static File getFile(String path)
getInputStream
public static InputStream getInputStream(String path)
getRelativePath
protected static String getRelativePath()
getEnvironmentPath
protected static String getEnvironmentPath()
getContainerHome
protected static String getContainerHome()
Copyright © 2007-2013 CARET, University of Cambridge. All Rights Reserved.