|
@@ -4,10 +4,15 @@
|
|
|
package org.dbsyncer.parser;
|
|
|
|
|
|
import org.dbsyncer.parser.flush.impl.TableGroupBufferActuator;
|
|
|
+import org.dbsyncer.sdk.spi.TableGroupBufferActuatorService;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
|
+import java.util.ServiceLoader;
|
|
|
+
|
|
|
/**
|
|
|
* @Author AE86
|
|
|
* @Version 1.0.0
|
|
@@ -16,9 +21,23 @@ import org.springframework.context.annotation.Configuration;
|
|
|
@Configuration
|
|
|
public class ParserSupportConfiguration {
|
|
|
|
|
|
+ private final Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
+
|
|
|
@Bean
|
|
|
@ConditionalOnMissingBean
|
|
|
public TableGroupBufferActuator tableGroupBufferActuator() {
|
|
|
+ ServiceLoader<TableGroupBufferActuatorService> services = ServiceLoader.load(TableGroupBufferActuatorService.class, Thread.currentThread().getContextClassLoader());
|
|
|
+ for (TableGroupBufferActuatorService s : services) {
|
|
|
+ try {
|
|
|
+ TableGroupBufferActuatorService service = s.getClass().newInstance();
|
|
|
+ if (service instanceof TableGroupBufferActuator) {
|
|
|
+ return (TableGroupBufferActuator) service;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
+ throw new ParserException("获取TableGroupBufferActuator异常.");
|
|
|
+ }
|
|
|
+ }
|
|
|
return new TableGroupBufferActuator();
|
|
|
}
|
|
|
}
|