0b5af2ff7637fe8bf1989968d2a0cdf664259055
[JavaForFun] /
1 package de.spring.webservices.rest.business.service.impl;
2
3 import java.util.concurrent.CompletableFuture;
4
5 import javax.inject.Inject;
6
7 import org.springframework.data.domain.Page;
8 import org.springframework.data.domain.Pageable;
9 import org.springframework.stereotype.Service;
10
11 import de.spring.webservices.domain.Car;
12 import de.spring.webservices.rest.business.service.AwesomeBusinessLogic;
13 import de.spring.webservices.rest.business.service.CompletableFutureBusinessLogic;
14
15 @Service("completableFutureBusinessLogic")
16 public class CompletablefutureBusinessLogicImpl implements CompletableFutureBusinessLogic {
17     private final AwesomeBusinessLogic awesomeBusinessLogic;
18     
19     @Inject
20         public CompletablefutureBusinessLogicImpl(AwesomeBusinessLogic awesomeBusinessLogic) {
21                 this.awesomeBusinessLogic = awesomeBusinessLogic;
22         }
23
24         @Override
25         public CompletableFuture<Page<Car>> findAll(Pageable pageRequest) {
26         return CompletableFuture.supplyAsync(() -> awesomeBusinessLogic.findAll(pageRequest));
27         }
28
29         @Override
30         public CompletableFuture<Car> findById(long id) {
31         return CompletableFuture.supplyAsync(() -> awesomeBusinessLogic.findById(id));
32         }
33
34         @Override
35         public CompletableFuture<Car> create(Car car) {
36                 return CompletableFuture.supplyAsync(() -> awesomeBusinessLogic.create(car));
37         }
38 }