Package org.apache.catalina
Interface WebResourceRoot
- All Superinterfaces:
- Lifecycle
- All Known Implementing Classes:
- ExtractingRoot,- StandardRoot
Represents the complete set of resources for a web application. The resources
 for a web application comprise of multiple ResourceSets and when looking for
 a Resource, the ResourceSets are processed in the following order:
 
- Pre - Resources defined by the <PreResource> element in the web application's context.xml. Resources will be searched in the order they were specified.
- Main - The main resources for the web application - i.e. the WAR or the directory containing the expanded WAR
- JARs - Resource JARs as defined by the Servlet specification. JARs will be searched in the order they were added to the ResourceRoot.
- Post - Resources defined by the <PostResource> element in the web application's context.xml. Resources will be searched in the order they were specified.
- Write operations (including delete) will only be applied to the main ResourceSet. The write operation will fail if the presence of a Resource in one of the other ResourceSets effectively makes the operation on the main ResourceSet a NO-OP.
- A file in a ResourceSet will hide a directory of the same name (and all the contents of that directory) in a ResourceSet that is later in the search order.
- Only the main ResourceSet may define a META-INF/context.xml since that file defines the Pre- and Post-Resources.
- As per the Servlet specification, any META-INF or WEB-INF directories in a resource JAR will be ignored.
- Pre- and Post-Resources may define WEB-INF/lib and WEB-INF/classes in order to make additional libraries and/or classes available to the web application.
- Aliases - Replaced by Post-Resources with the addition of support for single files as well as directories and JARs.
- VirtualWebappLoader - Replaced by Pre- and Post-Resources mapped to WEB-INF/lib and WEB-INF/classes
- VirtualDirContext - Replaced by Pre- and Post-Resources
- External repositories - Replaced by Pre- and Post-Resources mapped to WEB-INF/lib and WEB-INF/classes
- Resource JARs - Same feature but implemented using the same mechanism as all the other additional resources.
- 
Nested Class SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic enumstatic interfaceProvides a mechanism to modify the caching behaviour.static enumNested classes/interfaces inherited from interface org.apache.catalina.LifecycleLifecycle.SingleUse
- 
Field SummaryFields inherited from interface org.apache.catalina.LifecycleAFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddJarResources(WebResourceSet webResourceSet) Adds the provided WebResourceSet to this web application as a 'Jar' resource.voidaddPostResources(WebResourceSet webResourceSet) Adds the provided WebResourceSet to this web application as a 'Post' resource.voidaddPreResources(WebResourceSet webResourceSet) Adds the provided WebResourceSet to this web application as a 'Pre' resource.voidThis method will be invoked by the context on a periodic basis and allows the implementation a method that executes periodic tasks, such as purging expired cache entries.voidcreateWebResourceSet(WebResourceRoot.ResourceSetType type, String webAppMount, String base, String archivePath, String internalPath) Creates a newWebResourceSetfor thisWebResourceRootbased on the provided parameters.voidcreateWebResourceSet(WebResourceRoot.ResourceSetType type, String webAppMount, URL url, String internalPath) Creates a newWebResourceSetfor thisWebResourceRootbased on the provided parameters.voidderegisterTrackedResource(TrackedWebResource trackedResource) Stop tracking specified resource, once it no longer needs to free resources.voidgc()Implementations may cache some information to improve performance.booleanDetermine if this resources allow the use of symbolic links.Get the strategy to use for the resources archive lookup.Get the strategy to use for the resources archive lookup.longGet the maximum permitted size for the cache.intGet the maximum permitted size for a single object in the cache.default WebResourceRoot.CacheStrategyObtain the current caching strategy.longGet the Time-To-Live (TTL) for cache entries.getClassLoaderResource(String path) Obtain the object that represents the class loader resource at the given path.Obtain the objects that represent the class loader resource at the given path.getResource(String path) Obtain the object that represents the resource at the given path.getResources(String path) Obtain the objects that represent the resource at the given path.booleanHas the track locked files feature been enabled?booleanString[]Obtain the list of the names of all of the files and directories located in the specified directory.listResources(String path) Obtain the list of all of the WebResources in the specified directory.listWebAppPaths(String path) Obtain the Set of the web applications pathnames of all of the files and directories located in the specified directory.booleanCreate a new directory at the given path.voidregisterTrackedResource(TrackedWebResource trackedResource) Add a specified resource to track to be able to later release resources on stop.voidsetAllowLinking(boolean allowLinking) Configure if this resources allow the use of symbolic links.voidsetArchiveIndexStrategy(String archiveIndexStrategy) Set the strategy to use for the resources archive lookup.voidsetCacheMaxSize(long cacheMaxSize) Set the maximum permitted size for the cache.voidsetCacheObjectMaxSize(int cacheObjectMaxSize) Set the maximum permitted size for a single object in the cache.default voidSet the current caching strategy.voidsetCacheTtl(long ttl) Set the Time-To-Live (TTL) for cache entries.voidsetCachingAllowed(boolean cachingAllowed) Set whether or not caching is permitted for this web application.voidsetContext(Context context) Set the web application this WebResourceRoot is associated with.voidsetTrackLockedFiles(boolean trackLockedFiles) Controls whether the track locked files feature is enabled.booleanwrite(String path, InputStream is, boolean overwrite) Create a new resource at the requested path using the provided InputStream.Methods inherited from interface org.apache.catalina.LifecycleaddLifecycleListener, destroy, findLifecycleListeners, getState, getStateName, init, removeLifecycleListener, start, stop
- 
Method Details- 
getResourceObtain the object that represents the resource at the given path. Note that the resource at that path may not exist. If the resource does not exist, the WebResource returned will be associated with the main WebResourceSet.- Parameters:
- path- The path for the resource of interest relative to the root of the web application. It must start with '/'.
- Returns:
- The object that represents the resource at the given path
 
- 
getResourcesObtain the objects that represent the resource at the given path. Note that the resource at that path may not exist. If the resource does not exist, the WebResource returned will be associated with the main WebResourceSet. This will include all matches even if the resource would not normally be accessible (e.g. because it was overridden by another resource)- Parameters:
- path- The path for the resource of interest relative to the root of the web application. It must start with '/'.
- Returns:
- The objects that represents the resource at the given path
 
- 
getClassLoaderResourceObtain the object that represents the class loader resource at the given path. WEB-INF/classes is always searched prior to searching JAR files in WEB-INF/lib. The search order for JAR files will be consistent across subsequent calls to this method until the web application is reloaded. No guarantee is made as to what the search order for JAR files may be.- Parameters:
- path- The path of the class loader resource of interest relative to the the root of class loader resources for this web application.
- Returns:
- The object that represents the class loader resource at the given path
 
- 
getClassLoaderResourcesObtain the objects that represent the class loader resource at the given path. Note that the resource at that path may not exist. If the path does not exist, the WebResource returned will be associated with the main WebResourceSet. This will include all matches even if the resource would not normally be accessible (e.g. because it was overridden by another resource)- Parameters:
- path- The path for the class loader resource of interest relative to the root of the class loader resources for the web application. It must start with '/'.
- Returns:
- The objects that represents the class loader resources at the given path. There will always be at least one element although that element may represent a resource that is not present.
 
- 
listObtain the list of the names of all of the files and directories located in the specified directory.- Parameters:
- path- The path for the resource of interest relative to the root of the web application. It must start with '/'.
- Returns:
- The list of resources. If path does not refer to a directory then a zero length array will be returned.
 
- 
listWebAppPathsObtain the Set of the web applications pathnames of all of the files and directories located in the specified directory. Paths representing directories will end with a '/' character.- Parameters:
- path- The path for the resource of interest relative to the root of the web application. It must start with '/'.
- Returns:
- The Set of resources. If path does not refer to a directory then null will be returned.
 
- 
listResourcesObtain the list of all of the WebResources in the specified directory.- Parameters:
- path- The path for the resource of interest relative to the root of the web application. It must start with '/'.
- Returns:
- The list of resources. If path does not refer to a directory then a zero length array will be returned.
 
- 
mkdirCreate a new directory at the given path.- Parameters:
- path- The path for the new resource to create relative to the root of the web application. It must start with '/'.
- Returns:
- trueif the directory was created, otherwise- false
 
- 
writeCreate a new resource at the requested path using the provided InputStream.- Parameters:
- path- The path to be used for the new Resource. It is relative to the root of the web application and must start with '/'.
- is- The InputStream that will provide the content for the new Resource.
- overwrite- If- trueand the resource already exists it will be overwritten. If- falseand the resource already exists the write will fail.
- Returns:
- trueif and only if the new Resource is written
 
- 
createWebResourceSetvoid createWebResourceSet(WebResourceRoot.ResourceSetType type, String webAppMount, URL url, String internalPath) Creates a newWebResourceSetfor thisWebResourceRootbased on the provided parameters.- Parameters:
- type- The type of- WebResourceSetto create
- webAppMount- The path within the web application that the resources should be published at. It must start with '/'.
- url- The URL of the resource (must locate a JAR, file or directory)
- internalPath- The path within the resource where the content is to be found. It must start with '/'.
 
- 
createWebResourceSetvoid createWebResourceSet(WebResourceRoot.ResourceSetType type, String webAppMount, String base, String archivePath, String internalPath) Creates a newWebResourceSetfor thisWebResourceRootbased on the provided parameters.- Parameters:
- type- The type of- WebResourceSetto create
- webAppMount- The path within the web application that the resources should be published at. It must start with '/'.
- base- The location of the resources
- archivePath- The path within the resource to the archive where the content is to be found. If there is no archive then this should be- null.
- internalPath- The path within the archive (or the resource if the archivePath is- nullwhere the content is to be found. It must start with '/'.
 
- 
addPreResourcesAdds the provided WebResourceSet to this web application as a 'Pre' resource.- Parameters:
- webResourceSet- the resource set to use
 
- 
getPreResourcesWebResourceSet[] getPreResources()- Returns:
- the list of WebResourceSet configured to this web application as a 'Pre' resource.
 
- 
addJarResourcesAdds the provided WebResourceSet to this web application as a 'Jar' resource.- Parameters:
- webResourceSet- the resource set to use
 
- 
getJarResourcesWebResourceSet[] getJarResources()- Returns:
- the list of WebResourceSet configured to this web application as a 'Jar' resource.
 
- 
addPostResourcesAdds the provided WebResourceSet to this web application as a 'Post' resource.- Parameters:
- webResourceSet- the resource set to use
 
- 
getPostResourcesWebResourceSet[] getPostResources()- Returns:
- the list of WebResourceSet configured to this web application as a 'Post' resource.
 
- 
getContextContext getContext()- Returns:
- the web application this WebResourceRoot is associated with.
 
- 
setContextSet the web application this WebResourceRoot is associated with.- Parameters:
- context- the associated context
 
- 
setAllowLinkingvoid setAllowLinking(boolean allowLinking) Configure if this resources allow the use of symbolic links.- Parameters:
- allowLinking-- trueif symbolic links are allowed.
 
- 
getAllowLinkingboolean getAllowLinking()Determine if this resources allow the use of symbolic links.- Returns:
- trueif symbolic links are allowed
 
- 
setCachingAllowedvoid setCachingAllowed(boolean cachingAllowed) Set whether or not caching is permitted for this web application.- Parameters:
- cachingAllowed-- trueto enable caching, else- false
 
- 
isCachingAllowedboolean isCachingAllowed()- Returns:
- trueif caching is permitted for this web application.
 
- 
setCacheTtlvoid setCacheTtl(long ttl) Set the Time-To-Live (TTL) for cache entries.- Parameters:
- ttl- TTL in milliseconds
 
- 
getCacheTtllong getCacheTtl()Get the Time-To-Live (TTL) for cache entries.- Returns:
- TTL in milliseconds
 
- 
setCacheMaxSizevoid setCacheMaxSize(long cacheMaxSize) Set the maximum permitted size for the cache.- Parameters:
- cacheMaxSize- Maximum cache size in kilobytes
 
- 
getCacheMaxSizelong getCacheMaxSize()Get the maximum permitted size for the cache.- Returns:
- Maximum cache size in kilobytes
 
- 
setCacheObjectMaxSizevoid setCacheObjectMaxSize(int cacheObjectMaxSize) Set the maximum permitted size for a single object in the cache. Note that the maximum size in bytes may not exceedInteger.MAX_VALUE.- Parameters:
- cacheObjectMaxSize- Maximum size for a single cached object in kilobytes
 
- 
getCacheObjectMaxSizeint getCacheObjectMaxSize()Get the maximum permitted size for a single object in the cache. Note that the maximum size in bytes may not exceedInteger.MAX_VALUE.- Returns:
- Maximum size for a single cached object in kilobytes
 
- 
setTrackLockedFilesvoid setTrackLockedFiles(boolean trackLockedFiles) Controls whether the track locked files feature is enabled. If enabled, all calls to methods that return objects that lock a file and need to be closed to release that lock (e.g.WebResource.getInputStream()will perform a number of additional tasks.- The stack trace at the point where the method was called will be recorded and associated with the returned object.
- The returned object will be wrapped so that the point where close() (or equivalent) is called to release the resources can be detected. Tracking of the object will cease once the resources have been released.
- All remaining locked resources on web application shutdown will be logged and then closed.
 - Parameters:
- trackLockedFiles-- trueto enable it,- falseto disable it
 
- 
getTrackLockedFilesboolean getTrackLockedFiles()Has the track locked files feature been enabled?- Returns:
- trueif it has been enabled, otherwise- false
 
- 
setArchiveIndexStrategySet the strategy to use for the resources archive lookup.- Parameters:
- archiveIndexStrategy- The strategy to use for the resources archive lookup
 
- 
getArchiveIndexStrategyString getArchiveIndexStrategy()Get the strategy to use for the resources archive lookup.- Returns:
- The strategy to use for the resources archive lookup
 
- 
getArchiveIndexStrategyEnumWebResourceRoot.ArchiveIndexStrategy getArchiveIndexStrategyEnum()Get the strategy to use for the resources archive lookup.- Returns:
- The strategy to use for the resources archive lookup
 
- 
backgroundProcessvoid backgroundProcess()This method will be invoked by the context on a periodic basis and allows the implementation a method that executes periodic tasks, such as purging expired cache entries.
- 
registerTrackedResourceAdd a specified resource to track to be able to later release resources on stop.- Parameters:
- trackedResource- the resource that will be tracked
 
- 
deregisterTrackedResourceStop tracking specified resource, once it no longer needs to free resources.- Parameters:
- trackedResource- the resource that was tracked
 
- 
getBaseUrls- Returns:
- the set of WebResourceSet.getBaseUrl()for allWebResourceSets used by this root.
 
- 
gcvoid gc()Implementations may cache some information to improve performance. This method triggers the clean-up of those resources.
- 
getCacheStrategyObtain the current caching strategy.The default implementation returns null. Sub-classes wishing to utilise aWebResourceRoot.CacheStrategyshould provide an appropriate implementation.- Returns:
- the current caching strategy or nullif no strategy has been configured
 
- 
setCacheStrategySet the current caching strategy.The default implementation is a NO-OP. Sub-classes wishing to utilise a WebResourceRoot.CacheStrategyshould provide an appropriate implementation.- Parameters:
- strategy- The new strategy to use or- nullfor no strategy
 
 
-