5eec938d993465e2117dc5da6d2307b02fc4bc1f
[JavaForFun] /
1 package de.spring.webservices.rest.business.service.impl;
2
3 import javax.inject.Inject;
4
5 import org.springframework.data.domain.Page;
6 import org.springframework.data.domain.Pageable;
7 import org.springframework.stereotype.Service;
8
9 import de.spring.webservices.domain.Car;
10 import de.spring.webservices.rest.business.service.AwesomeBusinessLogic;
11 import de.spring.webservices.rest.business.service.RxJavaBusinessLogic;
12 import rx.Observable;
13
14 /**
15  * 
16  * 
17  * TODO: WHAT ABOUT EXCEPTIONS FROM awesomeBusinessLogic? RuntimeExceptions for example
18  * I guess they will be caught by my adapter in controller layer but I must try it.
19  *
20  */
21
22
23 @Service("rxJavaBusinessLogic")
24 public class RxJavaBusinessLogicImpl implements RxJavaBusinessLogic {
25     private final AwesomeBusinessLogic awesomeBusinessLogic;
26     
27     @Inject
28         public RxJavaBusinessLogicImpl(AwesomeBusinessLogic awesomeBusinessLogic) {
29                 this.awesomeBusinessLogic = awesomeBusinessLogic;
30         }
31
32         @Override
33         public Observable<Page<Car>> findAll(Pageable pageRequest) {
34         return Observable.create(observer -> observer.onNext( awesomeBusinessLogic.findAll(pageRequest)));
35
36         }
37
38         @Override
39         public Observable<Car> findById(long id) {
40         return Observable.create(observer -> observer.onNext( awesomeBusinessLogic.findById(id)));
41         }
42
43         @Override
44         public Observable<Car> create(Car car) {        
45                 return Observable.create(observer -> observer.onNext(awesomeBusinessLogic.create(car)));
46         }
47 }