Skip to content

Commit c3fa416

Browse files
committed
优化基础类的各种 init 方法及统一 creator 赋值;日志中不再打印 dbAccount 和 dbPassword;apijson-orm 改为用 Tencent/APIJSON 的库
1 parent 4af18d9 commit c3fa416

11 files changed

+197
-150
lines changed

.classpath

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
<attribute name="maven.pomderived" value="true"/>
2828
</attributes>
2929
</classpathentry>
30-
<classpathentry kind="lib" path="libs/apijson-orm-4.2.3.jar"/>
31-
<classpathentry kind="lib" path="libs/unitauto-2.5.0.jar"/>
32-
<classpathentry kind="lib" path="libs/unitauto-jar-2.5.0.jar"/>
30+
<classpathentry kind="lib" path="libs/apijson-orm-4.2.4.jar"/>
3331
<classpathentry kind="output" path="target/classes"/>
3432
</classpath>

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
1414
hs_err_pid*
1515
/target/
16+
bin

libs/apijson-orm-4.2.4.jar

267 KB
Binary file not shown.

pom.xml

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>apijson.framework</groupId>
77
<artifactId>apijson-framework</artifactId>
8-
<version>4.3.3</version>
8+
<version>4.4.0</version>
99
<packaging>jar</packaging>
1010

1111
<name>APIJSONFramework</name>
@@ -18,35 +18,22 @@
1818
</properties>
1919

2020
<dependencies>
21+
<!-- 可使用 libs 目录的 apijson-orm.jar 来替代,两种方式二选一 -->
2122
<dependency>
22-
<groupId>com.alibaba</groupId>
23-
<artifactId>fastjson</artifactId>
24-
<version>1.2.73</version>
25-
</dependency>
26-
<dependency>
27-
<groupId>com.github.APIJSON</groupId>
28-
<artifactId>apijson-orm</artifactId>
29-
<version>4.2.3</version>
30-
</dependency>
31-
<!-- 可使用 libs 目录的 unitauto-java.jar 和 unitauto-jar.jar 本地 jar 包依赖来替代,两种方式二选一 -->
32-
<dependency>
33-
<groupId>com.github.TommyLemon</groupId>
34-
<artifactId>unitauto-java</artifactId>
35-
<version>2.5.3</version>
36-
</dependency>
37-
<dependency>
38-
<groupId>com.github.TommyLemon</groupId>
39-
<artifactId>unitauto-jar</artifactId>
40-
<version>2.5.3</version>
23+
<groupId>com.github.Tencent</groupId>
24+
<artifactId>APIJSON</artifactId>
25+
<version>4.2.4</version>
4126
</dependency>
27+
28+
4229
<dependency>
4330
<groupId>javax.servlet</groupId>
4431
<artifactId>javax.servlet-api</artifactId>
4532
<version>4.0.1</version>
4633
</dependency>
4734

4835

49-
<!-- 数据库 JDBC 驱动 <<<<<<<<<<< -->
36+
<!-- 数据库 JDBC 驱动 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -->
5037
<dependency>
5138
<groupId>mysql</groupId>
5239
<artifactId>mysql-connector-java</artifactId>
@@ -62,7 +49,22 @@
6249
<artifactId>jtds</artifactId>
6350
<version>1.3.1</version>
6451
</dependency>
65-
<!-- 数据库 JDBC 驱动 >>>>>>>>>>>> -->
52+
<!-- 没找到合适且稳定的 Oracle 的 JDBC Maven 依赖,需要自行下载 jar 包 -->
53+
<!-- 数据库 JDBC 驱动 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -->
54+
55+
56+
<!-- 单元测试:可使用 libs 目录的 unitauto-java.jar 和 unitauto-jar.jar 来替代,两种方式二选一 <<<<<<<<< -->
57+
<dependency>
58+
<groupId>com.github.TommyLemon</groupId>
59+
<artifactId>unitauto-java</artifactId>
60+
<version>2.5.3</version>
61+
</dependency>
62+
<dependency>
63+
<groupId>com.github.TommyLemon</groupId>
64+
<artifactId>unitauto-jar</artifactId>
65+
<version>2.5.3</version>
66+
</dependency>
67+
<!-- 单元测试:可使用 libs 目录的 unitauto-java.jar 和 unitauto-jar.jar 来替代,两种方式二选一 >>>>>>>>> -->
6668

6769
</dependencies>
6870

@@ -80,6 +82,7 @@
8082
</build>
8183

8284
<repositories>
85+
<!-- APIJSON 必须用到的托管平台 -->
8386
<repository>
8487
<id>jitpack.io</id>
8588
<url>https://jitpack.io</url>

src/main/java/apijson/framework/APIJSONApplication.java

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
package apijson.framework;
1616

17+
import java.rmi.ServerException;
18+
1719
import apijson.NotNull;
18-
import apijson.orm.ParserCreator;
19-
import apijson.orm.SQLCreator;
2020

2121

2222
/**SpringBootApplication
@@ -32,31 +32,47 @@ public class APIJSONApplication {
3232
}
3333

3434

35-
public static void init() throws Exception {
36-
init(true);
37-
}
38-
public static void init(boolean shutdownWhenServerError) throws Exception {
39-
init(shutdownWhenServerError, null, null);
35+
/**初始化,加载所有配置并校验
36+
* @return
37+
* @throws ServerException
38+
*/
39+
public static void init() throws ServerException {
40+
init(true, DEFAULT_APIJSON_CREATOR);
4041
}
41-
public static void init(APIJSONCreator creator) throws Exception {
42-
init(false, creator);
42+
/**初始化,加载所有配置并校验
43+
* @param shutdownWhenServerError
44+
* @return
45+
* @throws ServerException
46+
*/
47+
public static void init(boolean shutdownWhenServerError) throws ServerException {
48+
init(shutdownWhenServerError, DEFAULT_APIJSON_CREATOR);
4349
}
44-
public static void init(boolean shutdownWhenServerError, APIJSONCreator creator) throws Exception {
45-
init(shutdownWhenServerError, creator, creator);
50+
/**初始化,加载所有配置并校验
51+
* @param creator
52+
* @return
53+
* @throws ServerException
54+
*/
55+
public static void init(@NotNull APIJSONCreator creator) throws ServerException {
56+
init(true, creator);
4657
}
47-
public static void init(boolean shutdownWhenServerError, ParserCreator<Long> parserCreator, SQLCreator sqlCreator) throws Exception {
58+
/**初始化,加载所有配置并校验
59+
* @param shutdownWhenServerError
60+
* @param creator
61+
* @return
62+
* @throws ServerException
63+
*/
64+
public static void init(boolean shutdownWhenServerError, @NotNull APIJSONCreator creator) throws ServerException {
4865
System.out.println("\n\n\n\n\n<<<<<<<<<<<<<<<<<<<<<<<<< APIJSON 开始启动 >>>>>>>>>>>>>>>>>>>>>>>>\n");
66+
DEFAULT_APIJSON_CREATOR = creator;
4967

50-
if (parserCreator == null) {
51-
parserCreator = DEFAULT_APIJSON_CREATOR;
52-
}
53-
if (sqlCreator == null) {
54-
sqlCreator = DEFAULT_APIJSON_CREATOR;
55-
}
68+
// 统一用同一个 creator
69+
APIJSONSQLConfig.APIJSON_CREATOR = creator;
70+
APIJSONParser.APIJSON_CREATOR = creator;
71+
APIJSONController.APIJSON_CREATOR = creator;
5672

5773
System.out.println("\n\n\n开始初始化:远程函数配置 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
5874
try {
59-
APIJSONFunctionParser.init(shutdownWhenServerError, parserCreator);
75+
APIJSONFunctionParser.init(shutdownWhenServerError, creator);
6076
}
6177
catch (Exception e) {
6278
e.printStackTrace();
@@ -76,7 +92,7 @@ public static void init(boolean shutdownWhenServerError, ParserCreator<Long> par
7692

7793
System.out.println("\n\n\n开始初始化:请求校验配置 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
7894
try {
79-
StructureUtil.init(shutdownWhenServerError, parserCreator);
95+
StructureUtil.init(shutdownWhenServerError, creator);
8096
}
8197
catch (Exception e) {
8298
e.printStackTrace();
@@ -85,7 +101,7 @@ public static void init(boolean shutdownWhenServerError, ParserCreator<Long> par
85101

86102
System.out.println("\n\n\n开始测试:请求校验 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
87103
try {
88-
StructureUtil.test(sqlCreator);
104+
StructureUtil.test();
89105
}
90106
catch (Exception e) {
91107
e.printStackTrace();
@@ -96,7 +112,7 @@ public static void init(boolean shutdownWhenServerError, ParserCreator<Long> par
96112

97113
System.out.println("\n\n\n开始初始化:权限校验配置 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
98114
try {
99-
APIJSONVerifier.init(shutdownWhenServerError, parserCreator);
115+
APIJSONVerifier.init(shutdownWhenServerError, creator);
100116
}
101117
catch (Exception e) {
102118
e.printStackTrace();

src/main/java/apijson/framework/APIJSONController.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,16 @@
5959
*/
6060
public class APIJSONController {
6161
public static final String TAG = "APIJSONController";
62+
63+
@NotNull
64+
public static APIJSONCreator APIJSON_CREATOR;
65+
static {
66+
APIJSON_CREATOR = new APIJSONCreator();
67+
}
68+
6269

6370
public Parser<Long> newParser(HttpSession session, RequestMethod method) {
64-
Parser<Long> parser = APIJSONApplication.DEFAULT_APIJSON_CREATOR.createParser();
71+
Parser<Long> parser = APIJSON_CREATOR.createParser();
6572
parser.setMethod(method);
6673
if (parser instanceof APIJSONParser) {
6774
((APIJSONParser) parser).setSession(session);

0 commit comments

Comments
 (0)