Top Description Inners Fields Constructors Methods
org.apache.catalina.webresources

public Class StandardRoot

extends LifecycleMBeanBase
implements WebResourceRoot
Class Inheritance
All Implemented Interfaces
org.apache.catalina.WebResourceRoot, org.apache.catalina.Lifecycle
Known Direct Subclasses
org.apache.catalina.webresources.ExtractingRoot
Imports
java.io.File, .IOException, .InputStream, java.net.URI, .URISyntaxException, .URL, java.util.ArrayList, .Arrays, .HashSet, .LinkedHashSet, .List, .Locale, .Set, java.util.concurrent.ConcurrentHashMap, javax.management.ObjectName, org.apache.catalina.Context, .Host, .LifecycleException, .LifecycleState, .TrackedWebResource, .WebResource, .WebResourceRoot, .WebResourceSet, org.apache.catalina.util.LifecycleMBeanBase, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.util.buf.UriUtil, org.apache.tomcat.util.compat.JreCompat, org.apache.tomcat.util.http.RequestUtil, org.apache.tomcat.util.res.StringManager

Provides the resources implementation for a web application. The org.apache.catalina.Lifecycle of this class should be aligned with that of the associated Context.

This implementation assumes that the base attribute supplied to StandardRoot#createWebResourceSet(org.apache.catalina.WebResourceRoot.ResourceSetType, String, String, String, String) represents the absolute path to a file.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private boolean
private final List<List<WebResourceSet>>
private WebResourceRoot.ArchiveIndexStrategy
private final Cache
private ObjectName
private boolean
private final List<WebResourceSet>
private Context
private final List<WebResourceSet>
private static final Log
private WebResourceSet
private final List<WebResourceSet>
private final List<WebResourceSet>
private final List<WebResourceSet>
protected static final StringManager
private final Set<TrackedWebResource>
private boolean

Constructor Summary

AccessConstructor and Description
public
StandardRoot()

Creates a new standard implementation of WebResourceRoot.

public

Method Summary

Modifier and TypeMethod and Description
protected void
public void
addJarResources(WebResourceSet
the resource set to use
webResourceSet
)

Implements org.apache.catalina.WebResourceRoot.addJarResources.

Adds the provided WebResourceSet to this web application as a 'Jar' resource.

public void
addPostResources(WebResourceSet
the resource set to use
webResourceSet
)

Implements org.apache.catalina.WebResourceRoot.addPostResources.

Adds the provided WebResourceSet to this web application as a 'Post' resource.

public void
addPreResources(WebResourceSet
the resource set to use
webResourceSet
)

Implements org.apache.catalina.WebResourceRoot.addPreResources.

Adds the provided WebResourceSet to this web application as a 'Pre' resource.

public void
backgroundProcess()

Implements org.apache.catalina.WebResourceRoot.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.

protected WebResourceSet
public void
createWebResourceSet(WebResourceRoot.ResourceSetType
The type of WebResourceSet to create
type
,
String
The path within the web application that the resources should be published at. It must start with '/'.
webAppMount
,
URL
The URL of the resource (must locate a JAR, file or directory)
url
,
String
The path within the resource where the content is to be found. It must start with '/'.
internalPath
)

Implements org.apache.catalina.WebResourceRoot.createWebResourceSet.

Creates a new WebResourceSet for this WebResourceRoot based on the provided parameters.

public void
createWebResourceSet(WebResourceRoot.ResourceSetType
The type of WebResourceSet to create
type
,
String
The path within the web application that the resources should be published at. It must start with '/'.
webAppMount
,
String
The location of the resources
base
,
String
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.
archivePath
,
String
The path within the archive (or the resource if the archivePath is null where the content is to be found. It must start with '/'.
internalPath
)

Implements org.apache.catalina.WebResourceRoot.createWebResourceSet.

Creates a new WebResourceSet for this WebResourceRoot based on the provided parameters.

public void
deregisterTrackedResource(TrackedWebResource
the resource that was tracked
trackedResource
)

Implements org.apache.catalina.WebResourceRoot.deregisterTrackedResource.

Stop tracking specified resource, once it no longer needs to free resources.

protected void
destroyInternal()

Overrides org.apache.catalina.util.LifecycleMBeanBase.destroyInternal.

Sub-classes wishing to perform additional clean-up should override this method, ensuring that super.destroyInternal() is the last call in the overriding method.

public void
gc()

Implements org.apache.catalina.WebResourceRoot.gc.

Implementations may cache some information to improve performance.

public boolean
getAllowLinking()

Implements org.apache.catalina.WebResourceRoot.getAllowLinking.

Determine if this resources allow the use of symbolic links.

public String
getArchiveIndexStrategy()

Implements org.apache.catalina.WebResourceRoot.getArchiveIndexStrategy.

Get the strategy to use for the resources archive lookup.

public WebResourceRoot.ArchiveIndexStrategy
getArchiveIndexStrategyEnum()

Implements org.apache.catalina.WebResourceRoot.getArchiveIndexStrategyEnum.

Get the strategy to use for the resources archive lookup.

public List<URL>
public long
getCacheMaxSize()

Implements org.apache.catalina.WebResourceRoot.getCacheMaxSize.

Get the maximum permitted size for the cache.

public int
getCacheObjectMaxSize()

Implements org.apache.catalina.WebResourceRoot.getCacheObjectMaxSize.

Get the maximum permitted size for a single object in the cache.

public WebResourceRoot.CacheStrategy
getCacheStrategy()

Overrides default org.apache.catalina.WebResourceRoot.getCacheStrategy.

Obtain the current caching strategy.

public long
getCacheTtl()

Implements org.apache.catalina.WebResourceRoot.getCacheTtl.

Get the Time-To-Live (TTL) for cache entries.

public WebResource
getClassLoaderResource(String
The path of the class loader resource of interest relative to the the root of class loader resources for this web application.
path
)

Implements org.apache.catalina.WebResourceRoot.getClassLoaderResource.

Obtain the object that represents the class loader resource at the given path.

public WebResource[]
getClassLoaderResources(String
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 '/'.
path
)

Implements org.apache.catalina.WebResourceRoot.getClassLoaderResources.

Obtain the objects that represent the class loader resource at the given path.

protected WebResourceSet[]
public Context
protected String
getDomainInternal()

Implements abstract org.apache.catalina.util.LifecycleMBeanBase.getDomainInternal.

Method implemented by sub-classes to identify the domain in which MBeans should be registered.

public WebResourceSet[]
protected String
getObjectNameKeyProperties()

Implements abstract org.apache.catalina.util.LifecycleMBeanBase.getObjectNameKeyProperties.

Allow sub-classes to specify the key properties component of the ObjectName that will be used to register this component.

public WebResourceSet[]
public WebResourceSet[]
public WebResource
getResource(String
The path for the resource of interest relative to the root of the web application. It must start with '/'.
path
)

Implements org.apache.catalina.WebResourceRoot.getResource.

Obtain the object that represents the resource at the given path.

protected WebResource
getResource(String path, boolean validate, boolean useClassLoaderResources)

protected final WebResource
getResourceInternal(String path, boolean useClassLoaderResources)

public WebResource[]
getResources(String
The path for the resource of interest relative to the root of the web application. It must start with '/'.
path
)

Implements org.apache.catalina.WebResourceRoot.getResources.

Obtain the objects that represent the resource at the given path.

private WebResource[]
getResources(String path, boolean useClassLoaderResources)

protected WebResource[]
getResourcesInternal(String path, boolean useClassLoaderResources)

public List<String>
public boolean
getTrackLockedFiles()

Implements org.apache.catalina.WebResourceRoot.getTrackLockedFiles.

Has the track locked files feature been enabled?

protected void
initInternal()

Overrides org.apache.catalina.util.LifecycleMBeanBase.initInternal.

Sub-classes wishing to perform additional initialization should override this method, ensuring that super.initInternal() is the first call in the overriding method.

public boolean
protected boolean
public String[]
list(String
The path for the resource of interest relative to the root of the web application. It must start with '/'.
path
)

Implements org.apache.catalina.WebResourceRoot.list.

Obtain the list of the names of all of the files and directories located in the specified directory.

private String[]
list(String path, boolean validate)

public WebResource[]
listResources(String
The path for the resource of interest relative to the root of the web application. It must start with '/'.
path
)

Implements org.apache.catalina.WebResourceRoot.listResources.

Obtain the list of all of the WebResources in the specified directory.

protected WebResource[]
listResources(String path, boolean validate)

public Set<String>
listWebAppPaths(String
The path for the resource of interest relative to the root of the web application. It must start with '/'.
path
)

Implements org.apache.catalina.WebResourceRoot.listWebAppPaths.

Obtain the Set of the web applications pathnames of all of the files and directories located in the specified directory.

public boolean
mkdir(String
The path for the new resource to create relative to the root of the web application. It must start with '/'.
path
)

Implements org.apache.catalina.WebResourceRoot.mkdir.

Create a new directory at the given path.

private boolean
protected void
processWebInfLib()

Class loader resources are handled by treating JARs in WEB-INF/lib as resource JARs (without the internal META-INF/resources/ prefix) mounted at WEB-INF/classes (rather than the web app root).

public void
registerTrackedResource(TrackedWebResource
the resource that will be tracked
trackedResource
)

Implements org.apache.catalina.WebResourceRoot.registerTrackedResource.

Add a specified resource to track to be able to later release resources on stop.

protected void
public void
setAllowLinking(boolean
true if symbolic links are allowed.
allowLinking
)

Implements org.apache.catalina.WebResourceRoot.setAllowLinking.

Configure if this resources allow the use of symbolic links.

public void
setArchiveIndexStrategy(String
The strategy to use for the resources archive lookup
archiveIndexStrategy
)

Implements org.apache.catalina.WebResourceRoot.setArchiveIndexStrategy.

Set the strategy to use for the resources archive lookup.

public void
setCacheMaxSize(long
Maximum cache size in kilobytes
cacheMaxSize
)

Implements org.apache.catalina.WebResourceRoot.setCacheMaxSize.

Set the maximum permitted size for the cache.

public void
setCacheObjectMaxSize(int
Maximum size for a single cached object in kilobytes
cacheObjectMaxSize
)

Implements org.apache.catalina.WebResourceRoot.setCacheObjectMaxSize.

Set the maximum permitted size for a single object in the cache.

public void
setCacheStrategy(WebResourceRoot.CacheStrategy
The new strategy to use or null for no strategy
strategy
)

Overrides default org.apache.catalina.WebResourceRoot.setCacheStrategy.

Set the current caching strategy.

public void
setCacheTtl(long
TTL in milliseconds
cacheTtl
)

Implements org.apache.catalina.WebResourceRoot.setCacheTtl.

Set the Time-To-Live (TTL) for cache entries.

public void
setCachingAllowed(boolean
true to enable caching, else false
cachingAllowed
)

Implements org.apache.catalina.WebResourceRoot.setCachingAllowed.

Set whether or not caching is permitted for this web application.

public void
setContext(Context
the associated context
context
)

Implements org.apache.catalina.WebResourceRoot.setContext.

Set the web application this WebResourceRoot is associated with.

protected final void
setMainResources(WebResourceSet
The main resources
main
)

For unit testing.

public void
setTrackLockedFiles(boolean
true to enable it, false to disable it
trackLockedFiles
)

Implements org.apache.catalina.WebResourceRoot.setTrackLockedFiles.

Controls whether the track locked files feature is enabled.

protected void
startInternal()

Implements abstract org.apache.catalina.util.LifecycleBase.startInternal.

Sub-classes must ensure that the state is changed to LifecycleState#STARTING during the execution of this method.

protected void
stopInternal()

Implements abstract org.apache.catalina.util.LifecycleBase.stopInternal.

Sub-classes must ensure that the state is changed to LifecycleState#STOPPING during the execution of this method.

private String

Returns:

the normalized path
validate
(String
The path to validate
path
)

Ensures that this object is in a valid state to serve resources, checks that the path is a String that starts with '/' and checks that the path can be normalized without stepping outside of the root.

public boolean
write(String
The path to be used for the new Resource. It is relative to the root of the web application and must start with '/'.
path
,
InputStream
The InputStream that will provide the content for the new Resource.
is
,
boolean
If true and the resource already exists it will be overwritten. If false and the resource already exists the write will fail.
overwrite
)

Implements org.apache.catalina.WebResourceRoot.write.

Create a new resource at the requested path using the provided InputStream.

Inherited from org.apache.catalina.util.LifecycleMBeanBase:
getDomaingetObjectNamepostDeregisterpostRegisterpreDeregisterpreRegisterregistersetDomainunregisterunregister