Package org.ametys.core.resources
Class DefaultResourceHandler
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.resources.DefaultResourceHandler
-
- All Implemented Interfaces:
ResourceHandler
,LogEnabled
,Serviceable
- Direct Known Subclasses:
AbstractCompiledResourceHandler
,AbstractSourceMapResourceHandler
,ExpiresResourceHandler
,I18nTextResourceHandler
,ImageResourceHandler
,MinimizedCSSResourceHandler
,SassSourceMapResourceHandler
,UncompiledSassResourceHandler
public class DefaultResourceHandler extends AbstractLogEnabled implements ResourceHandler, Serviceable
Default resource handler
-
-
Field Summary
Fields Modifier and Type Field Description protected Map
_objectModel
The object modelprotected Parameters
_parameters
The sitemap parametersprotected boolean
_readForDownload
if the resource has been request for downloadprotected String
_requestedLocation
The initially requested resource locationprotected SourceResolver
_resolver
The source resolverprotected Source
_source
The resolved source
-
Constructor Summary
Constructors Constructor Description DefaultResourceHandler()
Default constructor.DefaultResourceHandler(Source source)
If theSource
is already resolved by theResourceHandlerProvider
, it may provide it through the constructor to avoid resolving it again.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
generate(OutputStream out)
Generate the resource configured during setup, and output itSerializable
getKey()
Get the unique key for this resource, for cache purpose.long
getLastModified()
Get the resource last modified timelong
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.void
service(ServiceManager manager)
Source
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, setLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ametys.core.resources.ResourceHandler
shouldUseSourceContentLength
-
-
-
-
Field Detail
-
_resolver
protected SourceResolver _resolver
The source resolver
-
_parameters
protected Parameters _parameters
The sitemap parameters
-
_objectModel
protected Map _objectModel
The object model
-
_readForDownload
protected boolean _readForDownload
if the resource has been request for download
-
_requestedLocation
protected String _requestedLocation
The initially requested resource location
-
-
Constructor Detail
-
DefaultResourceHandler
public DefaultResourceHandler()
Default constructor.
-
DefaultResourceHandler
public DefaultResourceHandler(Source source)
If theSource
is already resolved by theResourceHandlerProvider
, it may provide it through the constructor to avoid resolving it again.- Parameters:
source
- the source.
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
setup
public Source setup(String location, Map objectModel, Parameters parameters, boolean readForDownload) throws IOException, ProcessingException
Description copied from interface:ResourceHandler
Initialize the resource handler with a resource.- Specified by:
setup
in 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
public void generate(OutputStream out) throws IOException, ProcessingException
Description copied from interface:ResourceHandler
Generate the resource configured during setup, and output it- Specified by:
generate
in interfaceResourceHandler
- Parameters:
out
- The output stream to write to- Throws:
IOException
- If an error occursProcessingException
- If an error occurs
-
getKey
public Serializable getKey()
Description copied from interface:ResourceHandler
Get the unique key for this resource, for cache purpose.- Specified by:
getKey
in interfaceResourceHandler
- Returns:
- The cache key.
-
getValidity
public SourceValidity getValidity()
Description copied from interface:ResourceHandler
Get the resource validity, for cache purpose.- Specified by:
getValidity
in interfaceResourceHandler
- Returns:
- The resource validity.
-
getLength
public long getLength()
Description copied from interface:ResourceHandler
Get the resource size, if available.- Specified by:
getLength
in interfaceResourceHandler
- Returns:
- The resource size.
-
getLastModified
public long getLastModified()
Description copied from interface:ResourceHandler
Get the resource last modified time- Specified by:
getLastModified
in interfaceResourceHandler
- Returns:
- The last modified
-
getMimeType
public String getMimeType()
Description copied from interface:ResourceHandler
Return the mime type of the configured resource.- Specified by:
getMimeType
in interfaceResourceHandler
- Returns:
- The mime type.
-
-