Repository navigation
Expand file tree
/
Copy pathMain.java
More file actions
63 lines (42 loc) · 2.01 KB
/
Copy pathMain.java
File metadata and controls
63 lines (42 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package modern.challenge;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.logging.Logger;
public class Main {
private static final Logger logger = Logger.getLogger(Main.class.getName());
public static void main(String[] args) throws InterruptedException, ExecutionException {
System.setProperty("java.util.logging.SimpleFormatter.format",
"[%1$tT] [%4$-7s] %5$s %n");
logger.info("Printing customer order ...");
CustomerAsyncs.printOrder();
logger.info("Fetch order summary ...");
CustomerAsyncs.fetchOrderSummary();
logger.info("Fetch order summary (Executor) ...");
CustomerAsyncs.fetchOrderSummaryExecutor();
logger.info("Fetch order, compute total and sign ...");
CustomerAsyncs.fetchInvoiceTotalSign();
logger.info("Fetch and print order ...");
CustomerAsyncs.fetchAndPrintOrder();
logger.info("Deliver order and notify customer ...");
CustomerAsyncs.deliverOrderNotifyCustomer();
logger.info("exceptionally() ...");
CustomerAsyncs.fetchOrderTotalException();
logger.info("Chain exceptionally() ...");
CustomerAsyncs.fetchInvoiceTotalSignChainOfException();
logger.info("Global exceptionally() ...");
CustomerAsyncs.fetchInvoiceTotalSignGlobalException();
logger.info("exceptionallyCompose() ...");
CustomerAsyncs.printInvoiceException();
logger.info("exceptionallyAsync() ...");
CustomerAsyncs.fetchOrderTotalExceptionAsync();
logger.info("exceptionallyHandle() ...");
CustomerAsyncs.fetchOrderTotalHandle();
logger.info("Computing taxes ...");
CompletableFuture<Integer> cfTaxes = CustomerAsyncs.taxes();
while (!cfTaxes.isDone()) {
logger.info("Still computing ...");
}
int result = cfTaxes.get();
logger.info(() -> "Result: " + result);
}
}