DynamicContentpublic class DynamicContent extends Content Represents dynamic content in template form.
This class also keeps track of the most recent times the object's template
was used to generated different content from the previous time. 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 correct, 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 argument (for instance, one of the arguments could be a
timestamp that would change every time). |
Fields Summary |
---|
private static final int | MAX_INSTANCESmaximum number of instances of content to keep for each template | protected static final String | ALL_PERMISSIONS_JNLP_SETTINGJNLP element to request full permissions - used if the app client jar is signed | protected static final String | NO_PERMISSIONS_JNLP_SETTINGJNLP element to request no permissions - used if the app client jar is not signed - no perms is the JNLP default | private String | templatethe template which will be used at runtime to create the actual response
to the HTTP request | protected String | mimeTypethe MIME type of the data represented by this DynamicContent instance | private LinkedList | instancescontent instances resulting from previous HTTP GET requests | private boolean | requiresElevatedPermissionsrecords whether this content should request elevated permissions |
Constructors Summary |
---|
public DynamicContent(ContentOrigin origin, String contentKey, String path, String template, String mimeType)Returns a new instance of DynamicContent.
this(origin, contentKey, path, template, mimeType, false /* requiresElevatedPermissions */);
| public DynamicContent(ContentOrigin origin, String contentKey, String path, String template, String mimeType, boolean requiresElevatedPermissions)Returns a new instance of DynamicContent.
super(origin, contentKey, path);
this.template = template;
this.mimeType = mimeType;
this.requiresElevatedPermissions = requiresElevatedPermissions;
|
Methods Summary |
---|
private void | addInstance(com.sun.enterprise.appclient.jws.DynamicContent$Instance newInstance)Adds a new content instance to this dynamic content. If adding the instance
makes the cache too long, discards the oldest instance.
synchronized (instances) {
instances.addFirst(newInstance);
if (instances.size() > MAX_INSTANCES) {
instances.removeLast();
}
}
| protected void | clearInstances()Clears the cached instances.
instances.clear();
| public com.sun.enterprise.appclient.jws.DynamicContent$Instance | findInstance(java.util.Properties tokenValues, boolean createIfAbsent)Returns the DynamicContent.Instance for this template corresponding to
the specified substitution token values.
Instance result = null;
String textWithPlaceholdersReplaced = Util.replaceTokens(template, tokenValues);
/*
*Look for an instance with its text matching the just-computed replacement text.
*/
synchronized (instances) {
for (Instance i : instances) {
if (i.textEquals(textWithPlaceholdersReplaced)) {
result = i;
break;
}
}
if (result == null && createIfAbsent) {
result = new Instance(textWithPlaceholdersReplaced);
addInstance(result);
}
}
return result;
| public java.lang.String | getJNLPSecuritySetting()Returns the appropriate JNLP security setting for this content, based on
whether it requires elevated permissions or not.
return requiresElevatedPermissions ? ALL_PERMISSIONS_JNLP_SETTING : NO_PERMISSIONS_JNLP_SETTING;
| public java.lang.String | getMimeType()Returns the MIME type associated with this content.
return mimeType;
| public boolean | requiresElevatedPermissions()Returns whether this dynamic content requires elevated permissions.
return requiresElevatedPermissions;
| public java.lang.String | toString()Returns a string representation of the DynamicContent.
return super.toString() + ", template=" + template + ", MIME type=" + mimeType;// + ", most recent change in generated content=" + timestamp;
|
|