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

public Class CachingResourceManager

extends Object
implements ResourceManager
Class Inheritance
All Implemented Interfaces
io.undertow.server.handlers.resource.ResourceManager, java.io.Closeable, java.lang.AutoCloseable
Imports
java.io.IOException, java.util.Collection, .Set, io.undertow.UndertowLogger, io.undertow.server.handlers.cache.DirectBufferCache, .LRUCache

Author
Stuart Douglas

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final LRUCache<String, Object>
cache

A cache of file metadata, such as if a file exists or not

private final DirectBufferCache
dataCache

A cache of byte buffers

private final int
private final long
maxFileSize

The biggest file size we cache

private final ResourceManager
underlyingResourceManager

The underlying resource manager

Constructor Summary

AccessConstructor and Description
public
CachingResourceManager(final int metadataCacheSize, final long maxFileSize, final DirectBufferCache dataCache, final ResourceManager underlyingResourceManager, final int maxAge)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.

pack-priv DirectBufferCache
public int
public long
public CachedResource
getResource(final String
The path
p
)

Implements io.undertow.server.handlers.resource.ResourceManager.getResource.

Returns a resource for the given path.

public void
public boolean
public void
registerResourceChangeListener(ResourceChangeListener
The listener to register
listener
)

Implements io.undertow.server.handlers.resource.ResourceManager.registerResourceChangeListener.

Registers a resource change listener, if the underlying resource manager support it

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheback to summary
private final LRUCache<String, Object> cache

A cache of file metadata, such as if a file exists or not

dataCacheback to summary
private final DirectBufferCache dataCache

A cache of byte buffers

maxAgeback to summary
private final int maxAge
maxFileSizeback to summary
private final long maxFileSize

The biggest file size we cache

underlyingResourceManagerback to summary
private final ResourceManager underlyingResourceManager

The underlying resource manager

Constructor Detail

CachingResourceManagerback to summary
public CachingResourceManager(final int metadataCacheSize, final long maxFileSize, final DirectBufferCache dataCache, final ResourceManager underlyingResourceManager, final int maxAge)

Method Detail

closeback to summary
public void close() throws IOException

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
getDataCacheback to summary
pack-priv DirectBufferCache getDataCache()
getMaxAgeback to summary
public int getMaxAge()
getMaxFileSizeback to summary
public long getMaxFileSize()
getResourceback to summary
public CachedResource getResource(final String p) throws IOException

Implements io.undertow.server.handlers.resource.ResourceManager.getResource.

Doc from io.undertow.server.handlers.resource.ResourceManager.getResource.

Returns a resource for the given path. It is the responsibility of the called to make sure that the path in Canonicalised.

Parameters
p:String

The path

Returns:CachedResource

The resource representing the path, or null if no resource was found.

Annotations
@Override
invalidateback to summary
public void invalidate(String path)
isResourceChangeListenerSupportedback to summary
public boolean isResourceChangeListenerSupported()

Implements io.undertow.server.handlers.resource.ResourceManager.isResourceChangeListenerSupported.

Returns:boolean

Doc from io.undertow.server.handlers.resource.ResourceManager.isResourceChangeListenerSupported.

true if a resource change listener is supported

Annotations
@Override
registerResourceChangeListenerback to summary
public void registerResourceChangeListener(ResourceChangeListener listener)

Implements io.undertow.server.handlers.resource.ResourceManager.registerResourceChangeListener.

Doc from io.undertow.server.handlers.resource.ResourceManager.registerResourceChangeListener.

Registers a resource change listener, if the underlying resource manager support it

Parameters
listener:ResourceChangeListener

The listener to register

Annotations
@Override
removeResourceChangeListenerback to summary
public void removeResourceChangeListener(ResourceChangeListener listener)

Implements io.undertow.server.handlers.resource.ResourceManager.removeResourceChangeListener.

Doc from io.undertow.server.handlers.resource.ResourceManager.removeResourceChangeListener.

Removes a resource change listener

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

private final Class CachingResourceManager.NoResourceMarker

extends Object
Class Inheritance
  • java.lang.Object
  • io.undertow.server.handlers.resource.CachingResourceManager.NoResourceMarker

Field Summary

Modifier and TypeField and Description
pack-priv volatile long

Constructor Summary

AccessConstructor and Description
private
NoResourceMarker(long nextCheckTime)

Method Summary

Modifier and TypeMethod and Description
public long
public void
setNextCheckTime(long nextCheckTime)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nextCheckTimeback to summary
pack-priv volatile long nextCheckTime

Constructor Detail

NoResourceMarkerback to summary
private NoResourceMarker(long nextCheckTime)

Method Detail

getNextCheckTimeback to summary
public long getNextCheckTime()
setNextCheckTimeback to summary
public void setNextCheckTime(long nextCheckTime)