Class CachingDynamicContentImpl

  • All Implemented Interfaces:
    Content, DynamicContent

    public class CachingDynamicContentImpl
    extends Content.Adapter
    implements DynamicContent
    Represents dynamic content in template form.

    This class also keeps track of the most recent times the object's template was used to generate content that was different from the result of the previous generation using this template. This information is used in responding to HTTP HEAD requests. Java Web Start uses HEAD requests to find out if a document on the server is more recent than the locally cached copy on the client. If so, then Java Web Start will request the updated version with a routine GET request.

    To avoid incorrectly reporting obsolete cached documents as current, this class keeps track of when the content generated by the template is different from the previous generation.

    The generated content can depend on request-time information (such as command line arguments passed in the query string of the HTTP request). We save and track only a few individual response instances, because the assumption is that requests that carry query strings (which are converted into command line arguments passed to ACC and on through to the app client) are likely to change frequently and not necessarily be reused often. Keeping a few allows caching the different content resulting from a small number of different argument value settings, but avoids the problems of caching every single response which could become a large memory drain if each request specified a different set of arguments (for instance, one of the arguments could be a timestamp that would change every time).

    • Field Detail

      • mimeType

        protected final String mimeType
        the MIME type of the data represented by this CachingDynamicContentImpl instance
    • Constructor Detail

      • CachingDynamicContentImpl

        public CachingDynamicContentImpl​(String template,
                                         String mimeType)
        Returns a new instance of CachingDynamicContentImpl.
        Parameters:
        origin - the ContentOrigin for the new content instance
        contentKey - the content key used to store and retrieve the content
        path - the path relative to the subcategory in which this document is addressable
        mimeType - the MIME type of data represented by the content generated by this object.
      • CachingDynamicContentImpl

        public CachingDynamicContentImpl​(String template,
                                         String mimeType,
                                         int maxInstances)
    • Method Detail

      • getExistingInstance

        public DynamicContent.Instance getExistingInstance​(Properties tokenValues)
        Returns the CachingDynamicContentImpl.InstanceImpl for this template corresponding to the specified substitution token values.
        Specified by:
        getExistingInstance in interface DynamicContent
        Parameters:
        tokenValues - the name/value pairs to be substituted in the template
        createIfAbsent - selects whether a new CachingDynamicContentImpl.InstanceImpl should be created for the resulting text if the content text resulting from the substitution is not already cached by this CachingDynamicContentImpl.
        Returns:
        the instance corresponding to the content generated by the tokenValues; null if no such instance already exists for this CachingDynamicContentImpl and createIfAbsent was false.
      • getOrCreateInstance

        public DynamicContent.Instance getOrCreateInstance​(Properties tokenValues)
        Description copied from interface: DynamicContent
        Retrieves an existing "instance" of this dynamic content, with placeholders substituted, creating a new one if none already exists.
        Specified by:
        getOrCreateInstance in interface DynamicContent
        Parameters:
        tokenValues - maps placeholder tokens to values
        Returns:
        matching or newly-created Instance
      • isMain

        public boolean isMain()
        Description copied from interface: DynamicContent
        Reports whether this dynamic content represents the main JNLP document for an app client.
        Specified by:
        isMain in interface DynamicContent
        Returns:
      • getMimeType

        public String getMimeType()
        Returns the MIME type associated with this content.
        Specified by:
        getMimeType in interface DynamicContent
        Returns:
        the MIME type for this content
      • clearInstances

        protected void clearInstances()
        Clears the cached instances.
      • toString

        public String toString()
        Returns a string representation of the CachingDynamicContentImpl.
        Overrides:
        toString in class Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object