Package org.grails.core.io
Class DefaultResourceLocator
- java.lang.Object
-
- org.grails.core.io.DefaultResourceLocator
-
- All Implemented Interfaces:
PluginManagerAware,ResourceLocator,org.springframework.beans.factory.Aware,org.springframework.context.ResourceLoaderAware
public class DefaultResourceLocator extends java.lang.Object implements ResourceLocator, org.springframework.context.ResourceLoaderAware, PluginManagerAware
Default ResourceLocator implementation that doesn't take into account servlet loading.- Since:
- 2.0
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,org.springframework.core.io.Resource>classNameToResourceCacheprotected java.util.List<java.lang.String>classSearchDirectoriesstatic java.lang.StringCLOSURE_MARKERprotected org.springframework.core.io.ResourceLoaderdefaultResourceLoaderstatic java.lang.StringFILE_SEPARATORprotected static org.springframework.core.io.ResourceNULL_RESOURCEprotected org.springframework.core.io.support.PathMatchingResourcePatternResolverpatchMatchingResolverprotected GrailsPluginManagerpluginManagerprotected java.util.List<java.lang.String>resourceSearchDirectoriesprotected java.util.Map<java.lang.String,org.springframework.core.io.Resource>uriToResourceCacheprotected booleanwarDeployedstatic java.lang.StringWEB_APP_DIRstatic java.lang.StringWILDCARD
-
Constructor Summary
Constructors Constructor Description DefaultResourceLocator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.springframework.core.io.ResourcefindResourceForClassName(java.lang.String className)Finds the .groovy file or .java file for a given class from a Grails project.org.springframework.core.io.ResourcefindResourceForURI(java.lang.String uri)Finds a resource for the given URIprotected org.springframework.core.io.ResourcefindResourceInBinaryPlugins(org.grails.core.io.DefaultResourceLocator.PluginResourceInfo info)protected org.springframework.core.io.ResourceLoadergetDefaultResourceLoader()voidsetPluginManager(GrailsPluginManager pluginManager)Sets the plug-in manager on this instancevoidsetResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)voidsetSearchLocation(java.lang.String searchLocation)The basic location from which to conduct the search.voidsetSearchLocations(java.util.Collection<java.lang.String> searchLocations)Multiple locations to search.
-
-
-
Field Detail
-
WILDCARD
public static final java.lang.String WILDCARD
- See Also:
- Constant Field Values
-
FILE_SEPARATOR
public static final java.lang.String FILE_SEPARATOR
-
CLOSURE_MARKER
public static final java.lang.String CLOSURE_MARKER
- See Also:
- Constant Field Values
-
WEB_APP_DIR
public static final java.lang.String WEB_APP_DIR
- See Also:
- Constant Field Values
-
NULL_RESOURCE
protected static final org.springframework.core.io.Resource NULL_RESOURCE
-
patchMatchingResolver
protected org.springframework.core.io.support.PathMatchingResourcePatternResolver patchMatchingResolver
-
classSearchDirectories
protected java.util.List<java.lang.String> classSearchDirectories
-
resourceSearchDirectories
protected java.util.List<java.lang.String> resourceSearchDirectories
-
classNameToResourceCache
protected java.util.Map<java.lang.String,org.springframework.core.io.Resource> classNameToResourceCache
-
uriToResourceCache
protected java.util.Map<java.lang.String,org.springframework.core.io.Resource> uriToResourceCache
-
defaultResourceLoader
protected org.springframework.core.io.ResourceLoader defaultResourceLoader
-
pluginManager
protected GrailsPluginManager pluginManager
-
warDeployed
protected boolean warDeployed
-
-
Method Detail
-
setSearchLocation
public void setSearchLocation(java.lang.String searchLocation)
Description copied from interface:ResourceLocatorThe 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:
setSearchLocationin interfaceResourceLocator- Parameters:
searchLocation- The search location
-
getDefaultResourceLoader
protected org.springframework.core.io.ResourceLoader getDefaultResourceLoader()
-
setSearchLocations
public void setSearchLocations(java.util.Collection<java.lang.String> searchLocations)
Description copied from interface:ResourceLocatorMultiple locations to search. See #setSearchLocation- Specified by:
setSearchLocationsin interfaceResourceLocator- Parameters:
searchLocations- The locations to search
-
findResourceForURI
public org.springframework.core.io.Resource findResourceForURI(java.lang.String uri)
Description copied from interface:ResourceLocatorFinds a resource for the given URI- Specified by:
findResourceForURIin interfaceResourceLocator- Parameters:
uri- The URI- Returns:
- The resource or null if it doesn't exist
-
findResourceInBinaryPlugins
protected org.springframework.core.io.Resource findResourceInBinaryPlugins(org.grails.core.io.DefaultResourceLocator.PluginResourceInfo info)
-
findResourceForClassName
public org.springframework.core.io.Resource findResourceForClassName(java.lang.String className)
Description copied from interface:ResourceLocatorFinds 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:
findResourceForClassNamein interfaceResourceLocator- Parameters:
className- The class name- Returns:
- The resource or null
-
setResourceLoader
public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
- Specified by:
setResourceLoaderin interfaceorg.springframework.context.ResourceLoaderAware
-
setPluginManager
public void setPluginManager(GrailsPluginManager pluginManager)
Description copied from interface:PluginManagerAwareSets the plug-in manager on this instance- Specified by:
setPluginManagerin interfacePluginManagerAware- Parameters:
pluginManager- The PluginManager
-
-