|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.catalina.resources.ResourcesBase | +--org.apache.catalina.resources.FileResources
Implementation of the Resources that operates off a document base that is a directory in the local filesystem. If the specified document base is relative, it is resolved against the application base directory for our surrounding virtual host (if any), or against the value of the "catalina.home" system property.
IMPLEMENTATION NOTE: It is assumed that new files may be added, and existing files modified, while this web application is running. Therefore, only resources (not directories) are cached, and the background thread must remove cached entries that have been modified since they were cached.
Field Summary | |
protected java.io.File |
base
The document base directory for this component. |
protected static int |
BUFFER_SIZE
The descriptive information string for this implementation. |
protected static java.lang.String |
info
The descriptive information string for this implementation. |
Fields inherited from class org.apache.catalina.resources.ResourcesBase |
checkInterval, container, debug, docBase, expand, lifecycle, maxCount, maxSize, minSize, prefix, resourcesCache, resourcesCount, sm, started, support, thread, threadDone, threadName |
Fields inherited from interface org.apache.catalina.Lifecycle |
START_EVENT, STOP_EVENT |
Constructor Summary | |
FileResources()
|
Method Summary | |
boolean |
createCollection(java.lang.String path)
Create a collection at the specified path. |
boolean |
deleteResource(java.lang.String path)
Delete the specified resource. |
boolean |
exists(java.lang.String path)
Returns true if a resource exists at the specified path, where path would be suitable for passing as an argument to
getResource() or getResourceAsStream() . |
java.lang.String[] |
getCollectionMembers(java.lang.String path)
Return the children of the resource at the specified path, if any. |
java.lang.String |
getRealPath(java.lang.String path)
Return the real path for a given virtual path, or null
if no such path can be identified. |
java.net.URL |
getResource(java.lang.String path)
Return a URL to the resource specified by the given virtual path, or null if no such URL can be identified. |
java.io.InputStream |
getResourceAsStream(java.lang.String path)
Return an InputStream to the contents of the resource specified by the given virtual path, or null if no resource
exists at the specified path. |
long |
getResourceCreated(java.lang.String path)
Return the creation date/time of the resource at the specified path, where path would be suitable for passing as an
argument to getResource() or
getResourceAsStream() . |
long |
getResourceLength(java.lang.String path)
Return the content length of the resource at the specified path, where path would be suitable for passing as an
argument to getResource() or
getResourceAsStream() . |
long |
getResourceModified(java.lang.String path)
Return the last modified time for the resource specified by the given virtual path, or -1 if no such resource exists (or the last modified time cannot be determined). |
java.lang.String[] |
getResourcePaths()
Return the set of context-relative paths of all available resources. |
boolean |
isCollection(java.lang.String path)
Return true if the resource at the specified path is a collection. |
void |
setDocBase(java.lang.String docBase)
Set the document root for this component. |
boolean |
setResource(java.lang.String path,
java.io.InputStream content)
Set the content of the resource at the specified path. |
Methods inherited from class org.apache.catalina.resources.ResourcesBase |
addLifecycleListener, addPropertyChangeListener, cacheable, engineBase, getCheckInterval, getContainer, getDebug, getDocBase, getExpand, getInfo, getMaxCount, getMaxSize, getMimeType, getMinSize, hostBase, log, log, normalize, propertyChange, removeLifecycleListener, removePropertyChangeListener, run, setCheckInterval, setContainer, setDebug, setExpand, setMaxCount, setMaxSize, setMinSize, start, stop, threadProcess, threadSleep, threadStart, threadStop, validate |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.io.File base
protected static final java.lang.String info
protected static final int BUFFER_SIZE
Constructor Detail |
public FileResources()
Method Detail |
public void setDocBase(java.lang.String docBase)
setDocBase
in class ResourcesBase
docBase
- The new document rootjava.lang.IllegalArgumentException
- if the specified value is not
supported by this implementationjava.lang.IllegalArgumentException
- if this would create a
malformed URLpublic java.lang.String getRealPath(java.lang.String path)
null
if no such path can be identified.getRealPath
in class ResourcesBase
path
- Context-relative path starting with '/'java.lang.IllegalArgumentException
- if the path argument is null
or does not start with a '/'public java.net.URL getResource(java.lang.String path) throws java.net.MalformedURLException
null
if no such URL can be identified.
IMPLEMENTATION NOTE: Use of this method bypasses any caching
performed by this component. To take advantage of local caching,
use getResourceAsStream()
instead.
getResource
in class ResourcesBase
path
- Context-relative path starting with '/'java.lang.IllegalArgumentException
- if the path argument is null
or does not start with a '/'java.net.MalformedURLException
- if the resulting URL does not
have legal syntaxpublic java.io.InputStream getResourceAsStream(java.lang.String path)
null
if no resource
exists at the specified path.getResourceAsStream
in class ResourcesBase
path
- Context-relative path starting with '/'java.lang.IllegalArgumentException
- if the path argument is null
or does not start with a '/'public boolean exists(java.lang.String path)
path
would be suitable for passing as an argument to
getResource()
or getResourceAsStream()
.
If there is no resource at the specified location, return false.exists
in class ResourcesBase
path
- The path to the desired resourcepublic long getResourceModified(java.lang.String path)
IMPLEMENTATION NOTE: We are assuming that files may be modified while the application is running, so we bypass the cache and check the filesystem directly.
getResourceModified
in class ResourcesBase
path
- Context-relative path starting with '/'java.lang.IllegalArgumentException
- if the path argument is null
or does not start with a '/'public java.lang.String[] getResourcePaths()
public long getResourceCreated(java.lang.String path)
path
would be suitable for passing as an
argument to getResource()
or
getResourceAsStream()
. If there is no resource at the
specified location, return -1. If this time is unknown, the
implementation should return getResourceModified(path).
IMPLEMENTATION NOTE: The creation date of a file shouldn't change except if the file is deleted and the recreated, so this method uses the cache.
getResourceCreated
in class ResourcesBase
path
- Context-relative path starting with '/'java.lang.IllegalArgumentException
- if the path argument is null
or does not start with a '/'public long getResourceLength(java.lang.String path)
path
would be suitable for passing as an
argument to getResource()
or
getResourceAsStream()
. If the content length
of the resource can't be determined, return -1. If no content is
available (when for exemple, the resource is a collection), return 0.getResourceLength
in class ResourcesBase
path
- The path to the desired resourcepublic boolean isCollection(java.lang.String path)
isCollection
in class ResourcesBase
path
- The path to the desired resourcepublic java.lang.String[] getCollectionMembers(java.lang.String path)
getCollectionMembers
in class ResourcesBase
path
- The path to the desired resourcepublic boolean setResource(java.lang.String path, java.io.InputStream content)
setResource
in class ResourcesBase
path
- The path to the desired resourcecontent
- InputStream to the content to be setpublic boolean createCollection(java.lang.String path)
createCollection
in class ResourcesBase
path
- The path to the desired resourcepublic boolean deleteResource(java.lang.String path)
deleteResource
in class ResourcesBase
path
- The path to the desired resource
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |