diff --git a/src/main/java/com/loafle/overflow/container/service/Service.java b/src/main/java/com/loafle/overflow/container/service/Service.java index f7ed6d4..b93abbf 100644 --- a/src/main/java/com/loafle/overflow/container/service/Service.java +++ b/src/main/java/com/loafle/overflow/container/service/Service.java @@ -18,45 +18,42 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; import org.springframework.core.annotation.AnnotationUtils; +import org.springframework.stereotype.Component; /** * Service */ -@Configuration +@Component public class Service implements InitializingBean, ApplicationContextAware { private static final Logger logger = LoggerFactory.getLogger(Service.class); + public static final Class[] OrderedServices = { + ContainerProbeService.class, + ContainerSensorConfigService.class, + ContainerCrawlerService.class, + }; + private ApplicationContext applicationContext; @Autowired @Qualifier(Container.RPC_REGISTRY) private RPCRegistry rpcRegistry; - @Autowired - @Qualifier(Container.SERVICES) - private Map services; - @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } - @Bean(Container.SERVICES) - public Map services() { - return this.applicationContext.getBeansWithAnnotation(RPCService.class); - } - @Override public void afterPropertiesSet() throws Exception { - if (null == this.services || 0 == this.services.size()) { + Map services = this.applicationContext.getBeansWithAnnotation(RPCService.class); + if (null == services || 0 == services.size()) { logger.debug("there is not service"); return; } - this.services.forEach((name, bean) -> { + services.forEach((name, bean) -> { this.registerRPCService(bean, name); }); }