|
@@ -2,50 +2,140 @@
|
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
|
xmlns:th="http://www.thymeleaf.org" lang="zh-CN">
|
|
xmlns:th="http://www.thymeleaf.org" lang="zh-CN">
|
|
|
|
|
|
-<div class="container">
|
|
|
|
- <form id="uploadForm" class="form-horizontal" role="form">
|
|
|
|
|
|
+<div class="container-fluid">
|
|
|
|
+ <div class="row">
|
|
|
|
+ <div class="col-md-12">
|
|
|
|
+ <!-- 插件文档 -->
|
|
|
|
+ <div class="col-md-5">
|
|
|
|
+ <blockquote>
|
|
|
|
+ <p>插件有什么用?</p>
|
|
|
|
+ <small class="text-muted">插件是一种可扩展全量同步和增量同步实现数据转换的技术方式。通过插件可以接收同步数据,自定义同步到目标源的行数据,也能消费数据并实现更多业务场景。</small>
|
|
|
|
+ </blockquote>
|
|
|
|
|
|
- <div class="page-header">
|
|
|
|
- <h3>上传插件 <small>只支持 "jar" 的文件扩展名.</small></h3>
|
|
|
|
- </div>
|
|
|
|
|
|
+ <p>如何开发插件?</p>
|
|
|
|
+ <ol>
|
|
|
|
+ <li>新建java或maven工程,比如app</li>
|
|
|
|
+ <li>导入开发包:
|
|
|
|
+ <ul>
|
|
|
|
+ <li>方式1:导入jar <a onClick="downLoad()" href="javascript:;" title="下载开发包">dbsyncer-common-[[${version}]].jar</a></li>
|
|
|
|
+ <li>方式2:引入pom(需要安装到本地)
|
|
|
|
+ <pre><dependency><br/> <groupId>org.ghi</groupId><br/> <artifactId>dbsyncer-common</artifactId><br/> <version>[[${version}]]</version><br/></dependency></pre>
|
|
|
|
+ </li>
|
|
|
|
+ </ul>
|
|
|
|
+ </li>
|
|
|
|
+ <li>
|
|
|
|
+ <simple>新建一个类,比如MyPlugin,实现接口ConvertService方法</simple>
|
|
|
|
+ <pre>
|
|
|
|
+package org.test;
|
|
|
|
+
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+public class MyPlugin implements ConvertService{
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 全量同步
|
|
|
|
+ *
|
|
|
|
+ * @param source 数据源
|
|
|
|
+ * @param target 目标源
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void convert(List<Map> source, List<Map> target) {
|
|
|
|
+ // TODO 消费或处理数据
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 增量同步
|
|
|
|
+ *
|
|
|
|
+ * @param event 事件(INSERT/UPDATE/DELETE)
|
|
|
|
+ * @param source 数据源
|
|
|
|
+ * @param target 目标源
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void convert(String event, Map source, Map target) {
|
|
|
|
+ // TODO 消费或处理数据
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 重写方法:设置版本号
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String getVersion() {
|
|
|
|
+ return "1.0.0";
|
|
|
|
+ }
|
|
|
|
|
|
- <div class="form-group">
|
|
|
|
- <div class="file-loading">
|
|
|
|
- <input id="filePlugin" type="file" name="files" multiple="multiple" />
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 重写方法:设置插件名称
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String getName() {
|
|
|
|
+ return "MyPlugin";
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+ </pre>
|
|
|
|
+ </li>
|
|
|
|
+ <li>
|
|
|
|
+ <simple>/META-INF/新建services文件夹,并在services下新建一个文件,命名为org.dbsyncer.common.spi.ConvertService,文件写入实现类路径org.test.MyPlugin,如果有多个实现就换行再写入</simple>
|
|
|
|
+ <p><img th:src="@{'/img/plugin/spi.png'}"></p>
|
|
|
|
+ </li>
|
|
|
|
+ <li>
|
|
|
|
+ <simple>打包jar</simple>
|
|
|
|
+ <p><img th:src="@{'/img/plugin/jar.png'}"></p>
|
|
|
|
+ </li>
|
|
|
|
+ </ol>
|
|
</div>
|
|
</div>
|
|
- </div>
|
|
|
|
|
|
|
|
- <div class="form-group">
|
|
|
|
- <table class="table table-hover">
|
|
|
|
- <caption>插件列表([[${plugins?.size()} ?: 0]])</caption>
|
|
|
|
- <thead>
|
|
|
|
- <tr>
|
|
|
|
- <th>名称</th>
|
|
|
|
- <th>类名</th>
|
|
|
|
- <th>版本</th>
|
|
|
|
- <th>文件</th>
|
|
|
|
- <th>操作</th>
|
|
|
|
- </tr>
|
|
|
|
- </thead>
|
|
|
|
- <tbody id="pluginList">
|
|
|
|
- <tr th:id="${p?.name}" th:each="p,state : ${plugins}">
|
|
|
|
- <td th:text="${p?.name}"/>
|
|
|
|
- <td th:text="${p?.className}"/>
|
|
|
|
- <td th:text="${p?.version}"/>
|
|
|
|
- <td th:text="${p?.fileName}"/>
|
|
|
|
- <td><a th:id="${p?.name}" class='fa fa-remove fa-2x pluginDelete dbsyncer_pointer' title='暂不支持' aria-disabled="true"></a></td>
|
|
|
|
- </tr>
|
|
|
|
- </tbody>
|
|
|
|
- </table>
|
|
|
|
|
|
+ <!-- 插件列表 -->
|
|
|
|
+ <div class="col-md-7">
|
|
|
|
+ <form id="uploadForm" class="form-horizontal" role="form">
|
|
|
|
+ <div class="page-header">
|
|
|
|
+ <h3>上传插件 <small>只支持 "jar" 的文件扩展名.</small></h3>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <div class="form-group">
|
|
|
|
+ <div class="file-loading">
|
|
|
|
+ <input id="filePlugin" type="file" name="files" multiple="multiple" />
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <div class="form-group">
|
|
|
|
+ <table class="table table-hover">
|
|
|
|
+ <caption>插件列表([[${plugins?.size()} ?: 0]])</caption>
|
|
|
|
+ <thead>
|
|
|
|
+ <tr>
|
|
|
|
+ <th>名称</th>
|
|
|
|
+ <th>类名</th>
|
|
|
|
+ <th>版本</th>
|
|
|
|
+ <th>文件</th>
|
|
|
|
+ <th>操作</th>
|
|
|
|
+ </tr>
|
|
|
|
+ </thead>
|
|
|
|
+ <tbody id="pluginList">
|
|
|
|
+ <tr th:id="${p?.name}" th:each="p,state : ${plugins}">
|
|
|
|
+ <td th:text="${p?.name}"/>
|
|
|
|
+ <td th:text="${p?.className}"/>
|
|
|
|
+ <td th:text="${p?.version}"/>
|
|
|
|
+ <td th:text="${p?.fileName}"/>
|
|
|
|
+ <td><a th:id="${p?.name}" class='fa fa-remove fa-2x pluginDelete dbsyncer_pointer' title='暂不支持' aria-disabled="true"></a></td>
|
|
|
|
+ </tr>
|
|
|
|
+ </tbody>
|
|
|
|
+ </table>
|
|
|
|
+ </div>
|
|
|
|
+ </form>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
- </form>
|
|
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<script type="text/javascript">
|
|
<script type="text/javascript">
|
|
$("#filePlugin").fileinput({
|
|
$("#filePlugin").fileinput({
|
|
theme: 'fas',
|
|
theme: 'fas',
|
|
language: 'zh',
|
|
language: 'zh',
|
|
- uploadUrl: '/upload/upload',
|
|
|
|
|
|
+ uploadUrl: $basePath + '/upload/upload',
|
|
enctype: 'multipart/form-data',
|
|
enctype: 'multipart/form-data',
|
|
removeFromPreviewOnError:true, //当选择的文件不符合规则时,例如不是指定后缀文件、大小超出配置等,选择的文件不会出现在预览框中,只会显示错误信息
|
|
removeFromPreviewOnError:true, //当选择的文件不符合规则时,例如不是指定后缀文件、大小超出配置等,选择的文件不会出现在预览框中,只会显示错误信息
|
|
allowedFileExtensions: ['jar'],
|
|
allowedFileExtensions: ['jar'],
|
|
@@ -60,5 +150,9 @@
|
|
}
|
|
}
|
|
doLoader("/upload");
|
|
doLoader("/upload");
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ function downLoad(){
|
|
|
|
+ window.open($basePath + "/upload/download");
|
|
|
|
+ }
|
|
</script>
|
|
</script>
|
|
</html>
|
|
</html>
|