public class ResourceCache extends Object implements LifeCycle, Serializable
Modifier and Type | Class and Description |
---|---|
class |
ResourceCache.ResourceMetaData
MetaData associated with a context Resource.
|
Modifier and Type | Field and Description |
---|---|
protected Map |
_cache |
protected int |
_cacheSize |
protected org.openqa.jetty.http.ResourceCache.CachedMetaData |
_leastRecentlyUsed |
protected org.openqa.jetty.http.ResourceCache.CachedMetaData |
_mostRecentlyUsed |
Constructor and Description |
---|
ResourceCache()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Destroy a context.
|
void |
flushCache() |
Resource |
getBaseResource()
Get the base resource.
|
String |
getEncodingByMimeType(String type)
Get char encoding by mime type.
|
Map |
getEncodingMap()
Get the map of mime type to char encoding.
|
int |
getMaxCachedFileSize() |
int |
getMaxCacheSize() |
String |
getMimeByExtension(String filename)
Get the MIME type by filename extension.
|
Map |
getMimeMap() |
Resource |
getResource(String pathInContext)
Get a resource from the context.
|
String |
getResourceBase()
Set the Resource Base.
|
ResourceCache.ResourceMetaData |
getResourceMetaData(Resource resource)
Get Resource MetaData.
|
boolean |
isStarted() |
void |
setBaseResource(Resource base)
Set the base resource.
|
void |
setEncodingMap(Map encodingMap)
Set the map of mime type to char encoding.
|
void |
setMaxCachedFileSize(int maxCachedFileSize) |
void |
setMaxCacheSize(int maxCacheSize) |
void |
setMimeMap(Map mimeMap)
Also sets the org.openqa.jetty.http.mimeMap context attribute
|
void |
setMimeMapping(String extension,
String type)
Set a mime mapping
|
void |
setResourceBase(String resourceBase)
Set the Resource Base.
|
void |
setTypeEncoding(String mimeType,
String encoding)
Set the encoding that should be used for a mimeType.
|
void |
start()
Start the LifeCycle.
|
void |
stop()
Stop the context.
|
protected transient Map _cache
protected transient int _cacheSize
protected transient org.openqa.jetty.http.ResourceCache.CachedMetaData _mostRecentlyUsed
protected transient org.openqa.jetty.http.ResourceCache.CachedMetaData _leastRecentlyUsed
public String getResourceBase()
public void setResourceBase(String resourceBase)
resourceBase
- A URL prefix or directory name.public Resource getBaseResource()
public void setBaseResource(Resource base)
base
- The resourceBase as a Resource instancepublic int getMaxCachedFileSize()
public void setMaxCachedFileSize(int maxCachedFileSize)
public int getMaxCacheSize()
public void setMaxCacheSize(int maxCacheSize)
public void flushCache()
public Resource getResource(String pathInContext) throws IOException
pathInContext
- IOException
public Map getMimeMap()
public void setMimeMap(Map mimeMap)
mimeMap
- public String getMimeByExtension(String filename)
filename
- A file namepublic void setMimeMapping(String extension, String type)
extension
- type
- public Map getEncodingMap()
public void setEncodingMap(Map encodingMap)
encodingMap
- Map of mime type to character encodings.public String getEncodingByMimeType(String type)
type
- A mime type.public void setTypeEncoding(String mimeType, String encoding)
mimeType
- encoding
- public void start() throws Exception
LifeCycle
public boolean isStarted()
public void stop() throws InterruptedException
stop
in interface LifeCycle
InterruptedException
- Stopping a lifecycle is rarely atomic
and may be interrupted by another thread. If this happens
InterruptedException is throw and the component will be in an
indeterminant state and should probably be discarded.public void destroy()
public ResourceCache.ResourceMetaData getResourceMetaData(Resource resource)
resource
- Copyright © 2013. All Rights Reserved.