|
@@ -16,14 +16,11 @@ import org.dbsyncer.sdk.model.ConnectorConfig;
|
|
|
import org.dbsyncer.sdk.model.MetaInfo;
|
|
|
import org.dbsyncer.sdk.model.Table;
|
|
|
import org.dbsyncer.sdk.spi.ConnectorService;
|
|
|
-import org.springframework.beans.BeansException;
|
|
|
import org.springframework.beans.factory.DisposableBean;
|
|
|
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
|
|
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
|
|
-import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
@@ -40,7 +37,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|
|
* @Date 2019-09-18 23:30
|
|
|
*/
|
|
|
@Component
|
|
|
-public class ConnectorFactory implements BeanDefinitionRegistryPostProcessor, DisposableBean {
|
|
|
+public class ConnectorFactory implements DisposableBean {
|
|
|
|
|
|
private final Map<String, ConnectorInstance> pool = new ConcurrentHashMap<>();
|
|
|
|
|
@@ -48,8 +45,8 @@ public class ConnectorFactory implements BeanDefinitionRegistryPostProcessor, Di
|
|
|
|
|
|
private final Set<String> connectorTypes = new HashSet<>();
|
|
|
|
|
|
- @Override
|
|
|
- public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry beanDefinitionRegistry) throws BeansException {
|
|
|
+ @PostConstruct
|
|
|
+ private void init() {
|
|
|
ServiceLoader<ConnectorService> services = ServiceLoader.load(ConnectorService.class, Thread.currentThread().getContextClassLoader());
|
|
|
for (ConnectorService s : services) {
|
|
|
service.putIfAbsent(s.getConnectorType(), s);
|
|
@@ -57,11 +54,6 @@ public class ConnectorFactory implements BeanDefinitionRegistryPostProcessor, Di
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public void destroy() {
|
|
|
pool.values().forEach(this::disconnect);
|