Class AbstractResource
- java.lang.Object
-
- org.apache.wicket.request.resource.AbstractResource
-
- All Implemented Interfaces:
java.io.Serializable,IResource,org.apache.wicket.util.io.IClusterable
- Direct Known Subclasses:
BaseDataResource,ConcatBundleResource,ContextRelativeResource,DynamicImageResource,FileSystemResource,PackageResource,ResourceStreamResource
public abstract class AbstractResource extends java.lang.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 classAbstractResource.ContentRangeTypeAll available content range types.static classAbstractResource.ResourceResponseRepresents data used to configure response and write resource data.static classAbstractResource.WriteCallbackCallback 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 java.lang.StringCONTENT_DISPOSITION_HEADER_NAMEstatic MetaDataKey<java.lang.Long>CONTENT_RANGE_ENDBYTEThe meta data key of the content range end bytestatic MetaDataKey<java.lang.Long>CONTENT_RANGE_STARTBYTEThe meta data key of the content range start bytestatic java.util.Set<java.lang.String>INTERNAL_HEADERSheader 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 voidconfigureCache(AbstractResource.ResourceResponse data, IResource.Attributes attributes)Configure the web response header for client cache control.protected IResourceCachingStrategygetCachingStrategy()protected abstract AbstractResource.ResourceResponsenewResourceResponse(IResource.Attributes attributes)Override this method to return aAbstractResource.ResourceResponsefor the request.voidrespond(IResource.Attributes attributes)Renders this resource to response using the provided attributes.protected voidsetRequestMetaData(IResource.Attributes attributes)Reads the plain request header information and applies enriched information as meta data to the current request.protected voidsetRequestRangeMetaData(org.apache.wicket.request.http.WebRequest webRequest)protected booleansetResponseContentRangeHeaderFields(org.apache.wicket.request.http.WebResponse webResponse, IResource.Attributes attributes, long contentLength)Sets the content range header fields to the given web responseprotected voidsetResponseHeaders(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 java.util.Set<java.lang.String> INTERNAL_HEADERS
header values that are managed internally and must not be set directly
-
CONTENT_RANGE_STARTBYTE
public static final MetaDataKey<java.lang.Long> CONTENT_RANGE_STARTBYTE
The meta data key of the content range start byte
-
CONTENT_RANGE_ENDBYTE
public static final MetaDataKey<java.lang.Long> CONTENT_RANGE_ENDBYTE
The meta data key of the content range end byte
-
CONTENT_DISPOSITION_HEADER_NAME
public static final java.lang.String CONTENT_DISPOSITION_HEADER_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
newResourceResponse
protected abstract AbstractResource.ResourceResponse newResourceResponse(IResource.Attributes attributes)
Override this method to return aAbstractResource.ResourceResponsefor 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:IResourceRenders this resource to response using the provided attributes.- Specified by:
respondin 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(org.apache.wicket.request.http.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(org.apache.wicket.request.http.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
-
-