Class CachedResource
java.lang.Object
org.apache.catalina.webresources.CachedResource
- All Implemented Interfaces:
WebResource
This class is designed to wrap a 'raw' WebResource and providing caching for expensive operations. Inexpensive
operations may be passed through to the underlying resource.
-
Constructor Summary
ConstructorsConstructorDescriptionCachedResource(Cache cache, StandardRoot root, String path, long ttl, int objectMaxSizeBytes, boolean usesClassLoaderResources) -
Method Summary
Modifier and TypeMethodDescriptionbooleancanRead()Checks if this resource can be read.booleandelete()Deletes this resource.booleanexists()Checks if this resource exists.Returns the canonical path of this resource.Returns the certificates that were used to sign this resource to verify it.Returns the code base for this resource.byte[]Returns the binary content of this resource.longReturns the content length of this resource.longReturns the creation time of this resource.getETag()Returns the weak ETag calculated from the content length and last modified.Obtains an InputStream based on the contents of this resource.longReturns the last modified time.Returns the last modified time in HTTP format.Returns the manifest associated with this resource.Returns the MIME type for this Resource.getName()Returns the name of this resource.protected longReturn the strong ETag if available else return the weak ETag calculated from the content length and last modified.getURL()Returns a URL to access this resource.Returns the webapp path of this resource.Returns a reference to the WebResourceRoot of which this WebResource is a part.booleanChecks if this resource is a directory.booleanisFile()Checks if this resource is a file.booleanIndicates if this resource is required for applications to correctly scan the file structure but that does not exist in either the main or any additionalWebResourceSet.voidsetMimeType(String mimeType) Set the MIME type for this Resource.protected booleanvalidateResource(boolean useClassLoaderResources) protected booleanvalidateResources(boolean useClassLoaderResources)
-
Constructor Details
-
CachedResource
public CachedResource(Cache cache, StandardRoot root, String path, long ttl, int objectMaxSizeBytes, boolean usesClassLoaderResources)
-
-
Method Details
-
validateResource
protected boolean validateResource(boolean useClassLoaderResources) -
validateResources
protected boolean validateResources(boolean useClassLoaderResources) -
getNextCheck
protected long getNextCheck() -
getLastModified
public long getLastModified()Description copied from interface:WebResourceReturns the last modified time.- Specified by:
getLastModifiedin interfaceWebResource- Returns:
File.lastModified().
-
getLastModifiedHttp
Description copied from interface:WebResourceReturns the last modified time in HTTP format.- Specified by:
getLastModifiedHttpin interfaceWebResource- Returns:
- the last modified time of this resource in the correct format for the HTTP Last-Modified header as specified by RFC 2616.
-
exists
public boolean exists()Description copied from interface:WebResourceChecks if this resource exists.- Specified by:
existsin interfaceWebResource- Returns:
File.exists().
-
isVirtual
public boolean isVirtual()Description copied from interface:WebResourceIndicates if this resource is required for applications to correctly scan the file structure but that does not exist in either the main or any additionalWebResourceSet. For example, if an external directory is mapped to /WEB-INF/lib in an otherwise empty web application, /WEB-INF will be represented as a virtual resource.- Specified by:
isVirtualin interfaceWebResource- Returns:
truefor a virtual resource
-
isDirectory
public boolean isDirectory()Description copied from interface:WebResourceChecks if this resource is a directory.- Specified by:
isDirectoryin interfaceWebResource- Returns:
File.isDirectory().
-
isFile
public boolean isFile()Description copied from interface:WebResourceChecks if this resource is a file.- Specified by:
isFilein interfaceWebResource- Returns:
File.isFile().
-
delete
public boolean delete()Description copied from interface:WebResourceDeletes this resource.- Specified by:
deletein interfaceWebResource- Returns:
File.delete().
-
getName
Description copied from interface:WebResourceReturns the name of this resource.- Specified by:
getNamein interfaceWebResource- Returns:
File.getName().
-
getContentLength
public long getContentLength()Description copied from interface:WebResourceReturns the content length of this resource.- Specified by:
getContentLengthin interfaceWebResource- Returns:
File.length().
-
getCanonicalPath
Description copied from interface:WebResourceReturns the canonical path of this resource.- Specified by:
getCanonicalPathin interfaceWebResource- Returns:
File.getCanonicalPath().
-
canRead
public boolean canRead()Description copied from interface:WebResourceChecks if this resource can be read.- Specified by:
canReadin interfaceWebResource- Returns:
File.canRead().
-
getWebappPath
Description copied from interface:WebResourceReturns the webapp path of this resource.- Specified by:
getWebappPathin interfaceWebResource- Returns:
- The path of this resource relative to the web application root. If the resource is a directory, the return value will end in '/'.
-
getETag
Description copied from interface:WebResourceReturns the weak ETag calculated from the content length and last modified.- Specified by:
getETagin interfaceWebResource- Returns:
- The ETag for this resource
-
getStrongETag
Description copied from interface:WebResourceReturn the strong ETag if available else return the weak ETag calculated from the content length and last modified.- Specified by:
getStrongETagin interfaceWebResource- Returns:
- The ETag for this resource
-
setMimeType
Description copied from interface:WebResourceSet the MIME type for this Resource.- Specified by:
setMimeTypein interfaceWebResource- Parameters:
mimeType- The mime type that will be associated with the resource
-
getMimeType
Description copied from interface:WebResourceReturns the MIME type for this Resource.- Specified by:
getMimeTypein interfaceWebResource- Returns:
- the MIME type for this Resource.
-
getInputStream
Description copied from interface:WebResourceObtains an InputStream based on the contents of this resource.- Specified by:
getInputStreamin interfaceWebResource- Returns:
- An InputStream based on the contents of this resource or
nullif the resource does not exist or does not represent a file
-
getContent
public byte[] getContent()Description copied from interface:WebResourceReturns the binary content of this resource.- Specified by:
getContentin interfaceWebResource- Returns:
- the binary content of this resource or
nullif it is not available in a byte[] because, for example, it is too big.
-
getCreation
public long getCreation()Description copied from interface:WebResourceReturns the creation time of this resource.- Specified by:
getCreationin interfaceWebResource- Returns:
- The time the file was created. If not available, the result of
WebResource.getLastModified()will be returned.
-
getURL
Description copied from interface:WebResourceReturns a URL to access this resource.- Specified by:
getURLin interfaceWebResource- Returns:
- a URL to access the resource or
nullif no such URL is available or if the resource does not exist.
-
getCodeBase
Description copied from interface:WebResourceReturns the code base for this resource.The expectation is that this will be deprecated and then removed once the SecurityManager has been fully removed from the JRE, and it has been confirmed that the JRE no longer depends on code base.
- Specified by:
getCodeBasein interfaceWebResource- Returns:
- the code base for this resource that will be used when looking up the assigned permissions for the code base in the security policy file when running under a security manager.
-
getCertificates
Description copied from interface:WebResourceReturns the certificates that were used to sign this resource to verify it.- Specified by:
getCertificatesin interfaceWebResource- Returns:
- the certificates that were used to sign this resource to verify it or @null if none.
- See Also:
-
getManifest
Description copied from interface:WebResourceReturns the manifest associated with this resource.- Specified by:
getManifestin interfaceWebResource- Returns:
- the manifest associated with this resource or @null if none.
- See Also:
-
getWebResourceRoot
Description copied from interface:WebResourceReturns a reference to the WebResourceRoot of which this WebResource is a part.- Specified by:
getWebResourceRootin interfaceWebResource- Returns:
- a reference to the WebResourceRoot of which this WebResource is a part.
-