Package org.apache.wicket.resource
Class FileSystemResource
- java.lang.Object
-
- org.apache.wicket.request.resource.AbstractResource
-
- org.apache.wicket.resource.FileSystemResource
-
- All Implemented Interfaces:
Serializable
,IResource
,IClusterable
public class FileSystemResource extends AbstractResource
Used to provide resources based on the on Java NIO FileSystem API.
For more information seeFileSystemResourceReference
- Author:
- Tobias Soloschenko
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.wicket.request.resource.AbstractResource
AbstractResource.ContentRangeType, AbstractResource.ResourceResponse, AbstractResource.WriteCallback
-
Nested classes/interfaces inherited from interface org.apache.wicket.request.resource.IResource
IResource.Attributes
-
-
Field Summary
-
Fields inherited from class org.apache.wicket.request.resource.AbstractResource
CONTENT_DISPOSITION_HEADER_NAME, CONTENT_RANGE_ENDBYTE, CONTENT_RANGE_STARTBYTE, INTERNAL_HEADERS
-
-
Constructor Summary
Constructors Constructor Description FileSystemResource()
Creates a new file system resourceFileSystemResource(Path path)
Creates a new file system resource based on the given path
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected AbstractResource.ResourceResponse
createResourceResponse(IResource.Attributes attributes, Path path)
Creates a resource response based on the given attributesprotected InputStream
getInputStream()
Gets the input stream of the given pathprotected String
getMimeType()
Gets the mime type to be used for the response it first uses the URL connection to get the mime type and after this the FileTypeDetector SPI is used.protected long
getSize()
Gets the size of the resourceprotected AbstractResource.ResourceResponse
newResourceResponse(IResource.Attributes attributes)
Creates a new resource response and reads the given pathvoid
respond(IResource.Attributes attributes)
Renders this resource to response using the provided attributes.-
Methods inherited from class org.apache.wicket.request.resource.AbstractResource
configureCache, getCachingStrategy, setRequestMetaData, setRequestRangeMetaData, setResponseContentRangeHeaderFields, setResponseHeaders
-
-
-
-
Constructor Detail
-
FileSystemResource
public FileSystemResource(Path path)
Creates a new file system resource based on the given path- Parameters:
path
- the path to be read for the resource
-
FileSystemResource
public FileSystemResource()
Creates a new file system resource
-
-
Method Detail
-
newResourceResponse
protected AbstractResource.ResourceResponse newResourceResponse(IResource.Attributes attributes)
Creates a new resource response and reads the given path- Specified by:
newResourceResponse
in classAbstractResource
- Parameters:
attributes
- request attributes- Returns:
- resource data instance
-
respond
public void respond(IResource.Attributes attributes)
Description copied from interface:IResource
Renders this resource to response using the provided attributes.- Specified by:
respond
in interfaceIResource
- Overrides:
respond
in classAbstractResource
- See Also:
IResource.respond(org.apache.wicket.request.resource.IResource.Attributes)
-
createResourceResponse
protected AbstractResource.ResourceResponse createResourceResponse(IResource.Attributes attributes, Path path)
Creates a resource response based on the given attributes- Parameters:
path
- the path to create the resource response withattributes
- request attributes- Returns:
- the actual resource response
-
getSize
protected long getSize() throws IOException
Gets the size of the resource- Returns:
- the size of the resource
- Throws:
IOException
- if the size attribute can't be read
-
getMimeType
protected String getMimeType() throws IOException
Gets the mime type to be used for the response it first uses the URL connection to get the mime type and after this the FileTypeDetector SPI is used.- Returns:
- the mime type to be used for the response
- Throws:
IOException
- if the mime type couldn't be resolved
-
getInputStream
protected InputStream getInputStream() throws IOException
Gets the input stream of the given path- Returns:
- the input stream of the given path
- Throws:
IOException
- if there is an exception while receiving the input stream
-
-