Package org.ametys.core.resources
Class AbstractResourceHandler
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.resources.AbstractResourceHandler
-
- All Implemented Interfaces:
ResourceHandler,LogEnabled,Configurable,Contextualizable,Serviceable
- Direct Known Subclasses:
AbstractCompiledResourceHandler,AbstractSourceMapResourceHandler,DefaultResourceHandler,ExpiresResourceHandler,I18nTextResourceHandler,ImageResourceHandler,MinimizedCSSResourceHandler,SassSourceMapResourceHandler,UncompiledSassResourceHandler
public abstract class AbstractResourceHandler extends AbstractLogEnabled implements ResourceHandler, Serviceable, Configurable, Contextualizable
Abstract resource handler that supports the "suffixes" configuration
-
-
Field Summary
Fields Modifier and Type Field Description protected Context_cocoonContextThe cocoon contextprotected Context_contextThe contextprotected SourceResolver_resolverThe source resolverprotected Set<String>_supportedSuffixesThe supported suffixes-
Fields inherited from interface org.ametys.core.resources.ResourceHandler
MAX_PRIORITY, MIN_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description AbstractResourceHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure(Configuration configuration)voidcontextualize(Context context)SerializablegetKey(Source source, Map objectModel, Parameters parameters, Map<String,Object> additionalParameters)Get the unique key for this resource, for cache purpose.longgetLastModified(Source source, Parameters parameters)Get the resource last modified timeStringgetMimeType(Source source, Parameters parameters)Return the mime type of the configured resource.intgetPriority()Get the priority of this handlerlonggetSize(Source source, Parameters parameters)Get the resource size, if available.SourceValiditygetValidity(Source source, Map objectModel, Parameters parameters, Map<String,Object> additionalParameters)Get the resource validity, for cache purpose.booleanisSupported(String source)Determines if the resource is supported by this handlervoidservice(ServiceManager manager)Sourcesetup(String location, Map objectModel, Parameters par, Map<String,Object> additionalParameters)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
generateResource
-
-
-
-
Field Detail
-
_supportedSuffixes
protected Set<String> _supportedSuffixes
The supported suffixes
-
_resolver
protected SourceResolver _resolver
The source resolver
-
_cocoonContext
protected Context _cocoonContext
The cocoon context
-
-
Constructor Detail
-
AbstractResourceHandler
public AbstractResourceHandler()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configurein interfaceConfigurable- Throws:
ConfigurationException
-
setup
public Source setup(String location, Map objectModel, Parameters par, Map<String,Object> additionalParameters) 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 modelpar- The parametersadditionalParameters- Additional parameters that can be filled, and will be transmitted to getKey, getValidity and generateResource- Returns:
- the resolved source
- Throws:
IOException- If an error occursProcessingException- If an error occurs
-
isSupported
public boolean isSupported(String source)
Description copied from interface:ResourceHandlerDetermines if the resource is supported by this handler- Specified by:
isSupportedin interfaceResourceHandler- Parameters:
source- The uri of resource- Returns:
trueif the resource is supported
-
getPriority
public int getPriority()
Description copied from interface:ResourceHandlerGet the priority of this handler- Specified by:
getPriorityin interfaceResourceHandler- Returns:
- the priority. The bigger the highest priority
-
getMimeType
public String getMimeType(Source source, Parameters parameters)
Description copied from interface:ResourceHandlerReturn the mime type of the configured resource.- Specified by:
getMimeTypein interfaceResourceHandler- Parameters:
source- The sourceparameters- The parameters- Returns:
- The mime type.
-
getKey
public Serializable getKey(Source source, Map objectModel, Parameters parameters, Map<String,Object> additionalParameters)
Description copied from interface:ResourceHandlerGet the unique key for this resource, for cache purpose.- Specified by:
getKeyin interfaceResourceHandler- Parameters:
source- The sourceobjectModel- The object modelparameters- The parametersadditionalParameters- Additional parameters- Returns:
- The cache key.
-
getValidity
public SourceValidity getValidity(Source source, Map objectModel, Parameters parameters, Map<String,Object> additionalParameters)
Description copied from interface:ResourceHandlerGet the resource validity, for cache purpose.- Specified by:
getValidityin interfaceResourceHandler- Parameters:
source- The sourceobjectModel- The object modelparameters- The parametersadditionalParameters- Additional parameters- Returns:
- The resource validity.
-
getSize
public long getSize(Source source, Parameters parameters)
Description copied from interface:ResourceHandlerGet the resource size, if available.- Specified by:
getSizein interfaceResourceHandler- Parameters:
source- The sourceparameters- The parameters- Returns:
- The resource size.
-
getLastModified
public long getLastModified(Source source, Parameters parameters)
Description copied from interface:ResourceHandlerGet the resource last modified time- Specified by:
getLastModifiedin interfaceResourceHandler- Parameters:
source- The sourceparameters- The parameters- Returns:
- The last modified
-
-