Package org.eclipse.jetty.util.resource
Class JarResource
- java.lang.Object
-
- org.eclipse.jetty.util.resource.Resource
-
- org.eclipse.jetty.util.resource.URLResource
-
- org.eclipse.jetty.util.resource.JarResource
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,ResourceFactory
- Direct Known Subclasses:
JarFileResource
,SelectiveJarResource
public class JarResource extends URLResource
-
-
Field Summary
Fields Modifier and Type Field Description protected java.net.JarURLConnection
_jarConnection
-
Fields inherited from class org.eclipse.jetty.util.resource.URLResource
_connection, _in, _url, _urlString
-
Fields inherited from class org.eclipse.jetty.util.resource.Resource
__defaultUseCaches
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
JarResource(java.net.URL url)
protected
JarResource(java.net.URL url, boolean useCaches)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
checkConnection()
void
close()
Release any resources held by the resource.void
copyTo(java.io.File directory)
Copy the Resource to the new destination file.boolean
exists()
Returns true if the represented resource exists.java.io.File
getFile()
Returns an File representing the given resource or NULL if this is not possible.java.io.InputStream
getInputStream()
Returns an input stream to the resource.protected void
newConnection()
static Resource
newJarResource(Resource resource)
-
Methods inherited from class org.eclipse.jetty.util.resource.URLResource
addPath, delete, equals, getInputStream, getName, getReadableByteChannel, getURL, getUseCaches, hashCode, isContainedIn, isDirectory, lastModified, length, list, renameTo, toString
-
Methods inherited from class org.eclipse.jetty.util.resource.Resource
encode, finalize, getAlias, getAllResources, getAssociate, getDefaultUseCaches, getListHTML, getListHTML, getResource, getURI, getWeakETag, getWeakETag, isAlias, isContainedIn, isSame, newClassPathResource, newClassPathResource, newResource, newResource, newResource, newResource, newResource, newResource, newSystemResource, release, setAssociate, setDefaultUseCaches, toURL, writeTo
-
-
-
-
Method Detail
-
close
public void close()
Description copied from class:URLResource
Release any resources held by the resource.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classURLResource
-
checkConnection
protected boolean checkConnection()
- Overrides:
checkConnection
in classURLResource
-
newConnection
protected void newConnection() throws java.io.IOException
- Throws:
java.io.IOException
- Sub-classes ofJarResource
may throw an IOException (or subclass)
-
exists
public boolean exists()
Returns true if the represented resource exists.- Overrides:
exists
in classURLResource
- Returns:
- true if the represented resource exists.
-
getFile
public java.io.File getFile() throws java.io.IOException
Description copied from class:URLResource
Returns an File representing the given resource or NULL if this is not possible.- Overrides:
getFile
in classURLResource
- Returns:
- an File representing the given resource or NULL if this is not possible.
- Throws:
java.io.IOException
- if unable to get the resource due to permissions
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOException
Description copied from class:URLResource
Returns an input stream to the resource. The underlying url connection will be nulled out to prevent re-use.- Overrides:
getInputStream
in classURLResource
- Returns:
- an input stream to the resource
- Throws:
java.io.IOException
- if unable to open the input stream
-
copyTo
public void copyTo(java.io.File directory) throws java.io.IOException
Description copied from class:Resource
Copy the Resource to the new destination file.Will not replace existing destination file.
-
-