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
_cocoonContext
The cocoon contextprotected Context
_context
The contextprotected SourceResolver
_resolver
The source resolverprotected Set<String>
_supportedSuffixes
The 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 void
configure(Configuration configuration)
void
contextualize(Context context)
Serializable
getKey(Source source, Map objectModel, Parameters parameters, Map<String,Object> additionalParameters)
Get the unique key for this resource, for cache purpose.long
getLastModified(Source source, Parameters parameters)
Get the resource last modified timeString
getMimeType(Source source, Parameters parameters)
Return the mime type of the configured resource.int
getPriority()
Get the priority of this handlerlong
getSize(Source source, Parameters parameters)
Get the resource size, if available.SourceValidity
getValidity(Source source, Map objectModel, Parameters parameters, Map<String,Object> additionalParameters)
Get the resource validity, for cache purpose.boolean
isSupported(String source)
Determines if the resource is supported by this handlervoid
service(ServiceManager manager)
Source
setup(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:
service
in interfaceServiceable
- Throws:
ServiceException
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
setup
public Source setup(String location, Map objectModel, Parameters par, Map<String,Object> additionalParameters) 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 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:ResourceHandler
Determines if the resource is supported by this handler- Specified by:
isSupported
in interfaceResourceHandler
- Parameters:
source
- The uri of resource- Returns:
true
if the resource is supported
-
getPriority
public int getPriority()
Description copied from interface:ResourceHandler
Get the priority of this handler- Specified by:
getPriority
in interfaceResourceHandler
- Returns:
- the priority. The bigger the highest priority
-
getMimeType
public String getMimeType(Source source, Parameters parameters)
Description copied from interface:ResourceHandler
Return the mime type of the configured resource.- Specified by:
getMimeType
in 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:ResourceHandler
Get the unique key for this resource, for cache purpose.- Specified by:
getKey
in 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:ResourceHandler
Get the resource validity, for cache purpose.- Specified by:
getValidity
in 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:ResourceHandler
Get the resource size, if available.- Specified by:
getSize
in interfaceResourceHandler
- Parameters:
source
- The sourceparameters
- The parameters- Returns:
- The resource size.
-
getLastModified
public long getLastModified(Source source, Parameters parameters)
Description copied from interface:ResourceHandler
Get the resource last modified time- Specified by:
getLastModified
in interfaceResourceHandler
- Parameters:
source
- The sourceparameters
- The parameters- Returns:
- The last modified
-
-