java.lang.Object
org.apache.wicket.util.resource.AbstractResourceStream
org.apache.wicket.util.resource.ZipResourceStream
- All Implemented Interfaces:
Closeable,Serializable,AutoCloseable,IClusterable,IResourceStream,IModifiable
An IResourceStream that ZIPs a directory's contents on the fly
NOTE 1. As a future improvement, cache a map of generated ZIP files for every directory and use a Watcher to detect modifications in this directory. Using ehcache would be good for that, but it's not in Wicket dependencies yet. No caching of the generated ZIP files is done yet.
NOTE 2. As a future improvement, implement getLastModified() and request ResourceStreamRequestTarget to generate Last-Modified and Expires HTTP headers. No HTTP cache headers are provided yet. See WICKET-385
- Author:
- Jean-Baptiste Quenot
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionZipResourceStream(File dir) Construct.ZipResourceStream(File dir, boolean recursive) Construct. -
Method Summary
Methods inherited from class org.apache.wicket.util.resource.AbstractResourceStream
getLocale, getStyle, getVariation, setLocale, setStyle, setVariation
-
Constructor Details
-
ZipResourceStream
Construct.- Parameters:
dir- The directory where to look for files. The directory itself will not be included in the ZIP.recursive- If true, all subdirs will be zipped as well
-
ZipResourceStream
Construct. Until Wicket 1.4-RC3 recursive zip was not supported. In order not to change the behavior, using this constructor will default to recursive == false.- Parameters:
dir- The directory where to look for files. The directory itself will not be included in the ZIP.
-
-
Method Details
-
close
Description copied from interface:IResourceStreamCloses the resource. Normally, this includes closing any underlying input stream returned by getInputStream().- Throws:
IOException- See Also:
-
getContentType
Description copied from interface:IResourceStreamGets the mime type of this resource- Specified by:
getContentTypein interfaceIResourceStream- Overrides:
getContentTypein classAbstractResourceStream- Returns:
- The mime type of this resource, such as "image/jpeg" or "text/html". Return null to let ResourceStreamRequestHandler handle the Content-Type automatically
- See Also:
-
getInputStream
Description copied from interface:IResourceStreamGets the resource stream. You should not directly close this stream. Instead call the close() method on IResourceStream.- Returns:
- Returns the inputStream.
- Throws:
ResourceStreamNotFoundException- See Also:
-
length
Description copied from interface:IResourceStreamGets the size of this resource- Specified by:
lengthin interfaceIResourceStream- Overrides:
lengthin classAbstractResourceStream- Returns:
- The size of this resource in the number of bytes, or
nullif unknown - See Also:
-
lastModifiedTime
Description copied from interface:IModifiableGets the last time this modifiable thing changed.- Specified by:
lastModifiedTimein interfaceIModifiable- Overrides:
lastModifiedTimein classAbstractResourceStream- Returns:
- the last modification
Timeornullif that information is not available - See Also:
-