Files
event-stream-processing-mic…/spring-boot-starters/spring-boot-starter-data-events/src/main/java/demo/event/EventAutoConfig.java
2016-12-26 06:12:21 -05:00

36 lines
1.2 KiB
Java
Executable File

package demo.event;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
/**
* This class auto-configures a {@link EventServiceImpl} bean.
*
* @author Kenny Bastani
*/
@Configuration
@ConditionalOnClass({ EventRepository.class, Source.class, RestTemplate.class })
@EnableConfigurationProperties(EventProperties.class)
public class EventAutoConfig {
private EventRepository eventRepository;
private Source source;
private RestTemplate restTemplate;
public EventAutoConfig(EventRepository eventRepository, Source source, RestTemplate restTemplate) {
this.eventRepository = eventRepository;
this.source = source;
this.restTemplate = restTemplate;
}
@SuppressWarnings("unchecked")
@Bean
public EventService eventService() {
return new EventServiceImpl(eventRepository, source, restTemplate);
}
}