Class InternalResourceMap


  • public final class InternalResourceMap
    extends Object

    The ImageResourceMap map keeps a reference to all internal resources within an application. It is used by the WContentHelperServlet to efficiently serve binary data without having to go through normal WComponent processing.

    Two things stop this map from consuming excessive amounts of memory:
    1. InternalResources are files which are present in the classpath. There will be a finite set.
    2. The InternalResource implementation does not hold the file data, just a reference to the file.
    Since:
    1.0.0
    Author:
    Yiannis Paschalidis
    • Method Detail

      • registerResource

        public static void registerResource​(InternalResource resource)
        Adds a resource to the resource map.
        Parameters:
        resource - the resource.
      • getResource

        public static InternalResource getResource​(String path)
        Retrieves a resource from the resource map.
        Parameters:
        path - the path to the resource.
        Returns:
        the resource path.
      • getResourceCacheKey

        public static String getResourceCacheKey​(String path)
        Retrieves the cache key for a resource path.
        Parameters:
        path - the path to the resource.
        Returns:
        the resource cache key.
      • computeHash

        public static String computeHash​(InternalResource resource)
        Computes a simple hash of the resource contents.
        Parameters:
        resource - the resource to hash.
        Returns:
        a hash of the resource contents.