Package org.ametys.core.resources
Interface ResourceHandler
-
- All Known Implementing Classes:
AbstractCompiledResourceHandler
,AbstractSourceMapResourceHandler
,CssResourceHandler
,CSSSourceMapResourceHandler
,DefaultResourceHandler
,ExpiresResourceHandler
,I18nTextResourceHandler
,ImageResourceHandler
,JSResourceHandler
,JSSourceMapResourceHandler
,LessResourceHandler
,MinimizedCSSResourceHandler
,MinimizedJSResourceHandler
,PdfCoverResourceHandler
,SassResourceHandler
,SassSourceMapResourceHandler
,SimpleResourceHandler
,UncompiledSassResourceHandler
,VueJsResourceHandler
public interface ResourceHandler
Interface used to handle resources
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default boolean
acceptRanges()
Returns true if thisResourceHandler
handles "Range" requests.void
generate(OutputStream out)
Generate the resource configured during setup, and output itdefault void
generate(OutputStream out, long offset, long length)
Generate the resource configured during setup in the context of a range request.Serializable
getKey()
Get the unique key for this resource, for cache purpose.long
getLastModified()
Get the resource last modified timedefault long
getLength()
Get the resource size, if available.String
getMimeType()
Return the mime type of the configured resource.SourceValidity
getValidity()
Get the resource validity, for cache purpose.Source
setup(String source, Map objectModel, Parameters par, boolean readForDownload)
Initialize the resource handler with a resource.default boolean
shouldUseSourceContentLength()
Returns true if the response Content-Length header should be set according to the source's length (ie.
-
-
-
Method Detail
-
setup
Source setup(String source, Map objectModel, Parameters par, boolean readForDownload) throws IOException, ProcessingException
Initialize the resource handler with a resource.- Parameters:
source
- The source uriobjectModel
- The object modelpar
- The parametersreadForDownload
- if the resource is to be downloaded and not rendered.- Returns:
- the resolved source
- Throws:
IOException
- If an error occursProcessingException
- If an error occurs
-
acceptRanges
default boolean acceptRanges()
Returns true if thisResourceHandler
handles "Range" requests. false by default.- Returns:
- true if this
ResourceHandler
handles "Range" requests.
-
generate
void generate(OutputStream out) throws IOException, ProcessingException
Generate the resource configured during setup, and output it- Parameters:
out
- The output stream to write to- Throws:
IOException
- If an error occursProcessingException
- If an error occurs
-
generate
default void generate(OutputStream out, long offset, long length) throws IOException, ProcessingException
Generate the resource configured during setup in the context of a range request.- Parameters:
out
- The output stream to write tooffset
- the first byte to sendlength
- the stream length to send- Throws:
IOException
- If an error occursProcessingException
- If an error occurs
-
getKey
Serializable getKey()
Get the unique key for this resource, for cache purpose.- Returns:
- The cache key.
-
getValidity
SourceValidity getValidity()
Get the resource validity, for cache purpose.- Returns:
- The resource validity.
-
getLength
default long getLength()
Get the resource size, if available. -1 if unknown.- Returns:
- The resource size.
-
getLastModified
long getLastModified()
Get the resource last modified time- Returns:
- The last modified
-
getMimeType
String getMimeType()
Return the mime type of the configured resource.- Returns:
- The mime type.
-
shouldUseSourceContentLength
default boolean shouldUseSourceContentLength()
Returns true if the response Content-Length header should be set according to the source's length (ie. the source is not transformed during processing).- Returns:
- true if the source's length can be relied on
-
-