public class SessionTestFacade extends Object
Constructor and Description |
---|
SessionTestFacade(javax.servlet.http.HttpSession session) |
Modifier and Type | Method and Description |
---|---|
Object |
get(String name)
Retrieve object from session.
|
<T> T |
get(String name,
Class<T> type)
Convenience method, will do internal check for null and then cast.
|
long |
getCreationTime()
Returns time when session was created.
|
protected javax.servlet.http.HttpSession |
getSession() |
void |
invalidate()
Invalidates current session.
|
String[] |
names()
Returns names of current attributes as a list.
|
void |
put(String name,
Serializable value)
Add object to a session.
|
void |
remove(String name)
Removes object from session.
|
void |
setTimeToLive(int seconds)
Sets time to live in seconds.
|
public SessionTestFacade(javax.servlet.http.HttpSession session)
public Object get(String name)
name
- name of object.public <T> T get(String name, Class<T> type)
ClassCastException
only in case the object in session is different type than expected.name
- name of session object.type
- expected typepublic void remove(String name)
name
- name of objectpublic void put(String name, Serializable value)
name
- name of objectvalue
- object reference.public long getCreationTime()
public void invalidate()
public void setTimeToLive(int seconds)
seconds
- time to live.public String[] names()
protected javax.servlet.http.HttpSession getSession()
Copyright © 2020 JavaLite. All rights reserved.