Class CachingDynamicContentImpl
- java.lang.Object
-
- org.glassfish.appclient.server.core.jws.servedcontent.Content.Adapter
-
- org.glassfish.appclient.server.core.jws.servedcontent.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).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.glassfish.appclient.server.core.jws.servedcontent.Content
Content.Adapter, Content.State
-
Nested classes/interfaces inherited from interface org.glassfish.appclient.server.core.jws.servedcontent.DynamicContent
DynamicContent.Instance, DynamicContent.InstanceAdapter
-
-
Constructor Summary
Constructors Constructor Description CachingDynamicContentImpl(String template, String mimeType)
Returns a new instance of CachingDynamicContentImpl.CachingDynamicContentImpl(String template, String mimeType, int maxInstances)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
clearInstances()
Clears the cached instances.boolean
equals(Object obj)
DynamicContent.Instance
getExistingInstance(Properties tokenValues)
Returns the CachingDynamicContentImpl.InstanceImpl for this template corresponding to the specified substitution token values.String
getMimeType()
Returns the MIME type associated with this content.DynamicContent.Instance
getOrCreateInstance(Properties tokenValues)
Retrieves an existing "instance" of this dynamic content, with placeholders substituted, creating a new one if none already exists.int
hashCode()
boolean
isMain()
Reports whether this dynamic content represents the main JNLP document for an app client.String
toString()
Returns a string representation of the CachingDynamicContentImpl.-
Methods inherited from class org.glassfish.appclient.server.core.jws.servedcontent.Content.Adapter
isAvailable, resume, start, state, stop, suspend
-
-
-
-
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 instancecontentKey
- the content key used to store and retrieve the contentpath
- the path relative to the subcategory in which this document is addressablemimeType
- the MIME type of data represented by the content generated by this object.
-
-
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 interfaceDynamicContent
- Parameters:
tokenValues
- the name/value pairs to be substituted in the templatecreateIfAbsent
- 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 interfaceDynamicContent
- 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 interfaceDynamicContent
- Returns:
-
getMimeType
public String getMimeType()
Returns the MIME type associated with this content.- Specified by:
getMimeType
in interfaceDynamicContent
- 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.
-
-