|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.svrCore.LocaleBeanBase
org.hd.d.pg2k.webSvr.util.LocaleBean
public final class LocaleBean
JavaBean encapsulating notions of locale for JSP/servlet pages. This should be created with request scope.
This puts off loading the properties bundle(s) until necessary, since it can suck CPU cycles.
If the user has a session in progress an explicit locale is looked for there, else the user's locale is obtained from the HTTP request object if the Accept-Languages header is present (which resorts to the server's locale if the user has not specified one), else we attempt to guess a locale given the user's IP address.
Access to this object is thread-safe, though since this object should appear at request (or page) level we do not actually expect threading to be an issue.
This is Serializable so as to be able to be stored in a servlet session; nothing especially long-lived or sensitive.
| Field Summary | |
|---|---|
private static boolean |
ALLOW_LOCALE_GUESS_FROM_IP_ADDR
If true then try to guess locale from user's IP address if no explicit locale indicated in HTTP request. |
private javax.servlet.http.HttpServletRequest |
cachedRequest
Cached request object. |
private static boolean |
LOG_MULTI_LOCALE_CLIENTS
If true then note when we seem to be visited by a client with multiple locale preferences set. |
private static WebUtils.ServletLoggerWithFallback |
logger
Our logger which falls back to System.out if servlet log not available; never null. |
private static long |
serialVersionUID
Unique Serialisation class ID generated by http://random.hd.org/. |
private static boolean |
SHOW_SERVER_ACCENT
If true, we may default the locale to that of the server location rather than the client, if no explicit locale is specified. |
private static StatsLogger.StatsConfig |
statsIDLang
The stats set to which we log HTTP-client preferred language code counts. |
private static StatsLogger.StatsConfig |
statsIDLangExplicit
The stats set to which we log HTTP-client explicitly-set language code counts. |
| Fields inherited from class org.hd.d.pg2k.svrCore.LocaleBeanBase |
|---|
SAFE_LOCALE |
| Constructor Summary | |
|---|---|
LocaleBean()
Public no-arg constructor for ease of use as a JavaBean. |
|
LocaleBean(java.util.Locale l)
Public no-arg constructor for ease of use as a JavaBean. |
|
| Method Summary | |
|---|---|
void |
setRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.ServletContext ctxt)
Set the current HTTP request to initialise the bean. |
| Methods inherited from class org.hd.d.pg2k.svrCore.LocaleBeanBase |
|---|
getCommonResourceBundle, getLocale, getLocalisedMessage, getLocalisedMessage, setLocale, toString, validateObject |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final boolean SHOW_SERVER_ACCENT
This is only in cases where no locale is specified, usually by SEs, whose spiders are predominantly in the US.
private static final boolean LOG_MULTI_LOCALE_CLIENTS
private static final WebUtils.ServletLoggerWithFallback logger
private static final StatsLogger.StatsConfig statsIDLang
We attempt to ignore requests from spiders, ie we try to log requests only from live humans.
We may enable or disable this logging (etc) from system parameters, but this is nonetheless our unique identifier.
private static final StatsLogger.StatsConfig statsIDLangExplicit
We attempt to ignore requests from spiders, ie we try to log requests only from live humans.
We may enable or disable this logging (etc) from system parameters, but this is nonetheless our unique identifier.
private static final boolean ALLOW_LOCALE_GUESS_FROM_IP_ADDR
private transient volatile javax.servlet.http.HttpServletRequest cachedRequest
private static final long serialVersionUID
| Constructor Detail |
|---|
public LocaleBean()
public LocaleBean(java.util.Locale l)
l - initial locale; never null| Method Detail |
|---|
public void setRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.ServletContext ctxt)
This first looks to see if there is a session containing a locale-override value; if so then it is used. No session is created if none exists.
Else, this looks for a locale set by the user's browser, and uses that if present.
Else, this tried to guess a suitable locale from the user's IP address, using the IP-to-location tools.
Else a `safe' locale is used, usually the server's.
If the request is null or some other invalid condition is encountered then this resets the local to a safe value (usually the server's locale).
If the new cached request is identical to the old one, then nothing is done.
request - if non-null is used to try to determine the user's localectxt - if non-null selects the servlet log to write to
(if null, output will go to System.out)
|
DHD Multimedia Gallery V1.57.21 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||