Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
开发者小峰
Jerry Rat Server
提交
7b305d83
Jerry Rat Server
项目概览
开发者小峰
/
Jerry Rat Server
9 个月 前同步成功
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Jerry Rat Server
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
7b305d83
编写于
5月 20, 2022
作者:
F
fanjiefeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新编译器
上级
d801df46
变更
26
隐藏空白更改
内联
并排
Showing
26 changed file
with
219 addition
and
36 deletion
+219
-36
Manage/bin/pub/fjf/http/HttpServer.class
Manage/bin/pub/fjf/http/HttpServer.class
+0
-0
Manage/bin/pub/fjf/tools/ExternalCompiler.class
Manage/bin/pub/fjf/tools/ExternalCompiler.class
+0
-0
Manage/bin/pub/fjf/tools/JerryRatCompiler.class
Manage/bin/pub/fjf/tools/JerryRatCompiler.class
+0
-0
Manage/bin/pub/fjf/tools/LocalCompiler.class
Manage/bin/pub/fjf/tools/LocalCompiler.class
+0
-0
Manage/bin/pub/fjf/tools/PathCompiler.class
Manage/bin/pub/fjf/tools/PathCompiler.class
+0
-0
Manage/bin/pub/fjf/tools/SystemCompiler.class
Manage/bin/pub/fjf/tools/SystemCompiler.class
+0
-0
Manage/bin/servlet/ServerConfig.class
Manage/bin/servlet/ServerConfig.class
+0
-0
Manage/resource/index.html
Manage/resource/index.html
+6
-6
Manage/resource/js/server/server.js
Manage/resource/js/server/server.js
+6
-6
Manage/src/servlet/ServerConfig.class
Manage/src/servlet/ServerConfig.class
+0
-0
Manage/src/servlet/ServerConfig.java
Manage/src/servlet/ServerConfig.java
+2
-2
bin/pub/fjf/http/HttpServer.class
bin/pub/fjf/http/HttpServer.class
+0
-0
bin/pub/fjf/tools/ExternalCompiler.class
bin/pub/fjf/tools/ExternalCompiler.class
+0
-0
bin/pub/fjf/tools/JerryRatCompiler.class
bin/pub/fjf/tools/JerryRatCompiler.class
+0
-0
bin/pub/fjf/tools/LocalCompiler.class
bin/pub/fjf/tools/LocalCompiler.class
+0
-0
bin/pub/fjf/tools/PathCompiler.class
bin/pub/fjf/tools/PathCompiler.class
+0
-0
bin/pub/fjf/tools/SystemCompiler.class
bin/pub/fjf/tools/SystemCompiler.class
+0
-0
config/CompilerList.json
config/CompilerList.json
+24
-0
config/HttpServer.json
config/HttpServer.json
+2
-2
lib/tools.jar
lib/tools.jar
+0
-0
src/pub/fjf/http/HttpServer.java
src/pub/fjf/http/HttpServer.java
+2
-2
src/pub/fjf/tools/ExternalCompiler.java
src/pub/fjf/tools/ExternalCompiler.java
+63
-0
src/pub/fjf/tools/JerryRatCompiler.java
src/pub/fjf/tools/JerryRatCompiler.java
+11
-0
src/pub/fjf/tools/LocalCompiler.java
src/pub/fjf/tools/LocalCompiler.java
+26
-0
src/pub/fjf/tools/PathCompiler.java
src/pub/fjf/tools/PathCompiler.java
+53
-18
src/pub/fjf/tools/SystemCompiler.java
src/pub/fjf/tools/SystemCompiler.java
+24
-0
未找到文件。
Manage/bin/pub/fjf/http/HttpServer.class
浏览文件 @
7b305d83
无法预览此类型文件
Manage/bin/pub/fjf/tools/ExternalCompiler.class
0 → 100644
浏览文件 @
7b305d83
文件已添加
Manage/bin/pub/fjf/tools/JerryRatCompiler.class
0 → 100644
浏览文件 @
7b305d83
文件已添加
Manage/bin/pub/fjf/tools/LocalCompiler.class
0 → 100644
浏览文件 @
7b305d83
文件已添加
Manage/bin/pub/fjf/tools/PathCompiler.class
浏览文件 @
7b305d83
无法预览此类型文件
Manage/bin/pub/fjf/tools/SystemCompiler.class
0 → 100644
浏览文件 @
7b305d83
文件已添加
Manage/bin/servlet/ServerConfig.class
浏览文件 @
7b305d83
无法预览此类型文件
Manage/resource/index.html
浏览文件 @
7b305d83
...
...
@@ -114,13 +114,13 @@
<option
value=
"lib"
>
lib
</option>
</select>
<br>
<span>
编译器路径
</span>
<input
type=
"text"
id=
"
compilerPat
h"
value=
""
/>
<select
name=
"
compilerPath"
id=
"compilerPat
hSelect"
onchange=
"selected('
compilerPat
h',this)"
>
<span>
日志开关
</span>
<input
type=
"text"
id=
"
logSwitc
h"
value=
""
/>
<select
name=
"
logSwitch"
id=
"logSwitc
hSelect"
onchange=
"selected('
logSwitc
h',this)"
>
<option
value=
""
selected=
"selected"
>
源
</option>
<option
value=
"
bin/javac"
>
自带
</option>
<option
value=
"
javac"
>
系统
</option>
<option
value=
"
true"
>
开
</option>
<option
value=
"
false"
>
关
</option>
</select>
<br>
<input
type=
"button"
value=
"更改"
onclick=
"updateServerConfig()"
/>
...
...
Manage/resource/js/server/server.js
浏览文件 @
7b305d83
...
...
@@ -30,11 +30,11 @@ function showServerConfig(text) {
var
classPathSelect
=
document
.
getElementById
(
"
classPathSelect
"
);
classPathSelect
.
options
[
0
].
value
=
serverConfig
.
classPath
;
classPathSelect
.
selectIndex
=
0
;
var
compilerPath
=
document
.
getElementById
(
"
compilerPat
h
"
);
compilerPath
.
value
=
serverConfig
.
compilerPat
h
;
var
compilerPathSelect
=
document
.
getElementById
(
"
compilerPat
hSelect
"
);
compilerPathSelect
.
options
[
0
].
value
=
serverConfig
.
compilerPat
h
;
compilerPat
hSelect
.
selectIndex
=
0
;
var
logSwitchInput
=
document
.
getElementById
(
"
logSwitc
h
"
);
logSwitchInput
.
value
=
serverConfig
.
logSwitc
h
;
var
logSwitchSelect
=
document
.
getElementById
(
"
logSwitc
hSelect
"
);
logSwitchSelect
.
options
[
0
].
value
=
serverConfig
.
logSwitc
h
;
logSwitc
hSelect
.
selectIndex
=
0
;
}
function
showWebProjects
(
text
)
{
...
...
@@ -69,7 +69,7 @@ function updateServerConfig() {
json
.
receiveTimeOut
=
document
.
getElementById
(
"
receiveTimeOut
"
).
value
;
json
.
port
=
document
.
getElementById
(
"
port
"
).
value
;
json
.
classPath
=
document
.
getElementById
(
"
classPath
"
).
value
;
json
.
compilerPath
=
document
.
getElementById
(
"
compilerPat
h
"
).
value
;
json
.
logSwitch
=
document
.
getElementById
(
"
logSwitc
h
"
).
value
;
send
(
"
POST
"
,
"
/@ServerConfig
"
,
true
,
JSON
.
stringify
(
json
),
showServerConfig
,
null
);
}
...
...
Manage/src/servlet/ServerConfig.class
浏览文件 @
7b305d83
无法预览此类型文件
Manage/src/servlet/ServerConfig.java
浏览文件 @
7b305d83
...
...
@@ -36,13 +36,13 @@ public class ServerConfig extends HttpServlet {
save
.
setMember
(
"receiveTimeOut"
,
recv
.
getMember
(
"receiveTimeOut"
));
save
.
setMember
(
"port"
,
recv
.
getMember
(
"port"
));
save
.
setMember
(
"classPath"
,
recv
.
getMember
(
"classPath"
));
save
.
setMember
(
"
compilerPath"
,
recv
.
getMember
(
"compilerPat
h"
));
save
.
setMember
(
"
logSwitch"
,
recv
.
getMember
(
"logSwitc
h"
));
if
(
StringTools
.
writeAsPath
(
configPath
,
save
.
toString
(
true
)))
{
hs
.
setUrlCharset
(
save
.
getMember
(
"urlCharset"
).
getValueString
());
hs
.
setCharset
(
save
.
getMember
(
"charset"
).
getValueString
());
hs
.
setReceiveTimeOut
(
Integer
.
parseInt
(
save
.
getMember
(
"receiveTimeOut"
).
getValueString
()));
HttpServer
.
classPath
=
save
.
getMember
(
"classPath"
).
getValueString
();
HttpServer
.
compilerPath
=
save
.
getMember
(
"compilerPath"
).
getValueString
(
);
HttpServer
.
logSwitch
=
Boolean
.
parseBoolean
(
save
.
getMember
(
"logSwitch"
).
getValueString
()
);
resp
.
sendData
(
save
.
toString
(),
"text/txt"
);
try
{
Thread
.
sleep
(
2000
);
...
...
bin/pub/fjf/http/HttpServer.class
浏览文件 @
7b305d83
无法预览此类型文件
bin/pub/fjf/tools/ExternalCompiler.class
0 → 100644
浏览文件 @
7b305d83
文件已添加
bin/pub/fjf/tools/JerryRatCompiler.class
0 → 100644
浏览文件 @
7b305d83
文件已添加
bin/pub/fjf/tools/LocalCompiler.class
0 → 100644
浏览文件 @
7b305d83
文件已添加
bin/pub/fjf/tools/PathCompiler.class
浏览文件 @
7b305d83
无法预览此类型文件
bin/pub/fjf/tools/SystemCompiler.class
0 → 100644
浏览文件 @
7b305d83
文件已添加
config/CompilerList.json
0 → 100644
浏览文件 @
7b305d83
/*
*
文件:
CompilerList.json
*
作用:
编译优先级列表
*/
[
{
"name"
:
"本地编译器"
,
"className"
:
"pub.fjf.tools.LocalCompiler"
,
"compilerName"
:
"LocalCompiler"
,
"content"
:
"bin/pub/fjf/tools"
},
{
"name"
:
"系统编译器"
,
"className"
:
"pub.fjf.tools.SystemCompiler"
,
"compilerName"
:
"SystemCompiler"
,
"content"
:
"bin/pub/fjf/tools"
},
{
"name"
:
"外部编译器"
,
"className"
:
"pub.fjf.tools.ExternalCompiler"
,
"compilerName"
:
"ExternalCompiler"
,
"content"
:
"bin/pub/fjf/tools"
}
]
\ No newline at end of file
config/HttpServer.json
浏览文件 @
7b305d83
...
...
@@ -3,7 +3,6 @@
*
作用:
配置Http服务器参数
*/
{
"compilerPath"
:
"javac"
,
"webProjects"
:
[
{
"removable"
:
false
,
...
...
@@ -26,5 +25,6 @@
"urlCharset"
:
"default"
,
"receiveTimeOut"
:
"24000"
,
"port"
:
"80"
,
"classPath"
:
"bin"
"classPath"
:
"bin"
,
"logSwitch"
:
"false"
}
\ No newline at end of file
lib/tools.jar
浏览文件 @
7b305d83
无法预览此类型文件
src/pub/fjf/http/HttpServer.java
浏览文件 @
7b305d83
...
...
@@ -31,7 +31,7 @@ public class HttpServer {
private
ThreadPoolExecutor
executors
=
null
;
private
ArrayList
<
WebProject
>
webProjects
=
new
ArrayList
<
WebProject
>();
//项目列表
public
static
String
classPath
=
"bin"
;
//服务器类路径
public
static
String
compilerPath
=
"javac"
;
//编译器路径
public
static
boolean
logSwitch
=
true
;
/**
* 创建Http服务器
* @param configPath 配置文件路径
...
...
@@ -73,7 +73,7 @@ public class HttpServer {
this
.
setReceiveTimeOut
(
Integer
.
parseInt
(
json
.
getJsonVar
(
"this.receiveTimeOut"
).
getValueString
()));
this
.
port
=
Integer
.
parseInt
(
json
.
getJsonVar
(
"this.port"
).
getValueString
());
HttpServer
.
classPath
=
json
.
getJsonVar
(
"this.classPath"
).
getValueString
();
HttpServer
.
compilerPath
=
json
.
getJsonVar
(
"this.compilerPath"
).
getValueString
(
);
HttpServer
.
logSwitch
=
Boolean
.
parseBoolean
(
json
.
getJsonVar
(
"this.logSwitch"
).
getValueString
()
);
ArrayList
<
Json
>
wpList
=
json
.
getJsonVar
(
"this.webProjects"
).
getElements
();
for
(
int
i
=
0
;
i
<
wpList
.
size
();
i
++)
{
Json
wpJson
=
wpList
.
get
(
i
);
...
...
src/pub/fjf/tools/ExternalCompiler.java
0 → 100644
浏览文件 @
7b305d83
package
pub.fjf.tools
;
import
java.io.IOException
;
import
java.io.InputStream
;
public
class
ExternalCompiler
implements
JerryRatCompiler
{
private
String
errorInform
;
private
String
compilerPath
;
public
ExternalCompiler
(){
this
(
"javac"
);
}
public
ExternalCompiler
(
String
compilerPath
){
this
.
compilerPath
=
compilerPath
;
}
@Override
public
boolean
compiler
(
String
classPath
,
String
javaPath
)
{
// TODO Auto-generated method stub
boolean
result
=
false
;
this
.
errorInform
=
""
;
StringBuffer
cmd
=
new
StringBuffer
();
cmd
.
append
(
compilerPath
+
" "
);
if
(
classPath
.
length
()>
0
)
{
cmd
.
append
(
"-cp "
);
cmd
.
append
(
classPath
);
cmd
.
append
(
" "
);
}
cmd
.
append
(
javaPath
);
for
(
int
i
=
0
;
i
<
cmd
.
length
();
i
++)
{
if
(
cmd
.
charAt
(
i
)==
'/'
)
{
cmd
.
setCharAt
(
i
,
'\\'
);
}
}
Process
p
=
null
;
try
{
p
=
Runtime
.
getRuntime
().
exec
(
cmd
.
toString
());
try
{
p
.
waitFor
();
}
catch
(
InterruptedException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
InputStream
is
=
p
.
getErrorStream
();
try
{
if
(
is
.
available
()==
0
)
{
result
=
true
;
}
else
{
byte
[]
bytes
=
new
byte
[
is
.
available
()];
is
.
read
(
bytes
);
this
.
errorInform
=
new
String
(
bytes
);
System
.
err
.
println
(
this
.
errorInform
);
}
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
return
result
;
}
}
src/pub/fjf/tools/JerryRatCompiler.java
0 → 100644
浏览文件 @
7b305d83
package
pub.fjf.tools
;
public
interface
JerryRatCompiler
{
/**
* 编译器接口
* @param classPath 类链接目录
* @param javaPath 源码文件路径
* @return 是否编译成功
*/
public
boolean
compiler
(
String
classPath
,
String
javaPath
);
}
src/pub/fjf/tools/LocalCompiler.java
0 → 100644
浏览文件 @
7b305d83
package
pub.fjf.tools
;
import
javax.tools.JavaCompiler
;
import
com.sun.tools.javac.api.JavacTool
;
public
class
LocalCompiler
implements
JerryRatCompiler
{
JavaCompiler
javac
=
null
;
public
LocalCompiler
()
throws
Exception
{
try
{
this
.
javac
=
JavacTool
.
create
();
}
catch
(
NoClassDefFoundError
e
)
{
throw
new
Exception
();
}
}
@Override
public
boolean
compiler
(
String
classPath
,
String
javaPath
)
{
// TODO Auto-generated method stub
boolean
result
=
false
;
String
[]
aguments
=
{
"-cp"
,
classPath
,
javaPath
};
if
(
javac
.
run
(
null
,
null
,
null
,
aguments
)==
0
)
{
result
=
true
;
}
return
result
;
}
}
src/pub/fjf/tools/PathCompiler.java
浏览文件 @
7b305d83
package
pub.fjf.tools
;
import
javax.tools.JavaCompiler
;
import
com.sun.tools.javac.api.JavacTool
;
//编译器
public
class
PathCompiler
{
private
static
JerryRatCompiler
compiler
;
private
String
rootPath
;
private
String
classPath
;
static
{
loadCompile
(
"config/CompilerList.json"
);
if
(
compiler
==
null
)
{
System
.
out
.
println
(
"无编译器可用!"
);
}
}
public
static
void
loadCompile
(
String
configPath
)
{
Json
configJson
=
new
Json
(
StringTools
.
readAsPath
(
configPath
));
if
(
configJson
.
getTypeCode
()==
Json
.
TYPE_ARRAY
)
{
for
(
int
i
=
0
;
i
<
configJson
.
getElementCount
();
i
++)
{
PathClassLoader
pathClassLoader
=
new
PathClassLoader
();
Class
<?>
C
=
null
;
Json
compilerJson
=
configJson
.
getElement
(
i
);
String
name
=
compilerJson
.
getMember
(
"name"
).
getValueString
();
String
className
=
compilerJson
.
getMember
(
"className"
).
getValueString
();
String
compilerName
=
compilerJson
.
getMember
(
"compilerName"
).
getValueString
();
String
content
=
compilerJson
.
getMember
(
"content"
).
getValueString
();
try
{
C
=
Class
.
forName
(
className
,
true
,
pathClassLoader
);
}
catch
(
ClassNotFoundException
e
)
{}
if
(
C
==
null
)
{
String
classPath
=
content
;
if
(
classPath
!=
null
&&
classPath
.
length
()>
0
)
{
classPath
+=
"/"
;
}
classPath
+=
compilerName
+
".class"
;
C
=
pathClassLoader
.
readClass
(
classPath
);
}
if
(
C
!=
null
)
{
try
{
compiler
=(
JerryRatCompiler
)(
C
.
newInstance
());
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
System
.
out
.
println
(
"创建 "
+
name
+
" 失败!"
);
}
}
else
{
System
.
out
.
println
(
"加载 "
+
name
+
" 失败!"
);
}
if
(
compiler
!=
null
)
{
System
.
out
.
println
(
"创建 "
+
name
+
" 成功!"
);
break
;
}
}
}
}
public
PathCompiler
()
{
this
(
""
);
}
...
...
@@ -32,21 +74,14 @@ public class PathCompiler {
}
public
boolean
compile
(
String
javaPath
)
{
boolean
result
=
false
;
StringBuffer
path
=
new
StringBuffer
();
if
(
this
.
rootPath
!=
null
&&
this
.
rootPath
.
length
()>
0
)
{
path
.
append
(
this
.
rootPath
);
path
.
append
(
"/"
);
}
path
.
append
(
javaPath
);
for
(
int
i
=
0
;
i
<
path
.
length
();
i
++)
{
if
(
path
.
charAt
(
i
)==
'/'
)
{
path
.
setCharAt
(
i
,
'\\'
);
if
(
compiler
!=
null
)
{
StringBuffer
path
=
new
StringBuffer
();
if
(
this
.
rootPath
!=
null
&&
this
.
rootPath
.
length
()>
0
)
{
path
.
append
(
this
.
rootPath
);
path
.
append
(
"/"
);
}
}
JavaCompiler
javac
=
JavacTool
.
create
();
String
[]
aguments
=
{
"-cp"
,
this
.
classPath
,
path
.
toString
()};
if
(
javac
.
run
(
null
,
null
,
null
,
aguments
)==
0
)
{
result
=
true
;
path
.
append
(
javaPath
);
result
=
compiler
.
compiler
(
classPath
,
path
.
toString
());
}
return
result
;
}
...
...
src/pub/fjf/tools/SystemCompiler.java
0 → 100644
浏览文件 @
7b305d83
package
pub.fjf.tools
;
import
javax.tools.JavaCompiler
;
import
javax.tools.ToolProvider
;
public
class
SystemCompiler
implements
JerryRatCompiler
{
JavaCompiler
javac
=
null
;
public
SystemCompiler
()
throws
Exception
{
this
.
javac
=
ToolProvider
.
getSystemJavaCompiler
();
if
(
javac
==
null
)
{
throw
new
Exception
();
}
}
@Override
public
boolean
compiler
(
String
classPath
,
String
javaPath
)
{
// TODO Auto-generated method stub
boolean
result
=
false
;
String
[]
aguments
=
{
"-cp"
,
classPath
,
javaPath
};
if
(
javac
.
run
(
null
,
null
,
null
,
aguments
)==
0
)
{
result
=
true
;
}
return
result
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录