Class CachedResource
- java.lang.Object
-
- io.undertow.server.handlers.resource.CachedResource
-
- All Implemented Interfaces:
RangeAwareResource,Resource
public class CachedResource extends Object implements Resource, RangeAwareResource
- Author:
- Stuart Douglas
-
-
Constructor Summary
Constructors Constructor Description CachedResource(CachingResourceManager cachingResourceManager, Resource underlyingResource, String path)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheckStillValid()StringgetCacheKey()LonggetContentLength()StringgetContentType(MimeMappings mimeMappings)Return the resources content type.ETaggetETag()FilegetFile()PathgetFilePath()DategetLastModified()StringgetLastModifiedString()StringgetName()StringgetPath()FilegetResourceManagerRoot()Returns the resource manager root.PathgetResourceManagerRootPath()Returns the resource manager root.URLgetUrl()voidinvalidate()booleanisDirectory()booleanisRangeSupported()It is possible that some resources managers may only support range requests on a subset of their resources,List<Resource>list()voidserve(Sender sender, HttpServerExchange exchange, IoCallback completionCallback)Serve the resource, and call the provided callback when complete.voidserveRange(Sender sender, HttpServerExchange exchange, long start, long end, IoCallback completionCallback)Serve the resource, and call the provided callback when complete.
-
-
-
Constructor Detail
-
CachedResource
public CachedResource(CachingResourceManager cachingResourceManager, Resource underlyingResource, String path)
-
-
Method Detail
-
getPath
public String getPath()
-
getLastModified
public Date getLastModified()
- Specified by:
getLastModifiedin interfaceResource- Returns:
- The last modified date of this resource, or null if this cannot be determined
-
getLastModifiedString
public String getLastModifiedString()
- Specified by:
getLastModifiedStringin interfaceResource- Returns:
- A string representation of the last modified date, or null if this cannot be determined
-
getETag
public ETag getETag()
-
getName
public String getName()
-
isDirectory
public boolean isDirectory()
- Specified by:
isDirectoryin interfaceResource- Returns:
trueif this resource represents a directory
-
getContentType
public String getContentType(MimeMappings mimeMappings)
Description copied from interface:ResourceReturn the resources content type. In most cases this will simply use the provided mime mappings, however in some cases the resource may have additional information as to the actual content type.- Specified by:
getContentTypein interfaceResource
-
invalidate
public void invalidate()
-
checkStillValid
public boolean checkStillValid()
-
serve
public void serve(Sender sender, HttpServerExchange exchange, IoCallback completionCallback)
Description copied from interface:ResourceServe the resource, and call the provided callback when complete.
-
getContentLength
public Long getContentLength()
- Specified by:
getContentLengthin interfaceResource- Returns:
- The content length, or null if it is unknown
-
getCacheKey
public String getCacheKey()
- Specified by:
getCacheKeyin interfaceResource- Returns:
- A string that uniquely identifies this resource
-
getFile
public File getFile()
-
getFilePath
public Path getFilePath()
- Specified by:
getFilePathin interfaceResource- Returns:
- The underlying file that matches the resource. This may return null if the resource does not map to a file
-
getResourceManagerRoot
public File getResourceManagerRoot()
Description copied from interface:ResourceReturns the resource manager root. If the resource manager has multiple roots then this returns the one that is the parent of this resource.- Specified by:
getResourceManagerRootin interfaceResource- Returns:
- a file representing the resource manager root. This may return null if the resource does not map to a file
-
getResourceManagerRootPath
public Path getResourceManagerRootPath()
Description copied from interface:ResourceReturns the resource manager root. If the resource manager has multiple roots then this returns the one that is the parent of this resource.- Specified by:
getResourceManagerRootPathin interfaceResource- Returns:
- a path representing the resource manager root. This may return null if the resource does not map to a file
-
getUrl
public URL getUrl()
-
serveRange
public void serveRange(Sender sender, HttpServerExchange exchange, long start, long end, IoCallback completionCallback)
Description copied from interface:RangeAwareResourceServe the resource, and call the provided callback when complete.- Specified by:
serveRangein interfaceRangeAwareResource- Parameters:
sender- The sender to use.exchange- The exchange
-
isRangeSupported
public boolean isRangeSupported()
Description copied from interface:RangeAwareResourceIt is possible that some resources managers may only support range requests on a subset of their resources,- Specified by:
isRangeSupportedin interfaceRangeAwareResource- Returns:
trueif this resource supports range requests
-
-