Package angry3vilbot.bankingapp
Class UserSession
java.lang.Object
angry3vilbot.bankingapp.UserSession
UserSession class to manage user session data.
This class is implemented as a Singleton to ensure that
only one instance of the session exists throughout the application.
It stores the user information and provides methods to
get and set the user.
It also provides a method to clear the session data
when the user logs out.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static UserSessionThe singleton instance of UserSession.private UserTheUserobject that contains user information. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClears the session data This method is used after a user logs out to clear the user information from the session.static UserSessionGet the singleton instance of UserSession This method is synchronized to ensure thread safety when accessing the singleton instance.getUser()Gets theUserobject that represents the current uservoidSets the newUserobject
-
Field Details
-
instance
The singleton instance of UserSession. -
user
TheUserobject that contains user information.
-
-
Constructor Details
-
UserSession
private UserSession()Private constructor to prevent instantiation
-
-
Method Details
-
getInstance
Get the singleton instance of UserSession This method is synchronized to ensure thread safety when accessing the singleton instance.- Returns:
- the singleton instance of UserSession
-
getUser
Gets theUserobject that represents the current user- Returns:
- the
Userobject
-
setUser
Sets the newUserobject- Parameters:
user- theUserobject to set
-
clearSession
public void clearSession()Clears the session data This method is used after a user logs out to clear the user information from the session.
-