Class 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: <property name="configLocation"> <bean class="org.sakaiproject.entitybroker.impl.util.ResourceFinder" factory-method="getResource"> <constructor-arg value="ehcache.xml" /> </bean> </property> Just call whichever get* method you want to depending on the needed output
    You can also get arrays of resources at once like so: <property name="mappingLocations"> <bean class="org.sakaiproject.entitybroker.impl.util.ResourceFinder" factory-method="getResources"> <constructor-arg> <list> <value>org/sakaiproject/hierarchy/dao/hbm/HierarchyPersistentNode.hbm.xml</value> <value>org/sakaiproject/hierarchy/dao/hbm/HierarchyNodeMetaData.hbm.xml</value> </list> </constructor-arg> </bean> </property>
    Author:
    Aaron Zeckoski (aaron@caret.cam.ac.uk)
    • Field Detail

      • relativePath

        public static String relativePath
      • environmentPathVariable

        public static String environmentPathVariable
    • Constructor Detail

      • ResourceFinder

        public ResourceFinder()
    • 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
      • 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)
      • getRelativePath

        protected static String getRelativePath()
      • getEnvironmentPath

        protected static String getEnvironmentPath()
      • getContainerHome

        protected static String getContainerHome()