Package net.solarnetwork.node.setup
Class PatternMatchingSetupResourceProvider
java.lang.Object
net.solarnetwork.node.setup.PatternMatchingSetupResourceProvider
- All Implemented Interfaces:
SetupResourceProvider,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
public class PatternMatchingSetupResourceProvider
extends Object
implements SetupResourceProvider, org.springframework.context.ApplicationContextAware
Resolve resources based on pattern matching a set of base names.
This can be easier to configure a set of localized resources than using
SimpleSetupResourceProvider.- Version:
- 1.1
- Author:
- matt
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe content type assigned to resolved resources that are of an unknown type.Fields inherited from interface net.solarnetwork.node.setup.SetupResourceProvider
WEB_CONSUMER_TYPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetSetupResource(String resourceUID, Locale locale) Get a specific resource for a resource UID.getSetupResourcesForConsumer(String consumerType, Locale locale) Get a set of resources for specific context and content type.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) voidsetBasenames(String[] basenames) Set the base names supported by this factory.voidsetCacheSeconds(int cacheSeconds) Set the cache value to use for resolved resources, in seconds.voidsetConsumerTypes(Set<String> consumerTypes) Set the consumer types assigned to all resolved resources.voidsetDefaultLocale(Locale defaultLocale) Set the locale to use for resources that have no locale specified in their filename.voidsetFileExtensionContentTypeMapping(Map<String, String> fileExtensionContentTypeMapping) Set the filename to content type mapping.voidsetResourcePatternResolver(org.springframework.core.io.support.ResourcePatternResolver resourcePatternResolver) A pattern resolver to search for resources with.voidThe required roles to assign to resolved resources.voidsetScope(SetupResourceScope scope) Set a scope to use for all resolved resources.
-
Field Details
-
UNKNOWN_CONTENT_TYPE
The content type assigned to resolved resources that are of an unknown type.- See Also:
-
-
Constructor Details
-
PatternMatchingSetupResourceProvider
public PatternMatchingSetupResourceProvider()
-
-
Method Details
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
getSetupResource
Description copied from interface:SetupResourceProviderGet a specific resource for a resource UID.- Specified by:
getSetupResourcein interfaceSetupResourceProvider- Parameters:
resourceUID- the ID of the resource to getlocale- the desired locale- Returns:
- the resource, or null if not available
-
getSetupResourcesForConsumer
Description copied from interface:SetupResourceProviderGet a set of resources for specific context and content type. AconsumerTyperepresents the type of application the consumer of the setup resources represents. TheSetupResourceProvider.WEB_CONSUMER_TYPErepresents a webapp, for example, and would be interested in resources such as JavaScript, CSS, images, etc.- Specified by:
getSetupResourcesForConsumerin interfaceSetupResourceProvider- Parameters:
consumerType- the consumer type to get all appropriate resources for.locale- the desired locale.- Returns:
- all matching resources, never null
-
setConsumerTypes
Set the consumer types assigned to all resolved resources. Defaults toSetupResource.WEB_CONSUMER_TYPES.- Parameters:
consumerTypes- The consumer types.
-
setBasenames
Set the base names supported by this factory.- Parameters:
basenames- The list of base names (file paths without extensions) to use.
-
setResourcePatternResolver
public void setResourcePatternResolver(org.springframework.core.io.support.ResourcePatternResolver resourcePatternResolver) A pattern resolver to search for resources with.- Parameters:
resourcePatternResolver- The pattern resolver to use.
-
setCacheSeconds
public void setCacheSeconds(int cacheSeconds) Set the cache value to use for resolved resources, in seconds.- Parameters:
cacheSeconds- The cache maximum seconds.
-
setRoles
The required roles to assign to resolved resources. Defaults toSetupResource.USER_ROLES.- Parameters:
roles- The required roles to use.
-
setFileExtensionContentTypeMapping
Set the filename to content type mapping. Defaults toSetupResourceUtils.DEFAULT_FILENAME_EXTENSION_CONTENT_TYPES.- Parameters:
fileExtensionContentTypeMapping- The filename to content type mapping to use.
-
setDefaultLocale
Set the locale to use for resources that have no locale specified in their filename.- Parameters:
defaultLocale- The default locale.
-
setScope
Set a scope to use for all resolved resources.- Parameters:
scope- the scope to set- Since:
- 1.1
-