parent
da7fbcb7f6
commit
81f4efb339
@ -0,0 +1,39 @@
|
|||||||
|
package com.bsmlab.dfx.agent.config;
|
||||||
|
|
||||||
|
import com.bsmlab.dfx.agent.config.datasource.DynamicDataSourceService;
|
||||||
|
import com.bsmlab.dfx.agent.task.dropbox.DropBoxTaskExecutorService;
|
||||||
|
import com.bsmlab.dfx.agent.task.postman.PostmanSchedulerService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.SmartInitializingSingleton;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class BeanInitializer implements SmartInitializingSingleton {
|
||||||
|
private final DfxAgentConfiguration dfxAgentConfiguration;
|
||||||
|
private final DynamicDataSourceService dynamicDataSourceService;
|
||||||
|
private final PostmanSchedulerService postmanSchedulerService;
|
||||||
|
private final DropBoxTaskExecutorService dropBoxTaskExecutorService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterSingletonsInstantiated() {
|
||||||
|
System.out.println("🔥 BeanInitializer afterSingletonsInstantiated() 진입!");
|
||||||
|
log.info("✅ BeanInitializer 작동 확인");
|
||||||
|
/*
|
||||||
|
// DfxAgentConfiguration 에서 생성한 빈 중 DataSource 관련 설정을 마무리한다.
|
||||||
|
dynamicDataSourceService.setSqlSessionFactoryMap(dfxAgentConfiguration.getTemporarySqlSessionFactoryMap());
|
||||||
|
dynamicDataSourceService.setTransactionManagerMap(dfxAgentConfiguration.getTemporaryTransactionManagerMap());
|
||||||
|
|
||||||
|
// PostmanSchedulerService, DropBoxTaskExecutorService 는 @RequiredArgsConstructor 이기 때문에 자동으로 injection 된다
|
||||||
|
// 그 후 @PostConstruct 로직이 실행될 것이다.
|
||||||
|
log.debug("BeanInitializer afterSingletonsInstantiated [run]");
|
||||||
|
log.debug("{} ready", postmanSchedulerService.getClass().getName());
|
||||||
|
log.debug("{} ready", dropBoxTaskExecutorService.getClass().getName());
|
||||||
|
//TODO 4. Worker 쓰레드 생성
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
package com.bsmlab.dfx.agent.event;
|
||||||
|
|
||||||
|
import com.bsmlab.dfx.agent.config.DfxAgentConfiguration;
|
||||||
|
import com.bsmlab.dfx.agent.config.datasource.DynamicDataSourceService;
|
||||||
|
import com.bsmlab.dfx.agent.task.dropbox.DropBoxTaskExecutorService;
|
||||||
|
import com.bsmlab.dfx.agent.task.postman.PostmanSchedulerService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.context.ApplicationListener;
|
||||||
|
import org.springframework.context.event.ContextRefreshedEvent;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ContextReadyListener implements ApplicationListener<ContextRefreshedEvent> {
|
||||||
|
private final DfxAgentConfiguration dfxAgentConfiguration;
|
||||||
|
private final DynamicDataSourceService dynamicDataSourceService;
|
||||||
|
private final PostmanSchedulerService postmanSchedulerService;
|
||||||
|
private final DropBoxTaskExecutorService dropBoxTaskExecutorService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||||
|
System.out.println("🔥 ContextReadyListener onApplicationEvent() 진입!");
|
||||||
|
log.info("✅ ContextReadyListener 작동 확인");
|
||||||
|
/*
|
||||||
|
// DfxAgentConfiguration 에서 생성한 빈 중 DataSource 관련 설정을 마무리한다.
|
||||||
|
dynamicDataSourceService.setSqlSessionFactoryMap(dfxAgentConfiguration.getTemporarySqlSessionFactoryMap());
|
||||||
|
dynamicDataSourceService.setTransactionManagerMap(dfxAgentConfiguration.getTemporaryTransactionManagerMap());
|
||||||
|
|
||||||
|
// PostmanSchedulerService, DropBoxTaskExecutorService 는 @RequiredArgsConstructor 이기 때문에 자동으로 injection 된다
|
||||||
|
// 그 후 @PostConstruct 로직이 실행될 것이다.
|
||||||
|
log.debug("ContextReadyListener onApplicationEvent [run]");
|
||||||
|
log.debug("{} ready", postmanSchedulerService.getClass().getName());
|
||||||
|
log.debug("{} ready", dropBoxTaskExecutorService.getClass().getName());
|
||||||
|
//TODO 4. Worker 쓰레드 생성
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsAsyncExecution() {
|
||||||
|
return ApplicationListener.super.supportsAsyncExecution();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in new issue