Class AbstractResource
- java.lang.Object
-
- org.apache.wicket.request.resource.AbstractResource
-
- All Implemented Interfaces:
Serializable
,IResource
,IClusterable
- Direct Known Subclasses:
BaseDataResource
,ConcatBundleResource
,ContextRelativeResource
,DynamicImageResource
,FileSystemResource
,PackageResource
,ResourceStreamResource
public abstract class AbstractResource extends Object implements IResource
Convenience resource implementation. The subclass must implementnewResourceResponse(org.apache.wicket.request.resource.IResource.Attributes)
method.- Author:
- Matej Knopp, Tobias Soloschenko
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractResource.ContentRangeType
All available content range types.static class
AbstractResource.ResourceResponse
Represents data used to configure response and write resource data.static class
AbstractResource.WriteCallback
Callback invoked when resource data needs to be written to response.-
Nested classes/interfaces inherited from interface org.apache.wicket.request.resource.IResource
IResource.Attributes
-
-
Field Summary
Fields Modifier and Type Field Description static String
CONTENT_DISPOSITION_HEADER_NAME
static MetaDataKey<Long>
CONTENT_RANGE_ENDBYTE
The meta data key of the content range end bytestatic MetaDataKey<Long>
CONTENT_RANGE_STARTBYTE
The meta data key of the content range start bytestatic Set<String>
INTERNAL_HEADERS
header values that are managed internally and must not be set directly
-
Constructor Summary
Constructors Constructor Description AbstractResource()
Construct.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
configureCache(AbstractResource.ResourceResponse data, IResource.Attributes attributes)
Configure the web response header for client cache control.protected IResourceCachingStrategy
getCachingStrategy()
protected abstract AbstractResource.ResourceResponse
newResourceResponse(IResource.Attributes attributes)
Override this method to return aAbstractResource.ResourceResponse
for the request.void
respond(IResource.Attributes attributes)
Renders this resource to response using the provided attributes.protected void
setRequestMetaData(IResource.Attributes attributes)
Reads the plain request header information and applies enriched information as meta data to the current request.protected void
setRequestRangeMetaData(WebRequest webRequest)
protected boolean
setResponseContentRangeHeaderFields(WebResponse webResponse, IResource.Attributes attributes, long contentLength)
Sets the content range header fields to the given web responseprotected void
setResponseHeaders(AbstractResource.ResourceResponse resourceResponse, IResource.Attributes attributes)
Sets the response header of resource response to the response received from the attributes
-
-
-
Field Detail
-
INTERNAL_HEADERS
public static final Set<String> INTERNAL_HEADERS
header values that are managed internally and must not be set directly
-
CONTENT_RANGE_STARTBYTE
public static final MetaDataKey<Long> CONTENT_RANGE_STARTBYTE
The meta data key of the content range start byte
-
CONTENT_RANGE_ENDBYTE
public static final MetaDataKey<Long> CONTENT_RANGE_ENDBYTE
The meta data key of the content range end byte
-
CONTENT_DISPOSITION_HEADER_NAME
public static final String CONTENT_DISPOSITION_HEADER_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractResource
public AbstractResource()
Construct.
-
-
Method Detail
-
newResourceResponse
protected abstract AbstractResource.ResourceResponse newResourceResponse(IResource.Attributes attributes)
Override this method to return aAbstractResource.ResourceResponse
for the request.- Parameters:
attributes
- request attributes- Returns:
- resource data instance
-
configureCache
protected void configureCache(AbstractResource.ResourceResponse data, IResource.Attributes attributes)
Configure the web response header for client cache control.- Parameters:
data
- resource dataattributes
- request attributes
-
getCachingStrategy
protected IResourceCachingStrategy getCachingStrategy()
-
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
- See Also:
IResource.respond(org.apache.wicket.request.resource.IResource.Attributes)
-
setRequestMetaData
protected void setRequestMetaData(IResource.Attributes attributes)
Reads the plain request header information and applies enriched information as meta data to the current request. Those information are available for the whole request cycle.- Parameters:
attributes
- the attributes to get the plain request header information
-
setRequestRangeMetaData
protected void setRequestRangeMetaData(WebRequest webRequest)
-
setResponseHeaders
protected void setResponseHeaders(AbstractResource.ResourceResponse resourceResponse, IResource.Attributes attributes)
Sets the response header of resource response to the response received from the attributes- Parameters:
resourceResponse
- the resource response to get the header fields fromattributes
- the attributes to get the response from to which the header information are going to be applied
-
setResponseContentRangeHeaderFields
protected boolean setResponseContentRangeHeaderFields(WebResponse webResponse, IResource.Attributes attributes, long contentLength)
Sets the content range header fields to the given web response- Parameters:
webResponse
- the web response to apply the content range information toattributes
- the attributes to get the request fromcontentLength
- the content length of the response- Returns:
- if the content range header information has been applied
-
-