Top Description Inners Fields Constructors Methods
org.eclipse.jetty.http.content

public Class ValidatingCachingHttpContentFactory

extends CachingHttpContentFactory
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Imports
java.util.Map, .Objects, java.util.concurrent.ConcurrentMap, .TimeUnit, java.util.concurrent.atomic.AtomicLong, org.eclipse.jetty.io.ByteBufferPool, org.eclipse.jetty.util.NanoTime, org.eclipse.jetty.util.annotation.Name, org.eclipse.jetty.util.thread.Scheduler

HttpContent.Factory implementation of CachingHttpContentFactory which evicts invalid entries from the cache. Uses a validationTime parameter to check files when they are accessed and/or sweepDelay parameter for a periodic sweep for invalid entries in the cache.

HttpContent validation checks are configured through the validationTime parameter in the constructor. If an HttpContent is found to be invalid it will be removed from the cache. A value of -1 means that the cached HttpContent will never be checked if it is still valid, a value of 0 means it is checked on every request, a positive value indicates the number of milliseconds of the minimum time between validation checks.

This also remember a missed entry for the time set by validationTimems. After this has elapsed the entry will be invalid and will be evicted from the cache at the next access.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
protected static class

Field Summary

Modifier and TypeField and Description
private final long
private final Scheduler
private final long
private final long

Constructor Summary

AccessConstructor and Description
public
ValidatingCachingHttpContentFactory(HttpContent.Factory
the wrapped HttpContent.Factory to use.
authority
,
long
time between filesystem checks in ms to see if an HttpContent is still valid (-1 never validate, 0 always validate).
validationPeriod
,
ByteBufferPool bufferPool)

Construct a ValidatingCachingHttpContentFactory which validates entries upon use to check if they are still valid.

public
ValidatingCachingHttpContentFactory(HttpContent.Factory
the wrapped HttpContent.Factory to use.
authority
,
long
time between filesystem checks in ms to see if an HttpContent is still valid (-1 never validate, 0 always validate).
validationPeriod
,
ByteBufferPool bufferPool, Scheduler
scheduler to use for the sweeper, can be null to not use sweeper.
scheduler
,
long
time between runs of the sweeper in ms (if 0 never sweep for invalid entries).
sweepPeriod
,
long
amount of time in ms an entry can be unused before evicted by the sweeper (if 0 never evict unused entries).
idleTimeout
)

Construct a ValidatingCachingHttpContentFactory which validates entries upon use to check if they are still valid and an optional period sweeper of the cache to find invalid and old entries to evict.

Method Summary

Modifier and TypeMethod and Description
protected boolean
isCacheable(HttpContent
the HttpContent to test.
httpContent
)

Overrides org.eclipse.jetty.http.content.CachingHttpContentFactory.isCacheable.

Tests whether the given HttpContent is cacheable, and if there is enough room to fit it in the cache.

protected CachingHttpContentFactory.CachingHttpContent
protected CachingHttpContentFactory.CachingHttpContent
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

private void
Inherited from org.eclipse.jetty.http.content.CachingHttpContentFactory:
flushCachegetCachegetCachedFilesgetCachedSizegetContentgetMaxCachedFilesgetMaxCachedFileSizegetMaxCacheSizeisUseDirectByteBuffersremoveFromCachesetMaxCachedFilessetMaxCachedFileSizesetMaxCacheSizesetUseDirectByteBuffers

Field Detail

_maxCacheIdleTimeback to summary
private final long _maxCacheIdleTime
_schedulerback to summary
private final Scheduler _scheduler
_sweepDelayback to summary
private final long _sweepDelay
_validationTimeback to summary
private final long _validationTime

Constructor Detail

ValidatingCachingHttpContentFactoryback to summary
public ValidatingCachingHttpContentFactory(HttpContent.Factory authority, long validationPeriod, ByteBufferPool bufferPool)

Construct a ValidatingCachingHttpContentFactory which validates entries upon use to check if they are still valid.

Parameters
authority:HttpContent.Factory

the wrapped HttpContent.Factory to use.

validationPeriod:long

time between filesystem checks in ms to see if an HttpContent is still valid (-1 never validate, 0 always validate).

bufferPool:ByteBufferPool

the org.eclipse.jetty.io.ByteBufferPool to use.

ValidatingCachingHttpContentFactoryback to summary
public ValidatingCachingHttpContentFactory(HttpContent.Factory authority, long validationPeriod, ByteBufferPool bufferPool, Scheduler scheduler, long sweepPeriod, long idleTimeout)

Construct a ValidatingCachingHttpContentFactory which validates entries upon use to check if they are still valid and an optional period sweeper of the cache to find invalid and old entries to evict.

Parameters
authority:HttpContent.Factory

the wrapped HttpContent.Factory to use.

validationPeriod:long

time between filesystem checks in ms to see if an HttpContent is still valid (-1 never validate, 0 always validate).

bufferPool:ByteBufferPool

the org.eclipse.jetty.io.ByteBufferPool to use.

scheduler:Scheduler

scheduler to use for the sweeper, can be null to not use sweeper.

sweepPeriod:long

time between runs of the sweeper in ms (if 0 never sweep for invalid entries).

idleTimeout:long

amount of time in ms an entry can be unused before evicted by the sweeper (if 0 never evict unused entries).

Method Detail

isCacheableback to summary
protected boolean isCacheable(HttpContent httpContent)

Overrides org.eclipse.jetty.http.content.CachingHttpContentFactory.isCacheable.

Doc from org.eclipse.jetty.http.content.CachingHttpContentFactory.isCacheable.

Tests whether the given HttpContent is cacheable, and if there is enough room to fit it in the cache.

Parameters
httpContent:HttpContent

the HttpContent to test.

Returns:boolean

whether the HttpContent is cacheable.

Annotations
@Override
newCachedContentback to summary
protected CachingHttpContentFactory.CachingHttpContent newCachedContent(String p, HttpContent httpContent)

Overrides org.eclipse.jetty.http.content.CachingHttpContentFactory.newCachedContent.

Annotations
@Override
newNotFoundContentback to summary
protected CachingHttpContentFactory.CachingHttpContent newNotFoundContent(String p)

Overrides org.eclipse.jetty.http.content.CachingHttpContentFactory.newNotFoundContent.

Annotations
@Override
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
scheduleback to summary
private void schedule()
org.eclipse.jetty.http.content back to summary

protected Class ValidatingCachingHttpContentFactory.ValidatingCachedContent

extends CachedHttpContent
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final AtomicLong
private final long

Constructor Summary

AccessConstructor and Description
public
ValidatingCachedContent(String key, HttpContent httpContent, long validationTime)

Method Summary

Modifier and TypeMethod and Description
public boolean
Inherited from org.eclipse.jetty.http.content.CachingHttpContentFactory.CachedHttpContent:
getByteBuffergetBytesOccupiedgetCharacterEncodinggetContentLengthgetContentLengthValuegetETaggetETagValuegetKeygetLastAccessedNanosgetLastModifiedgetLastModifiedInstantgetLastModifiedValuegetMimeTypegetPreCompressedContentFormatsreleaseretainsetLastAccessedNanos

Field Detail

_lastValidatedback to summary
private final AtomicLong _lastValidated
_validationTimeback to summary
private final long _validationTime

Constructor Detail

ValidatingCachedContentback to summary
public ValidatingCachedContent(String key, HttpContent httpContent, long validationTime)

Method Detail

isValidback to summary
public boolean isValid()

Overrides org.eclipse.jetty.http.content.CachingHttpContentFactory.CachedHttpContent.isValid.

Implements org.eclipse.jetty.http.content.CachingHttpContentFactory.CachingHttpContent.isValid.

Annotations
@Override
org.eclipse.jetty.http.content back to summary

protected Class ValidatingCachingHttpContentFactory.ValidatingNotFoundContent

extends NotFoundHttpContent
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final AtomicLong
private final long

Constructor Summary

AccessConstructor and Description
public
ValidatingNotFoundContent(String key, long validationTime)

Method Summary

Modifier and TypeMethod and Description
public boolean
Inherited from org.eclipse.jetty.http.content.CachingHttpContentFactory.NotFoundHttpContent:
getByteBuffergetCharacterEncodinggetContentEncodinggetContentEncodingValuegetContentLengthgetContentLengthValuegetContentTypegetContentTypeValuegetETaggetETagValuegetKeygetLastAccessedNanosgetLastModifiedgetLastModifiedInstantgetLastModifiedValuegetMimeTypegetPreCompressedContentFormatsgetResourcereleaseretainsetLastAccessedNanos

Field Detail

_lastValidatedback to summary
private final AtomicLong _lastValidated
_validationTimeback to summary
private final long _validationTime

Constructor Detail

ValidatingNotFoundContentback to summary
public ValidatingNotFoundContent(String key, long validationTime)

Method Detail

isValidback to summary
public boolean isValid()

Overrides org.eclipse.jetty.http.content.CachingHttpContentFactory.NotFoundHttpContent.isValid.

Implements org.eclipse.jetty.http.content.CachingHttpContentFactory.CachingHttpContent.isValid.

Annotations
@Override