ing
This commit is contained in:
parent
952de14105
commit
5c82049f48
|
@ -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<String, Object> services;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@Bean(Container.SERVICES)
|
||||
public Map<String, Object> services() {
|
||||
return this.applicationContext.getBeansWithAnnotation(RPCService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
if (null == this.services || 0 == this.services.size()) {
|
||||
Map<String, Object> 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);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user