import de.spring.webservices.domain.Car;
import de.spring.webservices.rest.business.service.AwesomeBusinessLogic;
+import rx.exceptions.Exceptions;
@Service("awesomeBusinessLogic")
public class AwesomeBusinessLogicImpl implements AwesomeBusinessLogic {
public Car createThrowable(Car car) throws IOException {
throw new IOException("createThrowable FATAL ERROR");
+ // Spring sees both exceptions.
+ // It seems like calling Exceptions.propagate(ex) in RxJava code is only required
+ // for no RuntimeExceptions :/
+ // throw new RuntimeException("createThrowable FATAL ERROR");
}
}
@Override
public void call(Subscriber<? super Page<Car>> observer) {
observer.onNext( awesomeBusinessLogic.findAll(pageRequest));
+ observer.onCompleted();
}
}).subscribeOn(Schedulers.io());
}
@Override
public void call(Subscriber<? super Page<Car>> observer) {
observer.onNext( awesomeBusinessLogic.findAll(pageRequest));
+ observer.onCompleted();
}
}).subscribeOn(Schedulers.io());
}
@Override
public Observable<Car> findById(long id) {
- return Observable.create((Subscriber<? super Car> observer) ->
- observer.onNext( awesomeBusinessLogic.findById(id)))
- .subscribeOn(Schedulers.io());
+ return Observable.create((Subscriber<? super Car> observer) -> {
+ observer.onNext( awesomeBusinessLogic.findById(id));
+ observer.onCompleted();
+ }).subscribeOn(Schedulers.io());
}
@Override
public Observable<Car> create(Car car) {
- return Observable.create((Subscriber<? super Car> observer) ->
- observer.onNext(awesomeBusinessLogic.create(car)))
- .subscribeOn(Schedulers.io());
+ return Observable.create((Subscriber<? super Car> observer) -> {
+ observer.onNext(awesomeBusinessLogic.create(car));
+ observer.onCompleted();
+ }).subscribeOn(Schedulers.io());
}
@Override
try {
observer.onNext(awesomeBusinessLogic.createThrowable(car));
+ observer.onCompleted();
} catch (IOException ex) {
// I could use this implementation. Instead, I will wrap my exception because
// that is what you would be doing if you were using any other method from RxJava (like map() for example)
Exceptions.propagate(ex);
}
-
- // No idea when to use this stuff :(
- // observer.onCompleted();
}).subscribeOn(Schedulers.io());
}