public interface Session
Modifier and Type | Method and Description |
---|---|
Session |
clear()
Remove all attributes.
|
static Session |
create(Context ctx,
String id)
Creates a new session.
|
static Session |
create(Context ctx,
String id,
Map<String,String> data)
Creates a new session.
|
void |
destroy()
Destroy/invalidates this session.
|
Value |
get(String name)
Get a session attribute.
|
Instant |
getCreationTime()
Session creation time.
|
String |
getId()
Session ID or
null for stateless (usually signed) sessions. |
Instant |
getLastAccessedTime()
Session last accessed time.
|
boolean |
isModify()
True for modified/dirty sessions.
|
boolean |
isNew()
True for new sessions.
|
default Session |
put(String name,
boolean value)
Put a session attribute.
|
default Session |
put(String name,
CharSequence value)
Put a session attribute.
|
default Session |
put(String name,
double value)
Put a session attribute.
|
default Session |
put(String name,
float value)
Put a session attribute.
|
default Session |
put(String name,
int value)
Put a session attribute.
|
default Session |
put(String name,
long value)
Put a session attribute.
|
default Session |
put(String name,
Number value)
Put a session attribute.
|
Session |
put(String name,
String value)
Put a session attribute.
|
Value |
remove(String name)
Remove a session attribute.
|
Session |
renewId()
Assign a new ID to the existing session.
|
Session |
setCreationTime(Instant creationTime)
Set session creation time.
|
Session |
setId(String id)
Set Session ID.
|
Session |
setLastAccessedTime(Instant lastAccessedTime)
Set session last accessed time.
|
Session |
setModify(boolean modify)
Set modify flag.
|
Session |
setNew(boolean isNew)
Set new flag.
|
Map<String,String> |
toMap()
Read-only copy of session attributes.
|
static final String NAME
@Nullable String getId()
null
for stateless (usually signed) sessions.null
for stateless (usually signed) sessions.@Nonnull Session setId(@Nullable String id)
id
- Session ID or null
@Nonnull Value get(@Nonnull String name)
name
- Attribute's name.@Nonnull default Session put(@Nonnull String name, int value)
name
- Attribute's name.value
- Attribute's value.@Nonnull default Session put(@Nonnull String name, long value)
name
- Attribute's name.value
- Attribute's value.@Nonnull default Session put(@Nonnull String name, @Nonnull CharSequence value)
name
- Attribute's name.value
- Attribute's value.@Nonnull Session put(@Nonnull String name, @Nonnull String value)
name
- Attribute's name.value
- Attribute's value.@Nonnull default Session put(@Nonnull String name, float value)
name
- Attribute's name.value
- Attribute's value.@Nonnull default Session put(@Nonnull String name, double value)
name
- Attribute's name.value
- Attribute's value.@Nonnull default Session put(@Nonnull String name, boolean value)
name
- Attribute's name.value
- Attribute's value.@Nonnull default Session put(@Nonnull String name, @Nonnull Number value)
name
- Attribute's name.value
- Attribute's value.@Nonnull Value remove(@Nonnull String name)
name
- Attribute's name.@Nonnull Map<String,String> toMap()
@Nonnull Instant getCreationTime()
@Nonnull Session setCreationTime(@Nonnull Instant creationTime)
creationTime
- Session creation time.@Nonnull Instant getLastAccessedTime()
@Nonnull Session setLastAccessedTime(@Nonnull Instant lastAccessedTime)
lastAccessedTime
- Session creation time.boolean isNew()
@Nonnull Session setNew(boolean isNew)
isNew
- New flag.boolean isModify()
@Nonnull Session setModify(boolean modify)
modify
- Modify flag.Session clear()
void destroy()
Session renewId()
@Nonnull static Session create(@Nonnull Context ctx, @Nullable String id)
ctx
- Web context.id
- Session ID or null
.Copyright © 2020. All rights reserved.