mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-13 02:14:45 +00:00
feat: Add Thread-Specific Storage design pattern (#3422)
* 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
This commit is contained in:
1 parent
48ba55a8a6
commit
e8595393d6
13 files changed
+702
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
@@ -0,0 +1,41 @@
|
||||
@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
|
||||
Reference in new issue
Block a user