quartz job spring bean 오류 수정
This commit is contained in:
@@ -10,9 +10,11 @@ import java.util.List;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -39,7 +41,6 @@ public class DailyToMonthlyAggregationJob implements Job {
|
||||
|
||||
private ApiStatsDayService apiStatsDayService;
|
||||
private ApiStatsMonthService apiStatsMonthService;
|
||||
private DailyToMonthlyAggregationJob self;
|
||||
|
||||
@Autowired
|
||||
public void setApiStatsDayService(ApiStatsDayService apiStatsDayService) {
|
||||
@@ -51,18 +52,24 @@ public class DailyToMonthlyAggregationJob implements Job {
|
||||
this.apiStatsMonthService = apiStatsMonthService;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setSelf(DailyToMonthlyAggregationJob self) {
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
|
||||
ApplicationContext appContext = null;
|
||||
final DailyToMonthlyAggregationJob selfJob;
|
||||
try {
|
||||
appContext = (ApplicationContext) context.getScheduler().getContext().get("applicationContext");
|
||||
selfJob = appContext.getBean(DailyToMonthlyAggregationJob.class);
|
||||
} catch (SchedulerException e) {
|
||||
log.error("applicationContext get module error",e);
|
||||
return ;
|
||||
}
|
||||
|
||||
DataSourceType dataType = DataSourceTypeManager.getDataSourceType(DataSourceTypeManager.APIGW);
|
||||
DataSourceContextHolder.setDataSourceType(dataType);
|
||||
try {
|
||||
YearMonth targetMonth = YearMonth.now().minusMonths(1);
|
||||
self.executeManual(targetMonth);
|
||||
selfJob.executeManual(targetMonth);
|
||||
} catch (Exception e) {
|
||||
throw new JobExecutionException(e);
|
||||
} finally {
|
||||
|
||||
@@ -9,9 +9,11 @@ import java.util.List;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -38,7 +40,6 @@ public class HourlyToDailyAggregationJob implements Job {
|
||||
|
||||
private ApiStatsHourService apiStatsHourService;
|
||||
private ApiStatsDayService apiStatsDayService;
|
||||
private HourlyToDailyAggregationJob self;
|
||||
|
||||
@Autowired
|
||||
public void setApiStatsHourService(ApiStatsHourService apiStatsHourService) {
|
||||
@@ -50,18 +51,23 @@ public class HourlyToDailyAggregationJob implements Job {
|
||||
this.apiStatsDayService = apiStatsDayService;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setSelf(HourlyToDailyAggregationJob self) {
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
ApplicationContext appContext = null;
|
||||
final HourlyToDailyAggregationJob selfJob;
|
||||
try {
|
||||
appContext = (ApplicationContext) context.getScheduler().getContext().get("applicationContext");
|
||||
selfJob = appContext.getBean(HourlyToDailyAggregationJob.class);
|
||||
} catch (SchedulerException e) {
|
||||
log.error("applicationContext get module error",e);
|
||||
return ;
|
||||
}
|
||||
|
||||
DataSourceType dataType = DataSourceTypeManager.getDataSourceType(DataSourceTypeManager.APIGW);
|
||||
DataSourceContextHolder.setDataSourceType(dataType);
|
||||
try {
|
||||
LocalDate targetDate = LocalDate.now().minusDays(1);
|
||||
self.executeManual(targetDate);
|
||||
selfJob.executeManual(targetDate);
|
||||
} catch (Exception e) {
|
||||
throw new JobExecutionException(e);
|
||||
} finally {
|
||||
|
||||
+14
-7
@@ -8,9 +8,11 @@ import java.util.List;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -37,7 +39,6 @@ public class MonthlyToYearlyAggregationJob implements Job {
|
||||
|
||||
private ApiStatsMonthService apiStatsMonthService;
|
||||
private ApiStatsYearService apiStatsYearService;
|
||||
private MonthlyToYearlyAggregationJob self;
|
||||
|
||||
@Autowired
|
||||
public void setApiStatsMonthService(ApiStatsMonthService apiStatsMonthService) {
|
||||
@@ -49,18 +50,24 @@ public class MonthlyToYearlyAggregationJob implements Job {
|
||||
this.apiStatsYearService = apiStatsYearService;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setSelf(MonthlyToYearlyAggregationJob self) {
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
|
||||
ApplicationContext appContext = null;
|
||||
final MonthlyToYearlyAggregationJob selfJob;
|
||||
try {
|
||||
appContext = (ApplicationContext) context.getScheduler().getContext().get("applicationContext");
|
||||
selfJob = appContext.getBean(MonthlyToYearlyAggregationJob.class);
|
||||
} catch (SchedulerException e) {
|
||||
log.error("applicationContext get module error",e);
|
||||
return ;
|
||||
}
|
||||
|
||||
DataSourceType dataType = DataSourceTypeManager.getDataSourceType(DataSourceTypeManager.APIGW);
|
||||
DataSourceContextHolder.setDataSourceType(dataType);
|
||||
try {
|
||||
Year targetYear = Year.now().minusYears(1);
|
||||
self.executeManual(targetYear);
|
||||
selfJob.executeManual(targetYear);
|
||||
} catch (Exception e) {
|
||||
throw new JobExecutionException(e);
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user