|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.webSvr.util.SessionVarBean
public final class SessionVarBean
JavaBean to hold explicit session variables such as user-selected-locale. Error tolerant on being set (should be able to be done by a filter using reflection) and can spit out a set of non-default values to adjust or pass to another server instance.
Names of all (visible) properties start "sessionVar" to avoid collision with other HTML (GET/POST) parameter users.
Not thread-safe; access to an instance in a session should be synchronised on the session object.
| Field Summary | |
|---|---|
static java.lang.String |
ATTR_NAME_SVB
Name of SessionVarBean instance in HttpSession. |
static java.lang.String |
KEY_sessionVar_CLEAR
HTTP tag/parameter we use to indicate that session variable should be set to defaults. |
static java.lang.String |
KEY_sessionVarLiteUI
|
static java.lang.String |
KEY_sessionVarLocale
|
private int |
rndToken
Immutable random token (shared with any clones/copies to save time) for cache-busting in URLs. |
private static long |
serialVersionUID
Unique Serialisation class ID generated by http://random.hd.org/. |
private boolean |
sessionVarLiteUI
Lite UI; if true we should run a "lite" UI for users on slow modems, etc, else full UI. |
private java.util.Locale |
sessionVarLocale
Session locale: if non-null this overrides any locale information from elsewhere. |
| Constructor Summary | |
|---|---|
SessionVarBean()
|
|
| Method Summary | |
|---|---|
java.lang.Object |
clone()
Make an independent clone of this object. |
SessionVarBean |
copy()
Make an independent clone of this object, returning the correct type; never null. |
static SessionVarBean |
getExtantSessionVars(javax.servlet.http.HttpServletRequest request,
boolean create)
Get (copy of) any existing value from the HTTP session; null if no session values and create is false. |
java.util.SortedMap<java.lang.String,java.lang.String> |
getNonDefaultValues()
Get sorted map of attribute names to values for all non-default values; never null. |
java.util.Locale |
getSessionVarLocale()
|
boolean |
isSessionVarLiteUI()
|
java.lang.String |
makeSessionVarSetURL(javax.servlet.http.HttpServletRequest request,
boolean attemptToPinToMirror,
DataSourceBean vars)
Generate new URL to set the desired state; never null. |
SessionVarBean |
setSessionVarLiteUI(boolean sessionVarLiteUI)
|
SessionVarBean |
setSessionVarLocale(java.util.Locale sessionVarLocale)
|
static void |
updateSessionVarsFromRequest(javax.servlet.http.HttpServletRequest request)
Update session vars from request, saving result back to session if need be. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String KEY_sessionVar_CLEAR
When this is set, session variables should be set to all defaults and then set to whatever other actual values are present, meaning that only changes from defaults need be sent.
This parameter is set to a fixed value for spiders to avoid presenting them with a spurious vast URI space to index.
private final int rndToken
private boolean sessionVarLiteUI
public static final java.lang.String KEY_sessionVarLiteUI
private java.util.Locale sessionVarLocale
Note that this field can only be set to Locales with a valid language code (ie two-letter lowercase) and an optional valid country code (ie two-letter uppercase) and no variant and that are found in our full supported-locales list. Note thae we do this validation since the Locale object does not (SHAME)!
We ignore attempts to set to an unsupported/unsafe/broken locale.
We rely on immutability of the Locale object here.
public static final java.lang.String KEY_sessionVarLocale
public static final java.lang.String ATTR_NAME_SVB
private static final long serialVersionUID
| Constructor Detail |
|---|
public SessionVarBean()
| Method Detail |
|---|
public boolean isSessionVarLiteUI()
public SessionVarBean setSessionVarLiteUI(boolean sessionVarLiteUI)
public java.util.Locale getSessionVarLocale()
public SessionVarBean setSessionVarLocale(java.util.Locale sessionVarLocale)
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedExceptionpublic SessionVarBean copy()
public static void updateSessionVarsFromRequest(javax.servlet.http.HttpServletRequest request)
This should probably only be routinely applied to GET operations where it cannot accidentally gobble data such as in a file-upload POST.
If a "clear" tag is present then we ignore extant values and start from defaults.
public java.lang.String makeSessionVarSetURL(javax.servlet.http.HttpServletRequest request,
boolean attemptToPinToMirror,
DataSourceBean vars)
For brevity/efficiency of result, this returns the shortest unambiguous relative or full URL that can be used as an href in the current page to get to the desired page with the desired session values set.
This may drop any query component of the original URL.
This may drop or preserve any fragment/ref component of the original URL.
This involves resetting all implicit session values to default and then explicitly setting all non-default values with query parameters.
This also adds a "cache-busting" random component to help ensure that the browser or a proxy does not just replay an old value from cache. This is given a fixed value if the request appears to be from a spider to avoid creating a huge virtual page space.
This can optionally force a diversion to an optimal mirror for the current site, helping to ensure that the user's browser is correctly "pinned" to a server and thus will not "lose" the state (and will probably give better performance for the user and be cheaper to serve too).
public static SessionVarBean getExtantSessionVars(javax.servlet.http.HttpServletRequest request,
boolean create)
Note that this returns a private copy of any value held in the session.
request - HTTP request object; never nullcreate - if true and session or session variable is missing
then createand return a new all-default value,
else if false and session or session variable is missing then return nullpublic java.util.SortedMap<java.lang.String,java.lang.String> getNonDefaultValues()
If the result is not empty then at least one value is non-default and we should probably save this in the session (creating a session if need be).
The map is sorted to so that it is easier to dump keys into HTML in sorted order and thus help compression if we are doing any.
|
DHD Multimedia Gallery V1.57.21 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||