Top Inners Fields Constructors Methods
io.undertow.server.handlers.resource

public Class CachedResource

extends Object
implements Resource, RangeAwareResource
Class Inheritance
All Implemented Interfaces
io.undertow.server.handlers.resource.RangeAwareResource, io.undertow.server.handlers.resource.Resource
Imports
java.io.File, .IOException, java.net.URL, java.nio.ByteBuffer, java.nio.file.Path, java.util.Date, .List, io.undertow.UndertowLogger, io.undertow.io.IoCallback, .Sender, io.undertow.server.HttpServerExchange, io.undertow.server.handlers.cache.DirectBufferCache, .LimitedBufferSlicePool, .ResponseCachingSender, io.undertow.util.DateUtils, .ETag, .MimeMappings

Author
Stuart Douglas

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
private static class

Field Summary

Modifier and TypeField and Description
private final CachedResource.CacheKey
private final CachingResourceManager
private final boolean
private final ETag
private final Date
private final String
private final String
private volatile long
private final Resource

Constructor Summary

AccessConstructor and Description
public
CachedResource(final CachingResourceManager cachingResourceManager, final Resource underlyingResource, final String path)

Method Summary

Modifier and TypeMethod and Description
public boolean
public String
public Long
public String
getContentType(final MimeMappings mimeMappings)

Implements io.undertow.server.handlers.resource.Resource.getContentType.

Return the resources content type.

public ETag
public File
public Path
public Date
public String
public String
public String
public File
public Path
public URL
public void
public boolean
public boolean
isRangeSupported()

Implements io.undertow.server.handlers.resource.RangeAwareResource.isRangeSupported.

It is possible that some resources managers may only support range requests on a subset of their resources,

public List<Resource>
public void
serve(final Sender
The sender to use.
sender
,
final HttpServerExchange
The exchange
exchange
,
final IoCallback completionCallback)

Implements io.undertow.server.handlers.resource.Resource.serve.

Serve the resource, and call the provided callback when complete.

public void
serveRange(Sender
The sender to use.
sender
,
HttpServerExchange
The exchange
exchange
,
long start, long end, IoCallback completionCallback)

Implements io.undertow.server.handlers.resource.RangeAwareResource.serveRange.

Serve the resource, and call the provided callback when complete.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheKeyback to summary
private final CachedResource.CacheKey cacheKey
cachingResourceManagerback to summary
private final CachingResourceManager cachingResourceManager
directoryback to summary
private final boolean directory
eTagback to summary
private final ETag eTag
lastModifiedDateback to summary
private final Date lastModifiedDate
lastModifiedDateStringback to summary
private final String lastModifiedDateString
nameback to summary
private final String name
nextMaxAgeCheckback to summary
private volatile long nextMaxAgeCheck
underlyingResourceback to summary
private final Resource underlyingResource

Constructor Detail

CachedResourceback to summary
public CachedResource(final CachingResourceManager cachingResourceManager, final Resource underlyingResource, final String path)

Method Detail

checkStillValidback to summary
public boolean checkStillValid()
getCacheKeyback to summary
public String getCacheKey()

Implements io.undertow.server.handlers.resource.Resource.getCacheKey.

Returns:String

Doc from io.undertow.server.handlers.resource.Resource.getCacheKey.

A string that uniquely identifies this resource

Annotations
@Override
getContentLengthback to summary
public Long getContentLength()

Implements io.undertow.server.handlers.resource.Resource.getContentLength.

Returns:Long

Doc from io.undertow.server.handlers.resource.Resource.getContentLength.

The content length, or null if it is unknown

Annotations
@Override
getContentTypeback to summary
public String getContentType(final MimeMappings mimeMappings)

Implements io.undertow.server.handlers.resource.Resource.getContentType.

Doc from io.undertow.server.handlers.resource.Resource.getContentType.

Return 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.

Annotations
@Override
getETagback to summary
public ETag getETag()

Implements io.undertow.server.handlers.resource.Resource.getETag.

Returns:ETag

Doc from io.undertow.server.handlers.resource.Resource.getETag.

The resources etags

Annotations
@Override
getFileback to summary
public File getFile()

Implements io.undertow.server.handlers.resource.Resource.getFile.

Returns:File

Doc from io.undertow.server.handlers.resource.Resource.getFile.

The underlying file that matches the resource. This may return null if the resource does not map to a file

Annotations
@Override
getFilePathback to summary
public Path getFilePath()

Implements io.undertow.server.handlers.resource.Resource.getFilePath.

Returns:Path

Doc from io.undertow.server.handlers.resource.Resource.getFilePath.

The underlying file that matches the resource. This may return null if the resource does not map to a file

Annotations
@Override
getLastModifiedback to summary
public Date getLastModified()

Implements io.undertow.server.handlers.resource.Resource.getLastModified.

Returns:Date

Doc from io.undertow.server.handlers.resource.Resource.getLastModified.

The last modified date of this resource, or null if this cannot be determined

Annotations
@Override
getLastModifiedStringback to summary
public String getLastModifiedString()

Implements io.undertow.server.handlers.resource.Resource.getLastModifiedString.

Returns:String

Doc from io.undertow.server.handlers.resource.Resource.getLastModifiedString.

A string representation of the last modified date, or null if this cannot be determined

Annotations
@Override
getNameback to summary
public String getName()

Implements io.undertow.server.handlers.resource.Resource.getName.

Returns:String

Doc from io.undertow.server.handlers.resource.Resource.getName.

The name of the resource

Annotations
@Override
getPathback to summary
public String getPath()

Implements io.undertow.server.handlers.resource.Resource.getPath.

Returns:String

Doc from io.undertow.server.handlers.resource.Resource.getPath.

The path from the resource manager root

Annotations
@Override
getResourceManagerRootback to summary
public File getResourceManagerRoot()

Implements io.undertow.server.handlers.resource.Resource.getResourceManagerRoot.

Doc from io.undertow.server.handlers.resource.Resource.getResourceManagerRoot.

Returns the resource manager root. If the resource manager has multiple roots then this returns the one that is the parent of this resource.

Returns:File

a file representing the resource manager root. This may return null if the resource does not map to a file

Annotations
@Override
getResourceManagerRootPathback to summary
public Path getResourceManagerRootPath()

Implements io.undertow.server.handlers.resource.Resource.getResourceManagerRootPath.

Doc from io.undertow.server.handlers.resource.Resource.getResourceManagerRootPath.

Returns the resource manager root. If the resource manager has multiple roots then this returns the one that is the parent of this resource.

Returns:Path

a path representing the resource manager root. This may return null if the resource does not map to a file

Annotations
@Override
getUrlback to summary
public URL getUrl()

Implements io.undertow.server.handlers.resource.Resource.getUrl.

Returns:URL

Doc from io.undertow.server.handlers.resource.Resource.getUrl.

The URL of the resource

Annotations
@Override
invalidateback to summary
public void invalidate()
isDirectoryback to summary
public boolean isDirectory()

Implements io.undertow.server.handlers.resource.Resource.isDirectory.

Returns:boolean

Doc from io.undertow.server.handlers.resource.Resource.isDirectory.

true if this resource represents a directory

Annotations
@Override
isRangeSupportedback to summary
public boolean isRangeSupported()

Implements io.undertow.server.handlers.resource.RangeAwareResource.isRangeSupported.

Doc from io.undertow.server.handlers.resource.RangeAwareResource.isRangeSupported.

It is possible that some resources managers may only support range requests on a subset of their resources,

Returns:boolean

true if this resource supports range requests

Annotations
@Override
listback to summary
public List<Resource> list()

Implements io.undertow.server.handlers.resource.Resource.list.

Returns:List<Resource>

Doc from io.undertow.server.handlers.resource.Resource.list.

a list of resources in this directory

Annotations
@Override
serveback to summary
public void serve(final Sender sender, final HttpServerExchange exchange, final IoCallback completionCallback)

Implements io.undertow.server.handlers.resource.Resource.serve.

Doc from io.undertow.server.handlers.resource.Resource.serve.

Serve the resource, and call the provided callback when complete.

Parameters
sender:Sender

The sender to use.

exchange:HttpServerExchange

The exchange

Annotations
@Override
serveRangeback to summary
public void serveRange(Sender sender, HttpServerExchange exchange, long start, long end, IoCallback completionCallback)

Implements io.undertow.server.handlers.resource.RangeAwareResource.serveRange.

Doc from io.undertow.server.handlers.resource.RangeAwareResource.serveRange.

Serve the resource, and call the provided callback when complete.

Parameters
sender:Sender

The sender to use.

exchange:HttpServerExchange

The exchange

Annotations
@Override
io.undertow.server.handlers.resource back to summary

pack-priv final Class CachedResource.CacheKey

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final String
pack-priv final CachingResourceManager

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheKeyback to summary
pack-priv final String cacheKey
managerback to summary
pack-priv final CachingResourceManager manager

Constructor Detail

CacheKeyback to summary
pack-priv CacheKey(CachingResourceManager manager, String cacheKey)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
io.undertow.server.handlers.resource back to summary

private Class CachedResource.DereferenceCallback

extends Object
implements IoCallback
Class Inheritance
  • java.lang.Object
  • io.undertow.server.handlers.resource.CachedResource.DereferenceCallback
All Implemented Interfaces
io.undertow.io.IoCallback

Field Summary

Modifier and TypeField and Description
private final IoCallback
private final DirectBufferCache.CacheEntry

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
public void
onException(final HttpServerExchange exchange, final Sender sender, final IOException exception)

Implements io.undertow.io.IoCallback.onException.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

callbackback to summary
private final IoCallback callback
entryback to summary
private final DirectBufferCache.CacheEntry entry

Constructor Detail

DereferenceCallbackback to summary
pack-priv DereferenceCallback(DirectBufferCache.CacheEntry entry, final IoCallback callback)

Method Detail

onCompleteback to summary
public void onComplete(final HttpServerExchange exchange, final Sender sender)

Implements io.undertow.io.IoCallback.onComplete.

Annotations
@Override
onExceptionback to summary
public void onException(final HttpServerExchange exchange, final Sender sender, final IOException exception)

Implements io.undertow.io.IoCallback.onException.

Annotations
@Override