1 package de.spring.webservices.rest.business.service.impl;
3 import java.util.concurrent.CompletableFuture;
5 import javax.inject.Inject;
7 import org.springframework.data.domain.Page;
8 import org.springframework.data.domain.Pageable;
9 import org.springframework.stereotype.Service;
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;
18 * TODO: WHAT ABOUT EXCEPTIONS FROM awesomeBusinessLogic? RuntimeExceptions for example
19 * I guess they will be caught by my adapter in controller layer but I must try it.
24 @Service("completableFutureBusinessLogic")
25 public class CompletablefutureBusinessLogicImpl implements CompletableFutureBusinessLogic {
26 private final AwesomeBusinessLogic awesomeBusinessLogic;
29 public CompletablefutureBusinessLogicImpl(AwesomeBusinessLogic awesomeBusinessLogic) {
30 this.awesomeBusinessLogic = awesomeBusinessLogic;
34 public CompletableFuture<Page<Car>> findAll(Pageable pageRequest) {
35 return CompletableFuture.supplyAsync(() -> awesomeBusinessLogic.findAll(pageRequest));
39 public CompletableFuture<Car> findById(long id) {
40 return CompletableFuture.supplyAsync(() -> awesomeBusinessLogic.findById(id));
44 public CompletableFuture<Car> create(Car car) {
45 return CompletableFuture.supplyAsync(() -> awesomeBusinessLogic.create(car));