diff --git a/tis-plugin-sezpoz/src/main/java/com/qlangtech/tis/extension/TISExtendsionInterceptor.java b/tis-plugin-sezpoz/src/main/java/com/qlangtech/tis/extension/TISExtendsionInterceptor.java index eac047134..db04dad6f 100644 --- a/tis-plugin-sezpoz/src/main/java/com/qlangtech/tis/extension/TISExtendsionInterceptor.java +++ b/tis-plugin-sezpoz/src/main/java/com/qlangtech/tis/extension/TISExtendsionInterceptor.java @@ -1,23 +1,25 @@ /** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.qlangtech.tis.extension; + + import net.java.sezpoz.impl.Indexer; import javax.annotation.processing.AbstractProcessor; @@ -37,7 +39,13 @@ import javax.tools.StandardLocation; import java.io.IOException; import java.io.ObjectOutputStream; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * 通过编译时期拦截扩展插件接口,将一些插件的元信息写入到 class compiler output目录当中去 @@ -81,7 +89,7 @@ public boolean process(Set annotations, RoundEnvironment FileObject out = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", Indexer.METAINF_ANNOTATIONS + FILE_EXTENDPOINTS ); - // System.out.println("create new res:" + out.getName()); + // System.out.println("create new res:" + out.getName()); try (ObjectOutputStream o = new ObjectOutputStream(out.openOutputStream())) { o.writeObject(extensionPoints); } @@ -164,10 +172,10 @@ public Void visitDeclared(DeclaredType t, Void aVoid) { TISExtensible extensible = t.asElement().getAnnotation(TISExtensible.class); extendPointMatch = extensible != null; if (extendPointMatch) { - extendPoint = t.toString(); + extendPoint = parseExtendPoint(t.toString()); } } else { - extendPoint = childtm.toString(); + extendPoint = parseExtendPoint(childtm.toString()); } // if (extendPointMatch) { // System.out.println(t + "----------->extendPointMatch:" + extendPointMatch + "t.getTypeArguments() size:" + t.getTypeArguments().size()); @@ -175,14 +183,33 @@ public Void visitDeclared(DeclaredType t, Void aVoid) { if (extendPointMatch) { for (TypeMirror p : t.getTypeArguments()) { - extendPoint = String.valueOf(p); - + extendPoint = parseExtendPoint(String.valueOf(p)); } } return null; } + } + private static final Pattern PATTERN_EXTEND_POINT = Pattern.compile("([\\w\\.]+?)(<\\S+?>)"); + + public static String parseExtendPoint(String rawExtendPoint) { + Matcher matcher = PATTERN_EXTEND_POINT.matcher(rawExtendPoint); + if (matcher.matches()) { + // 需要将类型中的范型部分去掉 + // : + /** + *

+             * 例如:
+             * com.qlangtech.tis.plugin.datax.common.AutoCreateTable
+             * 转化成:
+             * com.qlangtech.tis.plugin.datax.common.AutoCreateTable
+             * 
+             */
+            return matcher.group(1);
+        } else {
+            return rawExtendPoint;
+        }
     }
 
     @Override
diff --git a/tis-plugin-sezpoz/src/test/java/TestAll.java b/tis-plugin-sezpoz/src/test/java/TestAll.java
new file mode 100644
index 000000000..1dd27f882
--- /dev/null
+++ b/tis-plugin-sezpoz/src/test/java/TestAll.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.qlangtech.tis.extension.TestTISExtendsionInterceptor; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * + * @author: 百岁(baisui@qlangtech.com) + * @create: 2024-12-20 13:20 + **/ +public class TestAll extends TestCase { + + public static Test suite() { + TestSuite suite = new TestSuite(); + suite.addTestSuite(TestTISExtendsionInterceptor.class); + return suite; + } +} \ No newline at end of file diff --git a/tis-plugin-sezpoz/src/test/java/com/qlangtech/tis/extension/TestTISExtendsionInterceptor.java b/tis-plugin-sezpoz/src/test/java/com/qlangtech/tis/extension/TestTISExtendsionInterceptor.java new file mode 100644 index 000000000..725ede158 --- /dev/null +++ b/tis-plugin-sezpoz/src/test/java/com/qlangtech/tis/extension/TestTISExtendsionInterceptor.java @@ -0,0 +1,38 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.qlangtech.tis.extension; + +import junit.framework.TestCase; + +/** + * @author: 百岁(baisui@qlangtech.com) + * @create: 2024-12-20 13:15 + **/ +public class TestTISExtendsionInterceptor extends TestCase { + public void testParseExtendPoint() { + String rawExtendpoint = "com.qlangtech.tis.plugin.datax.common.AutoCreateTable"; + final String expectExtendpoint = "com.qlangtech.tis.plugin.datax.common.AutoCreateTable"; + String actualExtendpoint = TISExtendsionInterceptor.parseExtendPoint(rawExtendpoint); + + assertEquals(expectExtendpoint, actualExtendpoint); + + actualExtendpoint = TISExtendsionInterceptor.parseExtendPoint(expectExtendpoint); + assertEquals(expectExtendpoint, actualExtendpoint); + } +} diff --git a/tis-web-config/config.properties b/tis-web-config/config.properties index 29b1074dc..e2c258609 100644 --- a/tis-web-config/config.properties +++ b/tis-web-config/config.properties @@ -30,8 +30,8 @@ tis.datasource.type=derby tis.datasource.dbname=tis_console_db -assemble.host=192.168.28.119 -tis.host=192.168.28.119 +assemble.host=192.168.28.120 +tis.host=192.168.28.120