Class CachingLinkGenerator

  • All Implemented Interfaces:
    grails.plugins.PluginManagerAware, LinkGenerator, groovy.lang.GroovyObject, org.springframework.beans.factory.Aware

    public class CachingLinkGenerator
    extends org.grails.web.mapping.DefaultLinkGenerator
    A link generator that uses a LRU cache to cache generated links.
    Since:
    2.0
    • Constructor Detail

      • CachingLinkGenerator

        public CachingLinkGenerator​(java.lang.String serverBaseURL,
                                    java.lang.String contextPath)
      • CachingLinkGenerator

        public CachingLinkGenerator​(java.lang.String serverBaseURL)
    • Method Detail

      • link

        public java.lang.String link​(java.util.Map attrs,
                                     java.lang.String encoding)
        Description copied from interface: LinkGenerator
        Generates a link to a controller, action or URI for the given named parameters. Possible named parameters include:
        • resource - If linking to a REST resource, the name of the resource or resource path to link to. Either 'resource' or 'controller' should be specified, but not both
        • controller - The name of the controller to use in the link, if not specified the current controller will be linked
        • action - The name of the action to use in the link, if not specified the default action will be linked
        • uri - relative URI
        • url - A map containing the action,controller,id etc.
        • base - Sets the prefix to be added to the link target address, typically an absolute server URL. This overrides the behaviour of the absolute property, if both are specified.
        • absolute - If set to "true" will prefix the link target address with the value of the grails.serverURL property from Config, or http://localhost:<port> if no value in Config and not running in production.
        • id - The id to use in the link
        • fragment - The link fragment (often called anchor tag) to use
        • params - A map containing URL query parameters
        • mapping - The named URL mapping to use to rewrite the link
        • event - Webflow _eventId parameter
        Specified by:
        link in interface LinkGenerator
        Overrides:
        link in class org.grails.web.mapping.DefaultLinkGenerator
        Parameters:
        attrs - The named parameters
        encoding - The character encoding to use
        Returns:
        The generator link
      • isCacheable

        protected boolean isCacheable​(java.util.Map attrs)
      • appendMapKey

        protected void appendMapKey​(java.lang.StringBuilder buffer,
                                    java.util.Map<java.lang.String,​java.lang.Object> params)
      • getCacheKeyValueForResource

        protected java.lang.String getCacheKeyValueForResource​(java.lang.Object o)
      • appendKeyValue

        protected void appendKeyValue​(java.lang.StringBuilder buffer,
                                      java.util.Map map,
                                      java.lang.Object key,
                                      java.lang.Object value)
      • resource

        public java.lang.String resource​(java.util.Map attrs)
        Description copied from interface: LinkGenerator
        Generates a link to a static resource for the given named parameters. Possible named parameters include:
        • base - The base path of the URL, typically an absolute server path
        • contextPath - The context path to link to, defaults to the servlet context path
        • dir - The directory to link to
        • file - The file to link to (relative to the directory if specified)
        • plugin - The plugin that provides the resource
        • absolute - Whether the link should be absolute or not
        Specified by:
        resource in interface LinkGenerator
        Overrides:
        resource in class org.grails.web.mapping.DefaultLinkGenerator
        Parameters:
        attrs - The named parameters
        Returns:
        The link to the static resource
      • makeKey

        protected java.lang.String makeKey​(java.lang.String prefix,
                                           java.util.Map attrs)
      • clearCache

        public void clearCache()