|
|||||||||
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.JarResources
Implementation of the Resources that decompresses and renders
entries from a JAR file that is located either locally or remotely.
Valid syntax for the docBase
property corresponds to the
syntax supported by the java.net.JarURLConnection
class,
and is illustrated by the following examples:
/path/to/filename.jar
as the source of resources.
http://www.foo.com/bar/baz.jar
(which makes this
instance of Catalina serve as a proxy for the specified application).
docBase
you specify must begin with
jar:
. If your docBase
value does not end with
"!/", this will be added for you.
IMPLEMENTATION NOTE: It is assumed that the underlying
JAR file itself will not be modified without restarting this web application
(or at least this Resources
implementation). Therefore, the
set of directory and resource entries is pre-loaded into our resource cache.
The actual data associated with these resources is not cached until it is
requested the first time (and passes the "cacheable" test).
Field Summary | |
protected java.net.JarURLConnection |
conn
The URLConnection to our JAR file. |
protected static java.lang.String |
info
The descriptive information string for this implementation. |
protected java.util.jar.JarFile |
jarFile
The JarFile object associated with our document base. |
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 | |
JarResources()
|
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. |
void |
stop()
Shut down this component. |
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, 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.net.JarURLConnection conn
protected static final java.lang.String info
protected java.util.jar.JarFile jarFile
Constructor Detail |
public JarResources()
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 the underlying JAR file will not be modified without restarting our associated Context, so it is sufficient to return the last modified timestamp from our cached resource bean.
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).getResourceCreated
in class ResourcesBase
path
- The path to the desired resourcepublic 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 resourcepublic void stop() throws LifecycleException
stop
in class ResourcesBase
LifecycleException
- if a major problem occurs
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |