Package com.tnsai.coordination.resources
Class SessionManager
java.lang.Object
com.tnsai.coordination.resources.SessionManager
Manages group work sessions with start/end tracking.
SessionManager tracks work sessions for agent groups. Each session has a unique ID, start/end timestamps, metadata, and a state. Only one session per group can be active at a time.
Usage Example
SessionManager manager = new SessionManager();
// Start a session
Session session = manager.startSession("group-1");
// Check active session
Optional<Session> active = manager.getActiveSession("group-1");
// End session
manager.endSession(session.id(), SessionState.COMPLETED);
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA work session for a group.static enumStates a session can be in. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidendSession(String sessionId, SessionManager.SessionState finalState) Ends a session with the specified final state.getActiveSession(String groupId) Returns the currently active session for a group, if any.getSession(String sessionId) Retrieves a session by ID.getSessions(String groupId) Returns all sessions for a group.startSession(String groupId) Starts a new session for the given group.startSession(String groupId, Map<String, Object> metadata) Starts a new session for the given group with metadata.
-
Constructor Details
-
SessionManager
public SessionManager()Creates a new SessionManager.
-
-
Method Details
-
startSession
Starts a new session for the given group.- Parameters:
groupId- the group ID- Returns:
- the newly created session
- Throws:
NullPointerException- if groupId is nullIllegalStateException- if the group already has an active session
-
startSession
Starts a new session for the given group with metadata.- Parameters:
groupId- the group IDmetadata- additional session metadata- Returns:
- the newly created session
- Throws:
NullPointerException- if groupId is nullIllegalStateException- if the group already has an active session
-
endSession
Ends a session with the specified final state.- Parameters:
sessionId- the session ID to endfinalState- the terminal state (COMPLETED or FAILED)- Throws:
NullPointerException- if sessionId or finalState is nullIllegalArgumentException- if session not found
-
getSession
Retrieves a session by ID.- Parameters:
sessionId- the session ID- Returns:
- the session, or empty if not found
- Throws:
NullPointerException- if sessionId is null
-
getActiveSession
Returns the currently active session for a group, if any.- Parameters:
groupId- the group ID- Returns:
- the active session, or empty if none is active
- Throws:
NullPointerException- if groupId is null
-
getSessions
Returns all sessions for a group.- Parameters:
groupId- the group ID- Returns:
- list of sessions for the group
- Throws:
NullPointerException- if groupId is null
-