How jerryesperanza/singletonpattern works
This is a small Java singleton example. UserApp.main obtains the shared Application instance, then demonstrates login, a rejected second login, logout, and another login. Application owns the singleton instance and the logged-in user state, and its synchronized methods perform the state changes. The graph is limited to the two runtime files shown; no separate storage or external service is present.
Main entry points: UserApp.java Demo entry point · Application.java Singleton session
Components 2
Other components
- Demo entry point
UserApp.java - Singleton session
Application.java
Connections 3
- Demo entry point → Singleton session: gets instance
UserApp.java - Demo entry point → Singleton session: logs in
UserApp.java - Demo entry point → Singleton session: logs out
UserApp.java