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 Details

    • UNKNOWN_CONTENT_TYPE

      public static final String 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:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException
    • getSetupResource

      public SetupResource getSetupResource(String resourceUID, Locale locale)
      Description copied from interface: SetupResourceProvider
      Get a specific resource for a resource UID.
      Specified by:
      getSetupResource in interface SetupResourceProvider
      Parameters:
      resourceUID - the ID of the resource to get
      locale - the desired locale
      Returns:
      the resource, or null if not available
    • getSetupResourcesForConsumer

      public Collection<SetupResource> getSetupResourcesForConsumer(String consumerType, Locale locale)
      Description copied from interface: SetupResourceProvider
      Get a set of resources for specific context and content type. A consumerType represents the type of application the consumer of the setup resources represents. The SetupResourceProvider.WEB_CONSUMER_TYPE represents a webapp, for example, and would be interested in resources such as JavaScript, CSS, images, etc.
      Specified by:
      getSetupResourcesForConsumer in interface SetupResourceProvider
      Parameters:
      consumerType - the consumer type to get all appropriate resources for.
      locale - the desired locale.
      Returns:
      all matching resources, never null
    • setConsumerTypes

      public void setConsumerTypes(Set<String> consumerTypes)
      Set the consumer types assigned to all resolved resources. Defaults to SetupResource.WEB_CONSUMER_TYPES.
      Parameters:
      consumerTypes - The consumer types.
    • setBasenames

      public void setBasenames(String[] basenames)
      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

      public void setRoles(Set<String> roles)
      The required roles to assign to resolved resources. Defaults to SetupResource.USER_ROLES.
      Parameters:
      roles - The required roles to use.
    • setFileExtensionContentTypeMapping

      public void setFileExtensionContentTypeMapping(Map<String,String> fileExtensionContentTypeMapping)
      Set the filename to content type mapping. Defaults to SetupResourceUtils.DEFAULT_FILENAME_EXTENSION_CONTENT_TYPES.
      Parameters:
      fileExtensionContentTypeMapping - The filename to content type mapping to use.
    • setDefaultLocale

      public void setDefaultLocale(Locale defaultLocale)
      Set the locale to use for resources that have no locale specified in their filename.
      Parameters:
      defaultLocale - The default locale.
    • setScope

      public void setScope(SetupResourceScope scope)
      Set a scope to use for all resolved resources.
      Parameters:
      scope - the scope to set
      Since:
      1.1