Package org.ametys.core.resources
Class SimpleResourceHandler
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.core.resources.SimpleResourceHandler
- All Implemented Interfaces:
ResourceHandler,LogEnabled,Serviceable
- Direct Known Subclasses:
AbstractCompiledResourceHandler,AbstractSourceMapResourceHandler,DefaultResourceHandler,ExpiresResourceHandler,I18nTextResourceHandler,ImageResourceHandler,MinimizedCSSResourceHandler,SassSourceMapResourceHandler,UncompiledSassResourceHandler
public class SimpleResourceHandler
extends AbstractLogEnabled
implements ResourceHandler, Serviceable
Simple common ancestor for all
ResourceHandler implementations, delegating all methods to the underlying Source.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected MapThe object modelprotected ParametersThe sitemap parametersprotected booleanif the resource has been request for downloadprotected StringThe initially requested resource locationprotected SourceResolverThe source resolverprotected SourceThe resolved source -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.SimpleResourceHandler(Source source) If theSourceis already resolved by theResourceHandlerProvider, it may provide it through the constructor to avoid resolving it again. -
Method Summary
Modifier and TypeMethodDescriptionvoidgenerate(OutputStream out) Generate the resource configured during setup, and output itgetKey()Get the unique key for this resource, for cache purpose.longGet the resource last modified timeReturn the mime type of the configured resource.Get the resource validity, for cache purpose.voidservice(ServiceManager manager) setup(String location, Map objectModel, Parameters parameters, boolean readForDownload) Initialize the resource handler with a resource.Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLoggerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.ametys.core.resources.ResourceHandler
acceptRanges, generate, getLength, shouldUseSourceContentLength
-
Field Details
-
_resolver
The source resolver -
_source
The resolved source -
_parameters
The sitemap parameters -
_objectModel
The object model -
_readForDownload
if the resource has been request for download -
_requestedLocation
The initially requested resource location
-
-
Constructor Details
-
SimpleResourceHandler
public SimpleResourceHandler()Default constructor. -
SimpleResourceHandler
If theSourceis already resolved by theResourceHandlerProvider, it may provide it through the constructor to avoid resolving it again.- Parameters:
source- the source.
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
setup
public Source setup(String location, Map objectModel, Parameters parameters, boolean readForDownload) throws IOException, ProcessingException Description copied from interface:ResourceHandlerInitialize the resource handler with a resource.- Specified by:
setupin interfaceResourceHandler- Parameters:
location- The source uriobjectModel- The object modelparameters- 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
-
generate
Description copied from interface:ResourceHandlerGenerate the resource configured during setup, and output it- Specified by:
generatein interfaceResourceHandler- Parameters:
out- The output stream to write to- Throws:
IOException- If an error occursProcessingException- If an error occurs
-
getKey
Description copied from interface:ResourceHandlerGet the unique key for this resource, for cache purpose.- Specified by:
getKeyin interfaceResourceHandler- Returns:
- The cache key.
-
getValidity
Description copied from interface:ResourceHandlerGet the resource validity, for cache purpose.- Specified by:
getValidityin interfaceResourceHandler- Returns:
- The resource validity.
-
getLastModified
Description copied from interface:ResourceHandlerGet the resource last modified time- Specified by:
getLastModifiedin interfaceResourceHandler- Returns:
- The last modified
-
getMimeType
Description copied from interface:ResourceHandlerReturn the mime type of the configured resource.- Specified by:
getMimeTypein interfaceResourceHandler- Returns:
- The mime type.
-