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/configuration/CanalListenerEndpointRegistrar.java | 260 ++++++++++++++++++++++++++-------------------------- 1 files changed, 130 insertions(+), 130 deletions(-) diff --git a/src/main/java/com/duxinglangzi/canal/starter/configuration/CanalListenerEndpointRegistrar.java b/src/main/java/com/hz/canal/starter/configuration/CanalListenerEndpointRegistrar.java similarity index 97% rename from src/main/java/com/duxinglangzi/canal/starter/configuration/CanalListenerEndpointRegistrar.java rename to src/main/java/com/hz/canal/starter/configuration/CanalListenerEndpointRegistrar.java index 6dd0e43..a2144a9 100644 --- a/src/main/java/com/duxinglangzi/canal/starter/configuration/CanalListenerEndpointRegistrar.java +++ b/src/main/java/com/hz/canal/starter/configuration/CanalListenerEndpointRegistrar.java @@ -1,130 +1,130 @@ -package com.duxinglangzi.canal.starter.configuration; - -import com.alibaba.otter.canal.protocol.CanalEntry; -import com.alibaba.otter.canal.protocol.exception.CanalClientException; -import com.duxinglangzi.canal.starter.mode.CanalMessage; -import org.apache.commons.lang3.StringUtils; - -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -/** - * 鐩戝惉鐨勭粓绔敞鍐屽櫒 - * - * @author wuqiong 2022/4/11 - */ -public class CanalListenerEndpointRegistrar { - - private Object bean; - private Method method; - - /** - * 濡傛灉鏈繘琛岄厤缃紝鍒欎娇鐢ㄩ厤缃枃浠堕噷鍏ㄩ儴 destination - */ - private String destination; - - /** - * 鏁版嵁搴撳悕 - */ - private String database; - - /** - * 鏁版嵁琛ㄥ悕 - */ - private String[] table; - - /** - * 鏁版嵁鍙樺姩绫诲瀷锛屾澶勮娉ㄦ剰锛岄粯璁や笉鍖呭惈 DDL - */ - private CanalEntry.EventType[] eventType; - - /** - * 1銆佺洰鍓嶅疄鐜扮殑 DML 瑙f瀽鍣ㄤ粎鏀寔1涓弬鏁�, 璇ュ弬鏁板璞″唴鍖呭惈浜�: 搴撳悕銆佽〃鍚嶃�佷簨浠剁被鍨嬨�佸彉鏇寸殑鏁版嵁 <p> - * 2銆佹柟娉曞弬鏁板繀椤讳负: CanalMessage <p> - * 3銆佸鏋淐analListener 鎸囧畾鐨� destination 涓嶅湪閰嶇疆鏂囦欢鍐咃紝鍒欑洿鎺ユ姏閿� <p> - * - * @param sets - * @return void - * @author wuqiong 2022-04-23 20:27 - */ - public void checkParameter(Set<String> sets) { - List<Class<?>> classes = parameterTypes(); - if (classes.size() != 1 || classes.get(0) != CanalMessage.class) - throw new IllegalArgumentException("@CanalListener Method Parameter Type Invalid, " + - "Need Parameter Type [ com.duxinglangzi.canal.starter.mode.CanalMessage ] please check "); - if (StringUtils.isNotBlank(getDestination()) && !sets.contains(getDestination())) - throw new CanalClientException("@CanalListener Illegal destination " + getDestination() + ", please check "); - - } - - - public List<Class<?>> parameterTypes() { - return Arrays.stream(getMethod().getParameterTypes()).collect(Collectors.toList()); - } - - public boolean isContainDestination(String destination) { - if (StringUtils.isBlank(getDestination())) return true; - return getDestination().equals(destination); - } - - /** - * 杩囨护鍙傛暟 - * - * @param database - * @param tableName - * @param eventType - * @return java.util.function.Predicate - * @author wuqiong 2022-04-23 20:47 - */ - public static Predicate<CanalListenerEndpointRegistrar> filterArgs( - String database, String tableName, CanalEntry.EventType eventType) { - Predicate<CanalListenerEndpointRegistrar> databases = - e -> StringUtils.isBlank(e.getDatabase()) || e.getDatabase().equals(database); - Predicate<CanalListenerEndpointRegistrar> table = e -> e.getTable().length == 0 - || (e.getTable().length == 1 && "".equals(e.getTable()[0])) - || Arrays.stream(e.getTable()).anyMatch(s -> s.equals(tableName)); - Predicate<CanalListenerEndpointRegistrar> eventTypes = e -> e.getEventType().length == 0 - || Arrays.stream(e.getEventType()).anyMatch(eve -> eve == eventType); - return databases.and(table).and(eventTypes); - } - - - public CanalListenerEndpointRegistrar( - Object bean, Method method, String destination, - String database, String[] tables, CanalEntry.EventType[] eventTypes) { - this.bean = bean; - this.method = method; - this.destination = destination; - this.database = database; - this.table = tables; - this.eventType = eventTypes; - } - - public Object getBean() { - return bean; - } - - public Method getMethod() { - return method; - } - - public String getDestination() { - return destination; - } - - public String getDatabase() { - return database; - } - - public String[] getTable() { - return table; - } - - public CanalEntry.EventType[] getEventType() { - return eventType; - } -} +package com.hz.canal.starter.configuration; + +import com.alibaba.otter.canal.protocol.CanalEntry; +import com.alibaba.otter.canal.protocol.exception.CanalClientException; +import com.hz.canal.starter.mode.CanalMessage; +import org.apache.commons.lang3.StringUtils; + +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.List; +import java.util.Set; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +/** + * 鐩戝惉鐨勭粓绔敞鍐屽櫒 + * + * @author wuqiong 2022/4/11 + */ +public class CanalListenerEndpointRegistrar { + + private Object bean; + private Method method; + + /** + * 濡傛灉鏈繘琛岄厤缃紝鍒欎娇鐢ㄩ厤缃枃浠堕噷鍏ㄩ儴 destination + */ + private String destination; + + /** + * 鏁版嵁搴撳悕 + */ + private String database; + + /** + * 鏁版嵁琛ㄥ悕 + */ + private String[] table; + + /** + * 鏁版嵁鍙樺姩绫诲瀷锛屾澶勮娉ㄦ剰锛岄粯璁や笉鍖呭惈 DDL + */ + private CanalEntry.EventType[] eventType; + + /** + * 1銆佺洰鍓嶅疄鐜扮殑 DML 瑙f瀽鍣ㄤ粎鏀寔1涓弬鏁�, 璇ュ弬鏁板璞″唴鍖呭惈浜�: 搴撳悕銆佽〃鍚嶃�佷簨浠剁被鍨嬨�佸彉鏇寸殑鏁版嵁 <p> + * 2銆佹柟娉曞弬鏁板繀椤讳负: CanalMessage <p> + * 3銆佸鏋淐analListener 鎸囧畾鐨� destination 涓嶅湪閰嶇疆鏂囦欢鍐咃紝鍒欑洿鎺ユ姏閿� <p> + * + * @param sets + * @return void + * @author wuqiong 2022-04-23 20:27 + */ + public void checkParameter(Set<String> sets) { + List<Class<?>> classes = parameterTypes(); + if (classes.size() != 1 || classes.get(0) != CanalMessage.class) + throw new IllegalArgumentException("@CanalListener Method Parameter Type Invalid, " + + "Need Parameter Type [ com.duxinglangzi.canal.starter.mode.CanalMessage ] please check "); + if (StringUtils.isNotBlank(getDestination()) && !sets.contains(getDestination())) + throw new CanalClientException("@CanalListener Illegal destination " + getDestination() + ", please check "); + + } + + + public List<Class<?>> parameterTypes() { + return Arrays.stream(getMethod().getParameterTypes()).collect(Collectors.toList()); + } + + public boolean isContainDestination(String destination) { + if (StringUtils.isBlank(getDestination())) return true; + return getDestination().equals(destination); + } + + /** + * 杩囨护鍙傛暟 + * + * @param database + * @param tableName + * @param eventType + * @return java.util.function.Predicate + * @author wuqiong 2022-04-23 20:47 + */ + public static Predicate<CanalListenerEndpointRegistrar> filterArgs( + String database, String tableName, CanalEntry.EventType eventType) { + Predicate<CanalListenerEndpointRegistrar> databases = + e -> StringUtils.isBlank(e.getDatabase()) || e.getDatabase().equals(database); + Predicate<CanalListenerEndpointRegistrar> table = e -> e.getTable().length == 0 + || (e.getTable().length == 1 && "".equals(e.getTable()[0])) + || Arrays.stream(e.getTable()).anyMatch(s -> s.equals(tableName)); + Predicate<CanalListenerEndpointRegistrar> eventTypes = e -> e.getEventType().length == 0 + || Arrays.stream(e.getEventType()).anyMatch(eve -> eve == eventType); + return databases.and(table).and(eventTypes); + } + + + public CanalListenerEndpointRegistrar( + Object bean, Method method, String destination, + String database, String[] tables, CanalEntry.EventType[] eventTypes) { + this.bean = bean; + this.method = method; + this.destination = destination; + this.database = database; + this.table = tables; + this.eventType = eventTypes; + } + + public Object getBean() { + return bean; + } + + public Method getMethod() { + return method; + } + + public String getDestination() { + return destination; + } + + public String getDatabase() { + return database; + } + + public String[] getTable() { + return table; + } + + public CanalEntry.EventType[] getEventType() { + return eventType; + } +} -- Gitblit v1.8.0