| 23755 |
amit.gupta |
1 |
package com.smartdukaan.cron;
|
| 23723 |
amit.gupta |
2 |
|
|
|
3 |
import org.apache.logging.log4j.LogManager;
|
|
|
4 |
import org.apache.logging.log4j.Logger;
|
| 23898 |
amit.gupta |
5 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
6 |
import org.springframework.boot.ApplicationArguments;
|
|
|
7 |
import org.springframework.boot.ApplicationRunner;
|
| 23723 |
amit.gupta |
8 |
import org.springframework.boot.WebApplicationType;
|
|
|
9 |
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
|
10 |
import org.springframework.boot.builder.SpringApplicationBuilder;
|
|
|
11 |
import org.springframework.cache.annotation.EnableCaching;
|
|
|
12 |
import org.springframework.context.annotation.Bean;
|
|
|
13 |
import org.springframework.context.annotation.ComponentScan;
|
|
|
14 |
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
|
|
15 |
import org.springframework.core.io.ClassPathResource;
|
|
|
16 |
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
17 |
|
| 23898 |
amit.gupta |
18 |
import com.smartdukaan.cron.migrations.RunOnceTasks;
|
| 23724 |
amit.gupta |
19 |
|
| 23898 |
amit.gupta |
20 |
|
| 23723 |
amit.gupta |
21 |
@SpringBootApplication
|
|
|
22 |
@EnableCaching
|
|
|
23 |
@EnableScheduling
|
| 23755 |
amit.gupta |
24 |
@ComponentScan("com.smartdukaan.cron.*, com.spice.profitmandi.common.*")
|
| 23898 |
amit.gupta |
25 |
public class Application implements ApplicationRunner{
|
| 23723 |
amit.gupta |
26 |
|
|
|
27 |
private static final Logger LOGGER=LogManager.getLogger(Application.class);
|
|
|
28 |
|
|
|
29 |
public static void main(String[] args) throws Throwable {
|
| 23738 |
amit.gupta |
30 |
new SpringApplicationBuilder(Application.class).web(WebApplicationType.NONE).run(args);
|
| 23723 |
amit.gupta |
31 |
}
|
|
|
32 |
|
|
|
33 |
@Bean
|
| 23738 |
amit.gupta |
34 |
public static PropertySourcesPlaceholderConfigurer propertyConfigurer1() {
|
| 23755 |
amit.gupta |
35 |
LOGGER.info("Called Configuration");
|
| 23723 |
amit.gupta |
36 |
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
|
|
|
37 |
propertySourcesPlaceholderConfigurer.setLocation(new ClassPathResource("/META-INF/env.properties"));
|
|
|
38 |
return propertySourcesPlaceholderConfigurer;
|
|
|
39 |
}
|
|
|
40 |
|
| 23898 |
amit.gupta |
41 |
@Autowired
|
|
|
42 |
private RunOnceTasks runOnceTasks;
|
|
|
43 |
@Override
|
|
|
44 |
public void run(ApplicationArguments args) throws Exception {
|
|
|
45 |
LOGGER.info("Called run method");
|
|
|
46 |
if(args.containsOption("once")) {
|
|
|
47 |
runOnceTasks.populateGrnTimestamp();
|
|
|
48 |
System.exit(0);
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
}
|
|
|
52 |
|
| 23723 |
amit.gupta |
53 |
}
|