Top Inners Fields Constructors Methods
org.apache.catalina.webresources

public abstract Class AbstractArchiveResource

extends AbstractResource
Class Inheritance
Known Direct Subclasses
org.apache.catalina.webresources.AbstractSingleArchiveResource, org.apache.catalina.webresources.JarWarResource
Imports
java.io.IOException, .InputStream, java.net.MalformedURLException, .URI, .URISyntaxException, .URL, java.nio.charset.StandardCharsets, java.security.cert.Certificate, java.util.concurrent.atomic.AtomicBoolean, java.util.jar.JarEntry, .Manifest, org.apache.catalina.util.URLEncoder

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
AbstractArchiveResource.JarInputStreamWrapper

This wrapper assumes that the InputStream was created from a JarFile obtained from a call to getArchiveResourceSet().openJarFile().

Field Summary

Modifier and TypeField and Description
private final AbstractArchiveResourceSet
private final String
private Certificate[]
private final String
private final String
private boolean
private final JarEntry
Inherited from org.apache.catalina.webresources.AbstractResource:
sm

Constructor Summary

AccessConstructor and Description
protected
AbstractArchiveResource(AbstractArchiveResourceSet archiveResourceSet, String webAppPath, String baseUrl, JarEntry jarEntry, String codeBaseUrl)

Method Summary

Modifier and TypeMethod and Description
public boolean
public boolean
protected final InputStream
public boolean
protected AbstractArchiveResourceSet
protected final String
protected final String
public String
public Certificate[]
public URL
public final byte[]
public long
public long
protected abstract AbstractArchiveResource.JarInputStreamWrapper
public long
public Manifest
public String
protected final JarEntry
public URL
public boolean
public boolean
public boolean
isVirtual()

Implements org.apache.catalina.WebResource.isVirtual.

Indicates if this resource is required for applications to correctly scan the file structure but that does not exist in either the main or any additional WebResourceSet.

Inherited from org.apache.catalina.webresources.AbstractResource:
getETaggetInputStreamgetLastModifiedHttpgetLoggetMimeTypegetWebappPathgetWebResourceRootsetMimeType

Field Detail

archiveResourceSetback to summary
private final AbstractArchiveResourceSet archiveResourceSet
baseUrlback to summary
private final String baseUrl
certificatesback to summary
private Certificate[] certificates
codeBaseUrlback to summary
private final String codeBaseUrl
nameback to summary
private final String name
readCertsback to summary
private boolean readCerts
resourceback to summary
private final JarEntry resource

Constructor Detail

AbstractArchiveResourceback to summary
protected AbstractArchiveResource(AbstractArchiveResourceSet archiveResourceSet, String webAppPath, String baseUrl, JarEntry jarEntry, String codeBaseUrl)

Method Detail

canReadback to summary
public boolean canRead()

Implements org.apache.catalina.WebResource.canRead.

Returns:boolean

Doc from org.apache.catalina.WebResource.canRead.

java.io.File#canRead().

Annotations
@Override
deleteback to summary
public boolean delete()

Implements org.apache.catalina.WebResource.delete.

Returns:boolean

Doc from org.apache.catalina.WebResource.delete.

java.io.File#delete().

Annotations
@Override
doGetInputStreamback to summary
protected final InputStream doGetInputStream()

Implements abstract org.apache.catalina.webresources.AbstractResource.doGetInputStream.

Annotations
@Override
existsback to summary
public boolean exists()

Implements org.apache.catalina.WebResource.exists.

Returns:boolean

Doc from org.apache.catalina.WebResource.exists.

java.io.File#exists().

Annotations
@Override
getArchiveResourceSetback to summary
protected AbstractArchiveResourceSet getArchiveResourceSet()
getBaseback to summary
protected final String getBase()
getBaseUrlback to summary
protected final String getBaseUrl()
getCanonicalPathback to summary
public String getCanonicalPath()

Implements org.apache.catalina.WebResource.getCanonicalPath.

Returns:String

Doc from org.apache.catalina.WebResource.getCanonicalPath.

java.io.File#getCanonicalPath().

Annotations
@Override
getCertificatesback to summary
public Certificate[] getCertificates()

Implements org.apache.catalina.WebResource.getCertificates.

Returns:Certificate[]

Doc from org.apache.catalina.WebResource.getCertificates.

the certificates that were used to sign this resource to verify it or @null if none.

Annotations
@Override
getCodeBaseback to summary
public URL getCodeBase()

Implements org.apache.catalina.WebResource.getCodeBase.

Returns:URL

Doc from org.apache.catalina.WebResource.getCodeBase.

the code base for this resource that will be used when looking up the assigned permissions for the code base in the security policy file when running under a security manager.

Annotations
@Override
getContentback to summary
public final byte[] getContent()

Implements org.apache.catalina.WebResource.getContent.

Returns:byte[]

Doc from org.apache.catalina.WebResource.getContent.

the binary content of this resource or null if it is not available in a byte[] because, for example, it is too big.

Annotations
@Override
getContentLengthback to summary
public long getContentLength()

Implements org.apache.catalina.WebResource.getContentLength.

Returns:long

Doc from org.apache.catalina.WebResource.getContentLength.

java.io.File#length().

Annotations
@Override
getCreationback to summary
public long getCreation()

Implements org.apache.catalina.WebResource.getCreation.

Returns:long

Doc from org.apache.catalina.WebResource.getCreation.

The time the file was created. If not available, the result of getLastModified() will be returned.

Annotations
@Override
getJarInputStreamWrapperback to summary
protected abstract AbstractArchiveResource.JarInputStreamWrapper getJarInputStreamWrapper()
getLastModifiedback to summary
public long getLastModified()

Implements org.apache.catalina.WebResource.getLastModified.

Returns:long

Doc from org.apache.catalina.WebResource.getLastModified.

java.io.File#lastModified().

Annotations
@Override
getManifestback to summary
public Manifest getManifest()

Implements org.apache.catalina.WebResource.getManifest.

Returns:Manifest

Doc from org.apache.catalina.WebResource.getManifest.

the manifest associated with this resource or @null if none.

Annotations
@Override
getNameback to summary
public String getName()

Implements org.apache.catalina.WebResource.getName.

Returns:String

Doc from org.apache.catalina.WebResource.getName.

java.io.File#getName().

Annotations
@Override
getResourceback to summary
protected final JarEntry getResource()
getURLback to summary
public URL getURL()

Implements org.apache.catalina.WebResource.getURL.

Returns:URL

Doc from org.apache.catalina.WebResource.getURL.

a URL to access the resource or null if no such URL is available or if the resource does not exist.

Annotations
@Override
isDirectoryback to summary
public boolean isDirectory()

Implements org.apache.catalina.WebResource.isDirectory.

Returns:boolean

Doc from org.apache.catalina.WebResource.isDirectory.

java.io.File#isDirectory().

Annotations
@Override
isFileback to summary
public boolean isFile()

Implements org.apache.catalina.WebResource.isFile.

Returns:boolean

Doc from org.apache.catalina.WebResource.isFile.

java.io.File#isFile().

Annotations
@Override
isVirtualback to summary
public boolean isVirtual()

Implements org.apache.catalina.WebResource.isVirtual.

Doc from org.apache.catalina.WebResource.isVirtual.

Indicates if this resource is required for applications to correctly scan the file structure but that does not exist in either the main or any additional WebResourceSet. For example, if an external directory is mapped to /WEB-INF/lib in an otherwise empty web application, /WEB-INF will be represented as a virtual resource.

Returns:boolean

true for a virtual resource

Annotations
@Override
org.apache.catalina.webresources back to summary

protected Class AbstractArchiveResource.JarInputStreamWrapper

extends InputStream
Class Inheritance

This wrapper assumes that the InputStream was created from a JarFile obtained from a call to getArchiveResourceSet().openJarFile(). If this is not the case then the usage counting in AbstractArchiveResourceSet will break and the JarFile may be unexpectedly closed.

Field Summary

Modifier and TypeField and Description
private final AtomicBoolean
private final InputStream
private final JarEntry

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
available()

Overrides java.io.InputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected.

public void
close()

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Closes this input stream and releases any system resources associated with the stream.

public Certificate[]
public synchronized void
mark(int
the maximum limit of bytes that can be read before the mark position becomes invalid.
readlimit
)

Overrides java.io.InputStream.mark.

Marks the current position in this input stream.

public boolean
markSupported()

Overrides java.io.InputStream.markSupported.

Tests if this input stream supports the mark and reset methods.

public int
read()

Implements abstract java.io.InputStream.read.

Reads the next byte of data from the input stream.

public int
read(byte[]
the buffer into which the data is read.
b
)

Overrides java.io.InputStream.read.

Reads some number of bytes from the input stream and stores them into the buffer array b.

public int
read(byte[]
the buffer into which the data is read.
b
,
int
the start offset in array b at which the data is written.
off
,
int
the maximum number of bytes to read.
len
)

Overrides java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes.

public synchronized void
reset()

Overrides java.io.InputStream.reset.

Repositions this stream to the position at the time the mark method was last called on this input stream.

public long
skip(long
the number of bytes to be skipped.
n
)

Overrides java.io.InputStream.skip.

Skips over and discards n bytes of data from this input stream.

Inherited from java.io.InputStream:
nullInputStreamreadAllBytesreadNBytesreadNBytesskipNBytestransferTo

Field Detail

closedback to summary
private final AtomicBoolean closed
isback to summary
private final InputStream is
jarEntryback to summary
private final JarEntry jarEntry

Constructor Detail

JarInputStreamWrapperback to summary
public JarInputStreamWrapper(JarEntry jarEntry, InputStream is)

Method Detail

availableback to summary
public int available() throws IOException

Overrides java.io.InputStream.available.

Doc from java.io.InputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. The read might be on the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.

Note that while some implementations of InputStream will return the total number of bytes in the stream, many will not. It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream.

A subclass's implementation of this method may choose to throw an IOException if this input stream has been closed by invoking the close() method.

Returns:int

an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking or 0 when it reaches the end of the input stream.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
closeback to summary
public void close() throws IOException

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.InputStream.close.

Closes this input stream and releases any system resources associated with the stream.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
getCertificatesback to summary
public Certificate[] getCertificates()
markback to summary
public synchronized void mark(int readlimit)

Overrides java.io.InputStream.mark.

Doc from java.io.InputStream.mark.

Marks the current position in this input stream. A subsequent call to the reset method repositions this stream at the last marked position so that subsequent reads re-read the same bytes.

The readlimit arguments tells this input stream to allow that many bytes to be read before the mark position gets invalidated.

The general contract of mark is that, if the method markSupported returns true, the stream somehow remembers all the bytes read after the call to mark and stands ready to supply those same bytes again if and whenever the method reset is called. However, the stream is not required to remember any data at all if more than readlimit bytes are read from the stream before reset is called.

Marking a closed stream should not have any effect on the stream.

Parameters
readlimit:int

the maximum limit of bytes that can be read before the mark position becomes invalid.

Annotations
@Override
markSupportedback to summary
public boolean markSupported()

Overrides java.io.InputStream.markSupported.

Doc from java.io.InputStream.markSupported.

Tests if this input stream supports the mark and reset methods. Whether or not mark and reset are supported is an invariant property of a particular input stream instance.

Returns:boolean

true if this stream instance supports the mark and reset methods; false otherwise.

Annotations
@Override
readback to summary
public int read() throws IOException

Implements abstract java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Returns:int

the next byte of data, or -1 if the end of the stream is reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read(byte[] b) throws IOException

Overrides java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads some number of bytes from the input stream and stores them into the buffer array b. The number of bytes actually read is returned as an integer. This method blocks until input data is available, end of file is detected, or an exception is thrown.

If the length of b is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at the end of the file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

The first byte read is stored into element b[0], the next one into b[1], and so on. The number of bytes read is, at most, equal to the length of b. Let k be the number of bytes actually read; these bytes will be stored in elements b[0] through b[k-1], leaving elements b[k] through b[b.length-1] unaffected.

Parameters
b:byte[]

the buffer into which the data is read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Annotations
@Override
Exceptions
IOException:
If the first byte cannot be read for any reason other than the end of the file, if the input stream has been closed, or if some other I/O error occurs.
readback to summary
public int read(byte[] b, int off, int len) throws IOException

Overrides java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read. The number of bytes actually read is returned as an integer.

This method blocks until input data is available, end of file is detected, or an exception is thrown.

If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

The first byte read is stored into element b[off], the next one into b[off+1], and so on. The number of bytes read is, at most, equal to len. Let k be the number of bytes actually read; these bytes will be stored in elements b[off] through b[off+k-1], leaving elements b[off+k] through b[off+len-1] unaffected.

In every case, elements b[0] through b[off-1] and elements b[off+len] through b[b.length-1] are unaffected.

Parameters
b:byte[]

the buffer into which the data is read.

off:int

the start offset in array b at which the data is written.

len:int

the maximum number of bytes to read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Annotations
@Override
Exceptions
IOException:
If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs.
resetback to summary
public synchronized void reset() throws IOException

Overrides java.io.InputStream.reset.

Doc from java.io.InputStream.reset.

Repositions this stream to the position at the time the mark method was last called on this input stream.

The general contract of reset is:

  • If the method markSupported returns true, then:
    • If the method mark has not been called since the stream was created, or the number of bytes read from the stream since mark was last called is larger than the argument to mark at that last call, then an IOException might be thrown.
    • If such an IOException is not thrown, then the stream is reset to a state such that all the bytes read since the most recent call to mark (or since the start of the file, if mark has not been called) will be resupplied to subsequent callers of the read method, followed by any bytes that otherwise would have been the next input data as of the time of the call to reset.
  • If the method markSupported returns false, then:
    • The call to reset may throw an IOException.
    • If an IOException is not thrown, then the stream is reset to a fixed state that depends on the particular type of the input stream and how it was created. The bytes that will be supplied to subsequent callers of the read method depend on the particular type of the input stream.
Annotations
@Override
Exceptions
IOException:
if this stream has not been marked or if the mark has been invalidated.
skipback to summary
public long skip(long n) throws IOException

Overrides java.io.InputStream.skip.

Doc from java.io.InputStream.skip.

Skips over and discards n bytes of data from this input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility. The actual number of bytes skipped is returned. If n is negative, the skip method for class InputStream always returns 0, and no bytes are skipped. Subclasses may handle the negative value differently.

Parameters
n:long

the number of bytes to be skipped.

Returns:long

the actual number of bytes skipped which might be zero.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.