From 0b055a3f554da3a934e79e88c4781705cbab5a21 Mon Sep 17 00:00:00 2001 From: renxue <auster_i@163.com> Date: 星期一, 24 十月 2022 11:40:26 +0800 Subject: [PATCH] 修改包下的类名 --- src/main/java/com/hz/canal/starter/factory/TransponderContainerFactory.java | 134 ++++++++++++++++++++++---------------------- 1 files changed, 67 insertions(+), 67 deletions(-) diff --git a/src/main/java/com/duxinglangzi/canal/starter/factory/TransponderContainerFactory.java b/src/main/java/com/hz/canal/starter/factory/TransponderContainerFactory.java similarity index 89% rename from src/main/java/com/duxinglangzi/canal/starter/factory/TransponderContainerFactory.java rename to src/main/java/com/hz/canal/starter/factory/TransponderContainerFactory.java index bc051cd..26b4ba7 100644 --- a/src/main/java/com/duxinglangzi/canal/starter/factory/TransponderContainerFactory.java +++ b/src/main/java/com/hz/canal/starter/factory/TransponderContainerFactory.java @@ -1,67 +1,67 @@ -package com.duxinglangzi.canal.starter.factory; - -import com.alibaba.otter.canal.client.CanalConnector; -import com.duxinglangzi.canal.starter.configuration.CanalAutoConfigurationProperties; -import com.duxinglangzi.canal.starter.configuration.CanalListenerEndpointRegistrar; -import com.duxinglangzi.canal.starter.container.DmlMessageTransponderContainer; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * @author wuqiong 2022/4/18 - * @description - */ -public class TransponderContainerFactory { - - private static final String CONTAINER_ID_PREFIX = "com.duxinglangzi.canal.starter.container.MessageTransponderContainer#"; - - - /** - * 灏嗘墍鏈夊緟娉ㄥ唽鐨勭鐐癸紝娉ㄥ唽鍒皊pring涓� - * - * @param beanFactory - * @param canalConfig - * @param registrars - * @return void - * @author wuqiong 2022-04-23 20:34 - */ - public static void registerListenerContainer( - ConfigurableListableBeanFactory beanFactory, CanalAutoConfigurationProperties canalConfig, - Set<CanalListenerEndpointRegistrar> registrars) { - if (registrars == null || registrars.isEmpty()) return; - if (canalConfig == null || canalConfig.getInstances().isEmpty()) return; - - for (Map.Entry<String, CanalAutoConfigurationProperties.EndpointInstance> endpointInstance : canalConfig.getInstances().entrySet()) { - if (beanFactory.containsBean(getContainerID(endpointInstance.getKey()))) continue; // 濡傛灉宸茬粡瀛樺湪鍒欎笉鍦ㄥ垱寤� - List<CanalListenerEndpointRegistrar> registrarList = new ArrayList<>(); - for (CanalListenerEndpointRegistrar registrar : registrars) { - registrar.checkParameter(canalConfig.getInstances().keySet()); - if (!registrar.isContainDestination(endpointInstance.getKey())) continue; - registrarList.add(registrar); - } - if (registrarList.isEmpty()) continue; - registerTransponderContainer( - endpointInstance.getKey(), endpointInstance.getValue(), beanFactory, registrarList); - } - - } - - private static void registerTransponderContainer( - String destination, CanalAutoConfigurationProperties.EndpointInstance endpointInstance, - ConfigurableListableBeanFactory beanFactory, List<CanalListenerEndpointRegistrar> registrarList) { - CanalConnector connector = CanalConnectorFactory.createConnector(destination, endpointInstance); - beanFactory.registerSingleton(getContainerID(destination), - new DmlMessageTransponderContainer(connector, registrarList, endpointInstance)); - } - - - private static String getContainerID(String destination) { - return CONTAINER_ID_PREFIX + "#" + destination; - } - - -} +package com.hz.canal.starter.factory; + +import com.alibaba.otter.canal.client.CanalConnector; +import com.hz.canal.starter.configuration.CanalAutoConfigurationProperties; +import com.hz.canal.starter.configuration.CanalListenerEndpointRegistrar; +import com.hz.canal.starter.container.DmlMessageTransponderContainer; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @author wuqiong 2022/4/18 + * @description + */ +public class TransponderContainerFactory { + + private static final String CONTAINER_ID_PREFIX = "com.duxinglangzi.canal.starter.container.MessageTransponderContainer#"; + + + /** + * 灏嗘墍鏈夊緟娉ㄥ唽鐨勭鐐癸紝娉ㄥ唽鍒皊pring涓� + * + * @param beanFactory + * @param canalConfig + * @param registrars + * @return void + * @author wuqiong 2022-04-23 20:34 + */ + public static void registerListenerContainer( + ConfigurableListableBeanFactory beanFactory, CanalAutoConfigurationProperties canalConfig, + Set<CanalListenerEndpointRegistrar> registrars) { + if (registrars == null || registrars.isEmpty()) return; + if (canalConfig == null || canalConfig.getInstances().isEmpty()) return; + + for (Map.Entry<String, CanalAutoConfigurationProperties.EndpointInstance> endpointInstance : canalConfig.getInstances().entrySet()) { + if (beanFactory.containsBean(getContainerID(endpointInstance.getKey()))) continue; // 濡傛灉宸茬粡瀛樺湪鍒欎笉鍦ㄥ垱寤� + List<CanalListenerEndpointRegistrar> registrarList = new ArrayList<>(); + for (CanalListenerEndpointRegistrar registrar : registrars) { + registrar.checkParameter(canalConfig.getInstances().keySet()); + if (!registrar.isContainDestination(endpointInstance.getKey())) continue; + registrarList.add(registrar); + } + if (registrarList.isEmpty()) continue; + registerTransponderContainer( + endpointInstance.getKey(), endpointInstance.getValue(), beanFactory, registrarList); + } + + } + + private static void registerTransponderContainer( + String destination, CanalAutoConfigurationProperties.EndpointInstance endpointInstance, + ConfigurableListableBeanFactory beanFactory, List<CanalListenerEndpointRegistrar> registrarList) { + CanalConnector connector = CanalConnectorFactory.createConnector(destination, endpointInstance); + beanFactory.registerSingleton(getContainerID(destination), + new DmlMessageTransponderContainer(connector, registrarList, endpointInstance)); + } + + + private static String getContainerID(String destination) { + return CONTAINER_ID_PREFIX + "#" + destination; + } + + +} -- Gitblit v1.8.0