9f7605268e599d6a5dd2d85a8035105f0ec81ec9
[SpringWebServicesForFun/.git] /
1 package de.spring.webservices.rest.business;
2
3 import java.util.List;
4
5 import org.slf4j.Logger;
6 import org.slf4j.LoggerFactory;
7 import org.springframework.beans.factory.annotation.Autowired;
8 import org.springframework.stereotype.Service;
9
10 import de.spring.webservices.domain.Car;
11 import de.spring.webservices.rest.client.CarClientService;
12
13 @Service("businessService")
14 public class BusinessService {
15         private static final Logger LOGGER = LoggerFactory.getLogger(BusinessService.class);
16
17         private final CarClientService carClientService;
18
19         @Autowired
20         public BusinessService(CarClientService carClientService) {
21                 this.carClientService = carClientService;
22         }
23         
24         
25         public void doSomethingWithCars() {
26                 List<Car> cars = carClientService.doGetCars();
27                 LOGGER.info("Retrieved cars");
28                 for (Car car : cars) {
29                         LOGGER.info("car: " + car.getId());
30                         LOGGER.info(car.getContent());
31                 }
32         }
33         
34         public void doSomethingWithCar(long id) {               
35                 Car car = carClientService.doGetCar(id);
36                 LOGGER.info("Retrieved car");
37                 LOGGER.info("car: " + car.getId());
38                 LOGGER.info(car.getContent());
39         }
40         
41         public void createsNewCar() {
42                 Car newCar = new Car(666L, "just_a_test");
43                 
44                 Car car = carClientService.doNewCar(newCar);
45                 LOGGER.info("New car");
46                 LOGGER.info("car: " + car.getId());
47                 LOGGER.info(car.getContent());
48         }
49 }