b6367e835c56ae55a15f0a1c9550b30e42e93fe6
[SpringWebServicesForFun/.git] /
1 package de.spring.webservices.rest.business.service.impl;
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.business.service.BusinessService;
12 import de.spring.webservices.rest.client.service.CarClientService;
13
14 @Service("businessService")
15 public class BusinessServiceImpl implements BusinessService {
16         private static final Logger LOGGER = LoggerFactory.getLogger(BusinessServiceImpl.class);
17
18         private final CarClientService carClientService;
19
20         @Autowired
21         public BusinessServiceImpl(CarClientService carClientService) {
22                 this.carClientService = carClientService;
23         }
24         
25         
26         @Override
27         public void doSomethingWithCars() {
28                 List<Car> cars = carClientService.doGetCars();
29                 LOGGER.info("Retrieved cars");
30                 for (Car car : cars) {
31                         LOGGER.info("car: " + car.getId());
32                         LOGGER.info(car.getContent());
33                 }
34         }
35         
36         @Override
37         public void doSomethingWithCar(long id) {               
38                 Car car = carClientService.doGetCar(id);
39                 LOGGER.info("Retrieved car");
40                 LOGGER.info("car: " + car.getId());
41                 LOGGER.info(car.getContent());
42         }
43         
44         @Override
45         public void createsNewCar() {
46                 Car newCar = new Car(666L, "just_a_test");
47                 
48                 Car car = carClientService.doNewCar(newCar);
49                 LOGGER.info("New car");
50                 LOGGER.info("car: " + car.getId());
51                 LOGGER.info(car.getContent());
52         }
53 }