Class StaticResourceLocator

  • All Implemented Interfaces:
    ResourceLocator

    public class StaticResourceLocator
    extends java.lang.Object
    implements ResourceLocator
    A static resource locator that uses an internal map to locate resources. Used largely for testing.
    Since:
    2.0
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addClassResource​(java.lang.String className, org.springframework.core.io.Resource res)  
      org.springframework.core.io.Resource findResourceForClassName​(java.lang.String className)
      Finds the .groovy file or .java file for a given class from a Grails project.
      org.springframework.core.io.Resource findResourceForURI​(java.lang.String uri)
      Finds a resource for the given URI
      void setSearchLocation​(java.lang.String searchLocation)
      The basic location from which to conduct the search.
      void setSearchLocations​(java.util.Collection<java.lang.String> searchLocations)
      Multiple locations to search.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StaticResourceLocator

        public StaticResourceLocator()
    • Method Detail

      • setSearchLocation

        public void setSearchLocation​(java.lang.String searchLocation)
        Description copied from interface: ResourceLocator
        The basic location from which to conduct the search. At development time this is the base directory, during production this would be the servlet root
        Specified by:
        setSearchLocation in interface ResourceLocator
        Parameters:
        searchLocation - The search location
      • setSearchLocations

        public void setSearchLocations​(java.util.Collection<java.lang.String> searchLocations)
        Description copied from interface: ResourceLocator
        Multiple locations to search. See #setSearchLocation
        Specified by:
        setSearchLocations in interface ResourceLocator
        Parameters:
        searchLocations - The locations to search
      • findResourceForURI

        public org.springframework.core.io.Resource findResourceForURI​(java.lang.String uri)
        Description copied from interface: ResourceLocator
        Finds a resource for the given URI
        Specified by:
        findResourceForURI in interface ResourceLocator
        Parameters:
        uri - The URI
        Returns:
        The resource or null if it doesn't exist
      • findResourceForClassName

        public org.springframework.core.io.Resource findResourceForClassName​(java.lang.String className)
        Description copied from interface: ResourceLocator
        Finds the .groovy file or .java file for a given class from a Grails project. Note that this method will return null in production since sources are not packaged unless an appropriate search location is specified to locate the resource
        Specified by:
        findResourceForClassName in interface ResourceLocator
        Parameters:
        className - The class name
        Returns:
        The resource or null
      • addClassResource

        public void addClassResource​(java.lang.String className,
                                     org.springframework.core.io.Resource res)