|
|||||||||
| Home >> All >> org >> jeteam >> [ session overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.jeteam.session
Class HttpSessionCache

java.lang.Objectorg.jeteam.session.HttpSessionCache
- public class HttpSessionCache
- extends java.lang.Object
This cache keeps a java.util.Map internally to quickly lookup information that is associated with a specific session, this is to avoid to perform possibly costly operations more than necessary. In fact, the java.util.Map implementation maps HttpSessions instances to HttpSessionCache instance.
Get an instance for your session by passing the original request to the getInstance(HttpServletRequest)
method.
It is also possible to invalidate the cache in case you want to make sure the cache is rebuilt the next time
you do a call to getInstance(HttpServletRequest).
You can do this in one call, by using getInstance(HttpServletRequest,boolean) and passing
true as the second argument, this will force the cache to be replaced by the more recent one.
Furthermore, there are getter method for all available cache information.
This class is thread-safe in that it uses a java.util.Hashtable as the java.util.Map implementation.
| Field Summary | |
private java.lang.String[] |
days
|
private static java.util.Hashtable |
instanceMap
This is the singleton instance map. |
private java.lang.String[] |
months
|
private java.lang.String[] |
percentages
|
private org.jeteam.bean.project.ProjectDTO |
projectContext
|
private org.jeteam.bean.project.ProjectDTO[] |
projects
|
private org.jeteam.bean.config.SettingDTO[] |
settings
|
private org.jeteam.bean.user.UserDTO |
user
|
private java.lang.String[] |
years
|
| Constructor Summary | |
private |
HttpSessionCache(javax.servlet.http.HttpServletRequest request)
This class should not be instantiated directly. |
| Method Summary | |
java.lang.String[] |
getDays()
Returns an array of String instances that represent the days in a month. |
private org.jeteam.bean.project.ProjectDTO |
getDefaultProjectContext()
Checks if the user has a setting for a default project, if this is the case the corresponding ProjectDTO instance is returned. |
private java.lang.String |
getDefaultProjectContextName()
Searches the user's settings for a default project context name, this value is returned when found. |
static HttpSessionCache |
getInstance(javax.servlet.http.HttpServletRequest request)
Gets the singleton instance for the cache. |
static HttpSessionCache |
getInstance(javax.servlet.http.HttpServletRequest request,
boolean force)
Gets the singleton instance for the cache. |
java.lang.String[] |
getMonths()
The months of a year in the user's locale. |
java.lang.String[] |
getPercentages()
Percentages starting from 0 to 100, each time incremented by 5. |
private org.jeteam.bean.project.ProjectDTO |
getProject(java.lang.String projectName)
Gets the ProjectDTO instance with the given name, please note that only projects associated with this session's user are being taken into account. |
org.jeteam.bean.project.ProjectDTO |
getProjectContext()
The current project context, this value will be used when creating for example a task and no project is explicitely specified. |
org.jeteam.bean.project.ProjectDTO[] |
getProjects()
Returns an array of ProjectDTO instances that represent the user's projects. |
org.jeteam.bean.config.SettingDTO[] |
getSettings()
Returns an array of SettingDTO instances that represent the user's preferences or settings. |
org.jeteam.bean.user.UserDTO |
getUser()
Returns the user value object that is cached, the information is derived from the request's principal. |
java.lang.String[] |
getYears()
Five years starting from today. |
static void |
invalidateInstance(javax.servlet.http.HttpServletRequest request)
Invalidates this cache, the next time you need it you should get the instance by calling getInstance(HttpServletRequest) again. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
instanceMap
private static final java.util.Hashtable instanceMap
- This is the singleton instance map. We need it to be synchronized since many clients could access it
simultanously, that's why we prefer a Hastable over a HashMap.
user
private org.jeteam.bean.user.UserDTO user
projectContext
private org.jeteam.bean.project.ProjectDTO projectContext
settings
private org.jeteam.bean.config.SettingDTO[] settings
projects
private org.jeteam.bean.project.ProjectDTO[] projects
days
private java.lang.String[] days
months
private java.lang.String[] months
years
private java.lang.String[] years
percentages
private java.lang.String[] percentages
| Constructor Detail |
HttpSessionCache
private HttpSessionCache(javax.servlet.http.HttpServletRequest request)
- This class should not be instantiated directly.
By declaring it
privatewe respect the singleton pattern.
| Method Detail |
getInstance
public static HttpSessionCache getInstance(javax.servlet.http.HttpServletRequest request)
- Gets the singleton instance for the cache.
This is identical to calling
getInstance(request, false).
getInstance
public static HttpSessionCache getInstance(javax.servlet.http.HttpServletRequest request, boolean force)
- Gets the singleton instance for the cache.
In case there is a session for the argument request and the session is known internally the cache will be returned immediately, otherwise the cache is constructed and returned.
Use the
forceparameter if you want to reconstruct the cache even if it already exists.Please note that doing so implicitely invalidates the cache.
invalidateInstance
public static void invalidateInstance(javax.servlet.http.HttpServletRequest request)
- Invalidates this cache, the next time you need it you should get the instance by calling
getInstance(HttpServletRequest)again.Do this when you know the members of the cache have been updated by an external process.
IMPORTANT:
Do not use a cache instance after calling this method on a request which shares the same session as that cache. Each request from the same session uses the same cache.
getProject
private final org.jeteam.bean.project.ProjectDTO getProject(java.lang.String projectName)
- Gets the ProjectDTO instance with the given name, please note that only projects associated with this
session's user are being taken into account.
getDefaultProjectContextName
private final java.lang.String getDefaultProjectContextName()
- Searches the user's settings for a default project context name, this value is returned
when found. In case it is not found this method returns
null.
getDefaultProjectContext
private org.jeteam.bean.project.ProjectDTO getDefaultProjectContext()
- Checks if the user has a setting for a default project, if this is the case the corresponding ProjectDTO
instance is returned. In case the user does not have such a setting or it is invalid for some reason the first
project this user is assigned to will be returned and this value will be set as a new setting for that user.
getUser
public org.jeteam.bean.user.UserDTO getUser()
- Returns the user value object that is cached, the information
is derived from the request's principal.
getSettings
public org.jeteam.bean.config.SettingDTO[] getSettings()
- Returns an array of SettingDTO instances that represent the user's preferences or settings.
getProjects
public org.jeteam.bean.project.ProjectDTO[] getProjects()
- Returns an array of ProjectDTO instances that represent the user's projects.
getDays
public java.lang.String[] getDays()
- Returns an array of String instances that represent the days in a month.
getMonths
public java.lang.String[] getMonths()
- The months of a year in the user's locale.
getYears
public java.lang.String[] getYears()
- Five years starting from today.
getPercentages
public java.lang.String[] getPercentages()
- Percentages starting from 0 to 100, each time incremented by 5.
getProjectContext
public org.jeteam.bean.project.ProjectDTO getProjectContext()
- The current project context, this value will be used when creating for example
a task and no project is explicitely specified.
|
|||||||||
| Home >> All >> org >> jeteam >> [ session overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.jeteam.session.HttpSessionCache