mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-09-13 06:19:41 +00:00
* Add Thread-Specific Storage design pattern * fixed:pom.xml Run 'mvn spotless:apply' to fix these violations. * fix: address Sonar security hotspots for Random usage and e.printStackTrace() * fixed: Run 'mvn spotless:apply'(remove unused import) * fixed: Refactor Thread-Specific Storage pattern implementation to address Sonar issues: remove unnecessary instantiation, add private constructor, use diamond operator, and update tests. * fixed: update uml and README.md * Trigger CI rerun
41 lines
901 B
Plaintext
41 lines
901 B
Plaintext
@startuml
|
|
package thread-specific-storage {
|
|
|
|
class APP {
|
|
+ {static} main(args : String[]) : void
|
|
}
|
|
|
|
class Thread {
|
|
+ start() : void
|
|
}
|
|
|
|
class UserContext {
|
|
- userId : Long
|
|
+ UserContext(userId : Long)
|
|
+ getUserId() : Long
|
|
+ setUserId(userId : Long) : void
|
|
}
|
|
|
|
class UserContextProxy {
|
|
- {static} userContextHolder : ThreadLocal<UserContext>
|
|
+ {static} set(context : UserContext) : void
|
|
+ {static} get() : UserContext
|
|
+ {static} clear() : void
|
|
}
|
|
|
|
class RequestHandler {
|
|
- token : String
|
|
+ RequestHandler(token : String)
|
|
+ process() : void
|
|
- parseToken(token : String) : Long
|
|
}
|
|
|
|
UserContextProxy --> UserContext : manages
|
|
RequestHandler --> UserContextProxy : uses static
|
|
RequestHandler --> UserContext : creates
|
|
APP --> RequestHandler : creates
|
|
APP --> Thread : starts
|
|
Thread --> RequestHandler : executes
|
|
|
|
}
|
|
@enduml |