Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
APIManager-Java/src/com/api/manager/Config.java at master · gdcpljh/APIManager-Java · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
gdcpljh
/
APIManager-Java
Public
Notifications
You must be signed in to change notification settings
Fork
1
Star
1
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
master
Breadcrumbs
APIManager-Java
/
src
/
com
/
api
/
manager
/
Config.java
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
275 lines (246 loc) · 7.94 KB
master
Breadcrumbs
APIManager-Java
/
src
/
com
/
api
/
manager
/
Config.java
Copy path
Top
File metadata and controls
Code
Blame
275 lines (246 loc) · 7.94 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
package
com
.
api
.
manager
;
import
java
.
awt
.
Font
;
import
java
.
io
.
BufferedReader
;
import
java
.
io
.
IOException
;
import
java
.
io
.
InputStream
;
import
java
.
io
.
InputStreamReader
;
import
java
.
util
.
LinkedHashMap
;
import
java
.
util
.
Map
;
import
java
.
util
.
Properties
;
import
org
.
apache
.
log4j
.
Logger
;
import
com
.
api
.
manager
.
worker
.
http
.
HttpSender
.
Method
;
import
com
.
api
.
manager
.
worker
.
tool
.
reader
.
PropertiesReader
;
/**
* 配置
*
* @author ASLai
*
*/
public
class
Config
{
/**
* 图标资源
*/
public
enum
Icon
{
/** logo */
logo
(
"image/logo.png"
),
/** 新增按钮 */
add
(
"image/add.png"
),
/** 删除按钮 */
delete
(
"image/delete.png"
),
/** 清空按钮 */
clear
(
"image/clear.png"
),
/** 清空按钮 */
up
(
"image/up.png"
),
/** 文件夹 */
folder
(
"image/folder.png"
),
/** 文件夹-打开 */
folder_open
(
"image/folder_open.png"
),
/** 叶子节点 */
leaf
(
"image/leaf.png"
);
/** 图片路径 */
public
final
String
path
;
private
Icon
(
String
path
) {
this
.
path
=
path
;
}
}
private
static
Logger
logger
=
Logger
.
getLogger
(
Config
.
class
);
private
static
final
String
CONFIG_PATH
=
"/properties/config.properties"
;
private
static
final
String
VERSION_PATH
=
"/version/version.properties"
;
private
static
final
String
VERSION_TEXT_PATH
=
"/version/version.txt"
;
private
static
final
String
ATTR_NAME
=
"manager.name"
;
private
static
final
String
ATTR_SINGLETON
=
"manager.singleton"
;
private
static
final
String
ATTR_CHARTSET
=
"manager.charset"
;
private
static
final
String
ATTR_CONFIG_DIR
=
"manager.config.dir"
;
private
static
final
String
ATTR_CONFIG_FILE_BASE
=
"manager.config.file.base"
;
private
static
final
String
ATTR_CONFIG_FILE_STYLE
=
"manager.config.file.style"
;
private
static
final
String
ATTR_CONFIG_FILE_HISTORY
=
"manager.config.file.history"
;
private
static
final
String
ATTR_CONFIG_FILE_FAVORITES
=
"manager.config.file.favorites"
;
private
static
final
String
ATTR_CONFIG_SUFFIX
=
"manager.config.suffix"
;
private
static
final
String
ATTR_CONFIG_AUTO
=
"manager.config.auto"
;
private
static
final
String
ATTR_CONFIG_AUTO_TIME
=
"manager.config.auto.time"
;
private
static
final
String
ATTR_FONT_NAME
=
"manager.font.name"
;
private
static
final
String
ATTR_FONT_SIZE
=
"manager.font.size"
;
private
static
final
String
ATTR_THEME
=
"manager.theme"
;
private
static
final
String
ATTR_THEME_DEFAULT
=
"manager.theme.default"
;
private
static
final
String
ATTR_METHOD_DEFAULT
=
"manager.method.default"
;
private
static
final
String
ATTR_HISTORY_MAX
=
"manager.history.max"
;
private
static
final
String
ATTR_HISTORY_SAVE
=
"manager.history.save"
;
private
static
final
String
ATTR_HTTP_TIMEOUT
=
"manager.http.time.out"
;
private
static
final
String
ATTR_VERSION
=
"manager.version"
;
private
static
final
String
ATTR_VERSION_NUMBER
=
"manager.version.number"
;
private
static
final
String
ATTR_VERSION_DATE
=
"manager.version.date"
;
/** 名称 */
public
String
name
;
/** 是否为单例 */
public
Boolean
singleton
;
/** 编码 */
public
String
charset
;
/** 用户配置路径 */
public
String
config_dir
;
/** 基础配置文件 */
public
String
config_file_base
;
/** 主题样式配置文件 */
public
String
config_file_style
;
/** 历史记录配置文件 */
public
String
config_file_history
;
/** 收藏夹配置文件 */
public
String
config_file_favorites
;
/** 配置默认后缀 */
public
String
config_suffix
;
/** 是否开启配置自动保存 */
public
Boolean
config_auto
;
/** 自动保存配置间隔时间 */
public
Integer
config_auto_time
;
/** 默认字体 */
public
Font
font
;
/** 图标 */
public
Map
<
String
,
String
>
icons
;
/** 主题 */
public
Map
<
String
,
String
>
themes
;
/** 默认主题 */
public
String
default_themes
;
/** 默认调用方式 */
public
Method
default_method
;
/** 历史记录最大条数 */
public
Integer
max_history
;
/** 是否保存历史记录 */
public
Boolean
save_history
;
/** 连接超时时间 */
public
Integer
time_out
;
/** 版本 */
public
String
version
;
/** 版本序号 */
public
Integer
version_number
;
/** 版本构建事件 */
public
String
version_date
;
/**
* 初始化配置
*/
public
void
init
() {
long
start
=
System
.
currentTimeMillis
();
logger
.
info
(
"读取系统配置"
);
Properties
prop
=
PropertiesReader
.
getResourceProp
(
CONFIG_PATH
);
initBase
(
prop
);
initTheme
(
prop
);
initFont
(
prop
);
initMethod
(
prop
);
prop
=
PropertiesReader
.
getResourceProp
(
VERSION_PATH
);
initVersion
(
prop
);
logger
.
info
(
"读取系统配置 -完毕- "
+ (
System
.
currentTimeMillis
() -
start
) +
"ms"
);
}
/**
* 初始化基础配置
*
* @param prop 配置
*/
private
void
initBase
(
Properties
prop
) {
name
= (
String
)
prop
.
get
(
ATTR_NAME
);
singleton
=
Boolean
.
valueOf
((
String
)
prop
.
get
(
ATTR_SINGLETON
));
max_history
=
Integer
.
valueOf
((
String
)
prop
.
get
(
ATTR_HISTORY_MAX
));
save_history
=
Boolean
.
valueOf
((
String
)
prop
.
get
(
ATTR_HISTORY_SAVE
));
time_out
=
Integer
.
valueOf
((
String
)
prop
.
get
(
ATTR_HTTP_TIMEOUT
));
config_dir
= (
String
)
prop
.
get
(
ATTR_CONFIG_DIR
);
config_file_base
= (
String
)
prop
.
get
(
ATTR_CONFIG_FILE_BASE
);
config_file_style
= (
String
)
prop
.
get
(
ATTR_CONFIG_FILE_STYLE
);
config_file_history
= (
String
)
prop
.
get
(
ATTR_CONFIG_FILE_HISTORY
);
config_file_favorites
= (
String
)
prop
.
get
(
ATTR_CONFIG_FILE_FAVORITES
);
config_suffix
= (
String
)
prop
.
get
(
ATTR_CONFIG_SUFFIX
);
config_auto
=
Boolean
.
valueOf
((
String
)
prop
.
get
(
ATTR_CONFIG_AUTO
));
config_auto_time
=
Integer
.
valueOf
((
String
)
prop
.
get
(
ATTR_CONFIG_AUTO_TIME
));
charset
= (
String
)
prop
.
get
(
ATTR_CHARTSET
);
}
/**
* 初始化主体配置
*
* @param prop 配置
*/
private
void
initTheme
(
Properties
prop
) {
themes
=
new
LinkedHashMap
<
String
,
String
>();
// 主题类型
String
[]
types
= ((
String
)
prop
.
get
(
ATTR_THEME
)).
split
(
"
\\
|"
);
for
(
String
type
:
types
) {
// 主题类型信息
String
[]
themeTypeInfo
=
type
.
split
(
"_"
);
// 主题类型名称
String
name
=
themeTypeInfo
[
0
];
// 获取主题
for
(
String
theme
:
themeTypeInfo
[
1
].
split
(
","
)) {
StringBuilder
attr
=
new
StringBuilder
();
// 配置参数名称
attr
.
append
(
ATTR_THEME
).
append
(
"."
).
append
(
name
).
append
(
"."
).
append
(
theme
);
// 添加主题信息
String
[]
themeInfo
=
prop
.
get
(
attr
.
toString
()).
toString
().
split
(
","
);
themes
.
put
(
themeInfo
[
0
],
themeInfo
[
1
]);
}
}
default_themes
= (
String
)
prop
.
get
(
ATTR_THEME_DEFAULT
);
}
/**
* 初始化字体
*
* @param prop 配置
*/
private
void
initFont
(
Properties
prop
) {
String
font_name
= (
String
)
prop
.
get
(
ATTR_FONT_NAME
);
Integer
font_size
=
Integer
.
valueOf
((
String
)
prop
.
get
(
ATTR_FONT_SIZE
));
font
=
new
Font
(
font_name
,
Font
.
PLAIN
,
font_size
);
}
/**
* 初始化默认调用方式
*
* @param prop 配置
*/
private
void
initMethod
(
Properties
prop
) {
String
method
= (
String
)
prop
.
get
(
ATTR_METHOD_DEFAULT
);
default_method
=
Method
.
valueOf
(
method
);
}
private
void
initVersion
(
Properties
prop
) {
version
= (
String
)
prop
.
get
(
ATTR_VERSION
);
version_number
=
Integer
.
valueOf
((
String
)
prop
.
get
(
ATTR_VERSION_NUMBER
));
version_date
= (
String
)
prop
.
get
(
ATTR_VERSION_DATE
);
}
/**
* 读取版本信息
*
* @return 版本信息
*/
public
String
readVersion
() {
// 读取版本信息文件流
InputStream
is
=
Object
.
class
.
getResourceAsStream
(
VERSION_TEXT_PATH
);
// 读取器
BufferedReader
reader
=
null
;
try
{
reader
=
new
BufferedReader
(
new
InputStreamReader
(
is
));
// 版本信息
StringBuilder
version
=
new
StringBuilder
();
// 行字符串
String
str
=
null
;
// 是否为起始行
boolean
start
=
true
;
// 读取文件
while
((
str
=
reader
.
readLine
()) !=
null
) {
if
(
start
) {
start
=
false
;
}
else
{
version
.
append
(
"
\r
\n
"
);
}
version
.
append
(
new
String
(
str
.
getBytes
(),
charset
));
}
return
version
.
toString
();
}
catch
(
IOException
e
) {
throw
new
RuntimeException
(
e
);
}
finally
{
// 关闭流
if
(
reader
!=
null
) {
try
{
reader
.
close
();
}
catch
(
IOException
e
) {
}
}
try
{
is
.
close
();
}
catch
(
IOException
e
) {
}
}
}
}
You can’t perform that action at this time.