|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectlazyj.DBSession
public final class DBSession
Web session wrapper, with a database backend.
This class will take the database settings from the file "dbsessions.properties" that is found in the
folder specified by the system property "lazyj.config.folder". So make sure you have given the parameter
"-Dlazyj.config.folder=/path/to/the/folder" to your java application. Or, as an alternative, you can set
this parameter to a meaningful value at the very begining of your application, before it accesses any class
from this framework.
Configuration parameters:
DBFunctions format.
| Field Summary | |
|---|---|
static java.lang.String |
COOKIE_NAME
The cookie name to use for session ids. |
| Method Summary | |
|---|---|
static void |
clear()
Clear cached sessions |
int |
compareTo(java.util.concurrent.Delayed o)
Implementation of Delayed |
static byte[] |
decodeString(java.lang.String text)
Decode a text previously encoded with encodeBytes(byte[]) to the original byte array |
static java.lang.String |
encodeBytes(byte[] binaryContent)
Convert a byte array to a String with only letters |
boolean |
equals(java.lang.Object o)
|
java.io.Serializable |
get(java.lang.String sKey)
Get the object that was previously associated with this key. |
int |
getApp()
Get the application for which this session is valid. |
static int |
getCacheSize()
Statistics function: get the number of sessions that are kept in the memory cache. |
java.lang.String |
getClientIP()
Get the client's IP address |
long |
getDelay(java.util.concurrent.TimeUnit unit)
Implementation of Delayed |
java.lang.String |
getFullname()
Get the full name of the user that is associated with this session. |
int |
geti(java.lang.String sKey)
Get the integer value associated with this key, with the default 0. |
int |
geti(java.lang.String sKey,
int iDefault)
Get the integer value associated with this key. |
java.lang.String |
getID()
Get the unique ID for this session. |
java.lang.String |
getLastPage()
This is the last page that the user tried to access. |
static java.util.List<java.lang.String> |
getPagesList(int iAppId)
For statistics, get a list of usernames and the pages that they are currently visiting |
java.lang.String |
gets(java.lang.String sKey)
Get the string value for this key. |
static DBSession |
getSession(ExtendedServlet tp)
This is the entry point for the session engine. |
static java.util.List<DBSession> |
getSessionsList(int iAppId,
boolean bOnlyLogged)
For internal statistics, get the list of all active sessions for a given application. |
java.lang.String |
getUserAgent()
Get user's browser |
java.lang.String |
getUsername()
Get the account associated with this session. |
int |
hashCode()
|
void |
invalidate()
This method will delete all the information about this session. |
void |
put(java.lang.String sKey,
java.io.Serializable oValue)
Set a session variable, by associating a value with an unique key. |
java.lang.Object |
readResolve()
Overriden method to set the calling page to null when deserializing. |
void |
setLastPage(java.lang.String s)
This method should be used when you want for example to force the user to first authenticate itself then to return it to the page that it tried to access. |
void |
setUser(java.lang.String sUserAccount,
java.lang.String sUserFullname)
When the user is authenticated, you should call this method to store the username and the complete name in the session as well in separate fields in the database. |
void |
setUserAgent(java.lang.String s)
If you want to create nice statistics for your site(s) you could track also the user's browser. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String COOKIE_NAME
| Method Detail |
|---|
public java.lang.String getID()
public void setLastPage(java.lang.String s)
s - page to set into the sessionExtendedServlet.getCurrentPage()public java.lang.String getLastPage()
public final void setUserAgent(java.lang.String s)
s - user's browser, you probably want to use request.getHeader("User-Agent") here.public java.lang.String getUserAgent()
public void setUser(java.lang.String sUserAccount,
java.lang.String sUserFullname)
sUserAccount - account namesUserFullname - complete namepublic java.lang.String getUsername()
public java.lang.String getFullname()
public int getApp()
public java.lang.String getClientIP()
public static DBSession getSession(ExtendedServlet tp)
tp - the page that is currently beeing executed
public void invalidate()
public void put(java.lang.String sKey,
java.io.Serializable oValue)
sKey - unique key, cannot be null.oValue - associated value. If null it will just remove a previously set value.public java.io.Serializable get(java.lang.String sKey)
sKey - unique key
public java.lang.String gets(java.lang.String sKey)
null
then the empty string is returned to the caller.
sKey - unique key
public int geti(java.lang.String sKey)
sKey - unique key
public int geti(java.lang.String sKey,
int iDefault)
sKey - unique keyiDefault - default value to return in case of an error
public static final java.lang.String encodeBytes(byte[] binaryContent)
binaryContent - array to encode
decodeString(String)public static final byte[] decodeString(java.lang.String text)
encodeBytes(byte[]) to the original byte array
text - string to decode
public static final java.util.List<DBSession> getSessionsList(int iAppId,
boolean bOnlyLogged)
iAppId - application unique id (see ExtendedServlet.getApp()). Can be 0 to retrive all known sessions.bOnlyLogged - true if you want only the authenticated user, false otherwise
public static final java.util.List<java.lang.String> getPagesList(int iAppId)
iAppId - application unique id (see ExtendedServlet.getApp()). Can be 0 to retrive info from all applications.
username|page for all the in-memory sessions.public long getDelay(java.util.concurrent.TimeUnit unit)
Delayed
getDelay in interface java.util.concurrent.Delayedunit - time unit in which to return the value
public int compareTo(java.util.concurrent.Delayed o)
Delayed
compareTo in interface java.lang.Comparable<java.util.concurrent.Delayed>o - object to compare to
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.Object readResolve()
getSession(ExtendedServlet)
public static void clear()
public static int getCacheSize()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||