(NEW) Illustrative classes: - App: simulates a production application - BusinessOperation<T>: abstraction over any operation that can potentially fail - FindCustomer <: BusinessOperation<String>: illustrative operation that can throw an error - Retry <: BusinessOperation<T>: transparently implements the retry mechanism - Several "business" exceptions: - BusinessException: top-level - CustomerNotFoundException: can be ignored - DatabaseNotAvailableException: fatal error (NEW) .puml and .png for UML
38 lines
1.0 KiB
Plaintext
38 lines
1.0 KiB
Plaintext
@startuml
|
|
package com.iluwatar.retry {
|
|
class App {
|
|
- LOG : Logger {static}
|
|
- op : BusinessOperation<String> {static}
|
|
+ App()
|
|
- errorNoRetry() {static}
|
|
- errorWithRetry() {static}
|
|
+ main(args : String[]) {static}
|
|
- noErrors() {static}
|
|
}
|
|
interface BusinessOperation<T> {
|
|
+ perform() : T {abstract}
|
|
}
|
|
class FindCustomer {
|
|
- customerId : String
|
|
- errors : Deque<BusinessException>
|
|
+ FindCustomer(customerId : String, errors : BusinessException[])
|
|
+ perform() : String
|
|
}
|
|
class Retry<T> {
|
|
- attempts : AtomicInteger
|
|
- delay : long
|
|
- errors : List<Exception>
|
|
- maxAttempts : int
|
|
- op : BusinessOperation<T>
|
|
- test : Predicate<Exception>
|
|
+ Retry<T>(op : BusinessOperation<T>, maxAttempts : int, delay : long, ignoreTests : Predicate<Exception>[])
|
|
+ attempts() : int
|
|
+ errors() : List<Exception>
|
|
+ perform() : T
|
|
}
|
|
}
|
|
Retry --> "-op" BusinessOperation
|
|
App --> "-op" BusinessOperation
|
|
FindCustomer ..|> BusinessOperation
|
|
Retry ..|> BusinessOperation
|
|
@enduml |