-
Notifications
You must be signed in to change notification settings - Fork 0
/
HawkApplicationReadyEventListener.java
33 lines (27 loc) · 1011 Bytes
/
HawkApplicationReadyEventListener.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package io.irw.hawk;
import io.irw.hawk.scraper.service.domain.HawkFlightService;
import io.irw.hawk.scraper.service.scrape.ScraperService;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.experimental.FieldDefaults;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
@Component
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
@RequiredArgsConstructor
@Slf4j
public class HawkApplicationReadyEventListener implements ApplicationListener<ApplicationReadyEvent> {
ScraperService scraperService;
HawkFlightService hawkFlightService;
@Override
@SneakyThrows
public void onApplicationEvent(ApplicationReadyEvent event) {
log.info("Running Hawk service");
hawkFlightService.startFlight();
scraperService.scrape();
hawkFlightService.finishFlight();
}
}