Skip to content

Commit 2f061b3

Browse files
committed
重构插件加载逻辑(移到 PluginLoader);升级 dom4j 版本
1 parent 1c4b3ca commit 2f061b3

6 files changed

Lines changed: 235 additions & 175 deletions

File tree

pom.xml

Lines changed: 129 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,136 +1,129 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3-
<modelVersion>4.0.0</modelVersion>
4-
5-
<groupId>com.xwintop</groupId>
6-
<artifactId>xJavaFxTool</artifactId>
7-
<version>0.2.0</version>
8-
<packaging>jar</packaging>
9-
<name>xJavaFxTool</name>
10-
<description>基于JavaFx搭建的实用小工具集合</description>
11-
<url>https://gitee.com/xwintop/xJavaFxTool</url>
12-
13-
<!-- <parent>-->
14-
<!-- <groupId>org.springframework.boot</groupId>-->
15-
<!-- <artifactId>spring-boot-starter-parent</artifactId>-->
16-
<!-- <version>2.1.3.RELEASE</version>-->
17-
<!-- </parent>-->
18-
19-
<properties>
20-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21-
<maven.test.skip>true</maven.test.skip>
22-
<maven.compiler.source>1.8</maven.compiler.source>
23-
<maven.compiler.target>1.8</maven.compiler.target>
24-
</properties>
25-
<repositories>
26-
<repository>
27-
<id>aliyunmaven</id>
28-
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
29-
</repository>
30-
<repository>
31-
<id>xwintop-maven</id>
32-
<url>https://xwintop.gitee.io/maven/repository</url>
33-
</repository>
34-
<repository>
35-
<id>spring-snapshots</id>
36-
<url>http://repo.spring.io/snapshot</url>
37-
<snapshots>
38-
<enabled>true</enabled>
39-
</snapshots>
40-
</repository>
41-
<repository>
42-
<id>spring-milestones</id>
43-
<url>http://repo.spring.io/milestone</url>
44-
</repository>
45-
</repositories>
46-
<dependencies>
47-
<dependency>
48-
<groupId>junit</groupId>
49-
<artifactId>junit</artifactId>
50-
<version>4.12</version>
51-
<scope>test</scope>
52-
</dependency>
53-
<!-- <dependency>
54-
<groupId>com.xwintop</groupId>
55-
<artifactId>xcore</artifactId>
56-
<version>0.0.1-SNAPSHOT</version>
57-
<scope>system</scope>
58-
<systemPath>${project.basedir}/lib/xcore-0.0.1-SNAPSHOT.jar</systemPath>
59-
</dependency> -->
60-
<dependency>
61-
<groupId>com.xwintop</groupId>
62-
<artifactId>xcore</artifactId>
63-
<version>0.0.3-SNAPSHOT</version>
64-
</dependency>
65-
66-
<!-- oshi获取系统信息工具 -->
67-
<dependency>
68-
<groupId>com.github.oshi</groupId>
69-
<artifactId>oshi-core</artifactId>
70-
<version>3.9.1</version>
71-
</dependency>
72-
73-
</dependencies>
74-
<build>
75-
<plugins>
76-
<plugin>
77-
<groupId>org.apache.maven.plugins</groupId>
78-
<artifactId>maven-assembly-plugin</artifactId>
79-
<version>2.5.5</version>
80-
<configuration>
81-
<finalName>xJavaFxTool</finalName>
82-
<appendAssemblyId>false</appendAssemblyId>
83-
<encoding>utf-8</encoding>
84-
<archive>
85-
<manifest>
86-
<mainClass>com.xwintop.xJavaFxTool.Main</mainClass>
87-
</manifest>
88-
</archive>
89-
<descriptorRefs>
90-
<descriptorRef>jar-with-dependencies</descriptorRef>
91-
</descriptorRefs>
92-
</configuration>
93-
<executions>
94-
<execution>
95-
<id>make-assembly</id>
96-
<phase>package</phase>
97-
<goals>
98-
<goal>single</goal>
99-
</goals>
100-
</execution>
101-
</executions>
102-
</plugin>
103-
<plugin>
104-
<groupId>com.zenjava</groupId>
105-
<artifactId>javafx-maven-plugin</artifactId>
106-
<version>8.8.3</version>
107-
<configuration>
108-
<mainClass>com.xwintop.xJavaFxTool.Main</mainClass>
109-
<vendor>xwintop</vendor>
110-
<appName>xJavaFxTool</appName>
111-
</configuration>
112-
</plugin>
113-
<!-- 生成javadoc文档包的插件 -->
114-
<plugin>
115-
<groupId>org.apache.maven.plugins</groupId>
116-
<artifactId>maven-javadoc-plugin</artifactId>
117-
<version>3.1.1</version>
118-
<configuration>
119-
<show>private</show>
120-
<nohelp>true</nohelp>
121-
<additionalOptions>
122-
<additionalOption>-Xdoclint:none</additionalOption>
123-
</additionalOptions>
124-
</configuration>
125-
<executions>
126-
<execution>
127-
<id>attach-javadocs</id>
128-
<goals>
129-
<goal>jar</goal>
130-
</goals>
131-
</execution>
132-
</executions>
133-
</plugin>
134-
</plugins>
135-
</build>
136-
</project>
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>com.xwintop</groupId>
6+
<artifactId>xJavaFxTool</artifactId>
7+
<version>0.2.0</version>
8+
<packaging>jar</packaging>
9+
<name>xJavaFxTool</name>
10+
<description>基于JavaFx搭建的实用小工具集合</description>
11+
<url>https://gitee.com/xwintop/xJavaFxTool</url>
12+
13+
<!-- <parent>-->
14+
<!-- <groupId>org.springframework.boot</groupId>-->
15+
<!-- <artifactId>spring-boot-starter-parent</artifactId>-->
16+
<!-- <version>2.1.3.RELEASE</version>-->
17+
<!-- </parent>-->
18+
19+
<properties>
20+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21+
<maven.test.skip>true</maven.test.skip>
22+
<maven.compiler.source>1.8</maven.compiler.source>
23+
<maven.compiler.target>1.8</maven.compiler.target>
24+
</properties>
25+
<repositories>
26+
<repository>
27+
<id>aliyunmaven</id>
28+
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
29+
</repository>
30+
<repository>
31+
<id>xwintop-maven</id>
32+
<url>https://xwintop.gitee.io/maven/repository</url>
33+
</repository>
34+
<repository>
35+
<id>spring-snapshots</id>
36+
<url>http://repo.spring.io/snapshot</url>
37+
<snapshots>
38+
<enabled>true</enabled>
39+
</snapshots>
40+
</repository>
41+
<repository>
42+
<id>spring-milestones</id>
43+
<url>http://repo.spring.io/milestone</url>
44+
</repository>
45+
</repositories>
46+
<dependencies>
47+
<dependency>
48+
<groupId>junit</groupId>
49+
<artifactId>junit</artifactId>
50+
<version>4.12</version>
51+
<scope>test</scope>
52+
</dependency>
53+
<dependency>
54+
<groupId>com.xwintop</groupId>
55+
<artifactId>xcore</artifactId>
56+
<version>0.0.3-SNAPSHOT</version>
57+
</dependency>
58+
59+
<!-- oshi获取系统信息工具 -->
60+
<dependency>
61+
<groupId>com.github.oshi</groupId>
62+
<artifactId>oshi-core</artifactId>
63+
<version>3.9.1</version>
64+
</dependency>
65+
66+
</dependencies>
67+
<build>
68+
<plugins>
69+
<plugin>
70+
<groupId>org.apache.maven.plugins</groupId>
71+
<artifactId>maven-assembly-plugin</artifactId>
72+
<version>2.5.5</version>
73+
<configuration>
74+
<finalName>xJavaFxTool</finalName>
75+
<appendAssemblyId>false</appendAssemblyId>
76+
<encoding>utf-8</encoding>
77+
<archive>
78+
<manifest>
79+
<mainClass>com.xwintop.xJavaFxTool.Main</mainClass>
80+
</manifest>
81+
</archive>
82+
<descriptorRefs>
83+
<descriptorRef>jar-with-dependencies</descriptorRef>
84+
</descriptorRefs>
85+
</configuration>
86+
<executions>
87+
<execution>
88+
<id>make-assembly</id>
89+
<phase>package</phase>
90+
<goals>
91+
<goal>single</goal>
92+
</goals>
93+
</execution>
94+
</executions>
95+
</plugin>
96+
<plugin>
97+
<groupId>com.zenjava</groupId>
98+
<artifactId>javafx-maven-plugin</artifactId>
99+
<version>8.8.3</version>
100+
<configuration>
101+
<mainClass>com.xwintop.xJavaFxTool.Main</mainClass>
102+
<vendor>xwintop</vendor>
103+
<appName>xJavaFxTool</appName>
104+
</configuration>
105+
</plugin>
106+
<!-- 生成javadoc文档包的插件 -->
107+
<plugin>
108+
<groupId>org.apache.maven.plugins</groupId>
109+
<artifactId>maven-javadoc-plugin</artifactId>
110+
<version>3.1.1</version>
111+
<configuration>
112+
<show>private</show>
113+
<nohelp>true</nohelp>
114+
<additionalOptions>
115+
<additionalOption>-Xdoclint:none</additionalOption>
116+
</additionalOptions>
117+
</configuration>
118+
<executions>
119+
<execution>
120+
<id>attach-javadocs</id>
121+
<goals>
122+
<goal>jar</goal>
123+
</goals>
124+
</execution>
125+
</executions>
126+
</plugin>
127+
</plugins>
128+
</build>
129+
</project>

src/main/java/com/xwintop/xJavaFxTool/controller/IndexController.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,10 @@
4343
import org.apache.commons.beanutils.BeanUtils;
4444
import org.apache.commons.lang.StringUtils;
4545
import org.apache.commons.lang3.time.DateFormatUtils;
46+
import org.dom4j.Attribute;
4647
import org.dom4j.Document;
4748
import org.dom4j.Element;
4849
import org.dom4j.io.SAXReader;
49-
import org.dom4j.tree.DefaultAttribute;
50-
import org.dom4j.tree.DefaultElement;
5150

5251
/**
5352
* @ClassName: IndexController
@@ -143,12 +142,12 @@ public void addToolMenu(File file) throws Exception {
143142
List<Element> elements = root.elements("ToolFxmlLoaderConfiguration");
144143
for (Element configurationNode : elements) {
145144
ToolFxmlLoaderConfiguration toolFxmlLoaderConfiguration = new ToolFxmlLoaderConfiguration();
146-
List<DefaultAttribute> attributes = configurationNode.attributes();
147-
for (DefaultAttribute configuration : attributes) {
145+
List<Attribute> attributes = configurationNode.attributes();
146+
for (Attribute configuration : attributes) {
148147
BeanUtils.copyProperty(toolFxmlLoaderConfiguration, configuration.getName(), configuration.getValue());
149148
}
150-
List<DefaultElement> childrenList = configurationNode.elements();
151-
for (DefaultElement configuration : childrenList) {
149+
List<Element> childrenList = configurationNode.elements();
150+
for (Element configuration : childrenList) {
152151
BeanUtils.copyProperty(toolFxmlLoaderConfiguration, configuration.getName(), configuration.getStringValue());
153152
}
154153
if (StringUtils.isEmpty(toolFxmlLoaderConfiguration.getMenuParentId())) {

src/main/java/com/xwintop/xJavaFxTool/model/PluginJarInfo.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@Data
1313
public class PluginJarInfo {
1414

15-
////////////////////////////////////////////////////////////// 下面的属性在远程插件列表和本地配置中都存在
15+
///////////////////////////////////////// 下面的属性在远程插件列表和本地配置中都存在
1616

1717
private String name; // 名称
1818

@@ -26,11 +26,32 @@ public class PluginJarInfo {
2626

2727
private String downloadUrl; // 下载地址
2828

29-
////////////////////////////////////////////////////////////// 下面的属性在远程插件列表中不存在
29+
///////////////////////////////////////// 下面的属性在远程插件列表中不存在
3030

3131
private Boolean isDownload; // 是否下载
3232

3333
private Boolean isEnable; // 是否启用
3434

35-
private Integer localVersionNumber; // 插件本地版本
35+
private Integer localVersionNumber; // 插件本地版本
36+
37+
///////////////////////////////////////// 下面的属性来自插件描述文件 toolFxmlLoaderConfiguration.xml
38+
39+
private String fxmlPath; // FXML 资源路径
40+
41+
private String iconPath; // 图标资源路径(可选)
42+
43+
private String bundleName; // 配置资源路径
44+
45+
private String className; // ?
46+
47+
private String menuId; // 菜单id
48+
49+
private String menuParentId; // 菜单父id
50+
51+
private Boolean isMenu = false; // 是否为菜单
52+
53+
private String title; // (Tab 页或窗体)标题
54+
55+
private String controllerType = "Node"; // 内容类型(Node/WebView)
56+
3657
}

0 commit comments

Comments
 (0)