public class SessionState extends Object
The session lifecycle is pretty simple: there are only two lifecycle states, "alive" and "closed", and only one possible state transition, from "alive" to "closed".
Concurrent access to session internals is controlled by the
perform(SessionOperation)
method that guarantees that no two
operations
are performed concurrently on the
same session.
Constructor and Description |
---|
SessionState(SessionContext context)
Creates a state instance for a session.
|
Modifier and Type | Method and Description |
---|---|
void |
checkAlive()
Throws an exception if this session is not alive.
|
boolean |
close()
Closes this session.
|
boolean |
isAlive()
Checks whether this session is alive.
|
<T> T |
perform(SessionOperation<T> operation)
Performs the given operation within a synchronized block.
|
public SessionState(SessionContext context)
context
- component context of this sessionpublic boolean isAlive()
SessionOperation
, as
otherwise there's no guarantee against another thread closing the
session right after this method has returned.true
if the session is alive,
false
otherwiseSession.isLive()
public void checkAlive() throws RepositoryException
RepositoryException
- throw if this session is not alivepublic <T> T perform(SessionOperation<T> operation) throws RepositoryException
operation
- session operationRepositoryException
- if the operation fails or
if the session has already been closedpublic boolean close()
true
if the session was closed, or
false
if the session had already been closedCopyright © 2004–2021 The Apache Software Foundation. All rights reserved.