Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
ba682a9f
o2oa
项目概览
ghsby
/
o2oa
落后 Fork 源项目 2880 个版本
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ba682a9f
编写于
9月 01, 2020
作者:
Z
zhourui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
part four develop
上级
19a72915
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
245 addition
and
12 deletion
+245
-12
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/ClassLoaderTools.java
.../java/com/x/base/core/project/tools/ClassLoaderTools.java
+95
-0
o2server/x_console/src/main/java/com/x/server/console/InstrumentationAgent.java
.../main/java/com/x/server/console/InstrumentationAgent.java
+116
-0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/form/FormAction.java
...ocessplatform/assemble/surface/jaxrs/form/FormAction.java
+22
-4
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/form/V2GetWithWorkOrWorkCompleted.java
...mble/surface/jaxrs/form/V2GetWithWorkOrWorkCompleted.java
+12
-8
未找到文件。
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/ClassLoaderTools.java
0 → 100644
浏览文件 @
ba682a9f
package
com.x.base.core.project.tools
;
import
java.io.IOException
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.net.URLClassLoader
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Stream
;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.base.core.project.config.Config
;
public
class
ClassLoaderTools
{
private
ClassLoaderTools
()
{
// nothing
}
private
static
final
String
CFG
=
"manifest.cfg"
;
private
static
final
String
GIT
=
".gitignore"
;
private
static
final
String
JAR
=
".jar"
;
private
static
final
String
ZIP
=
".zip"
;
public
static
URLClassLoader
urlClassLoader
(
boolean
systemParent
,
boolean
ext
,
boolean
store
,
boolean
custom
,
boolean
dynamic
,
Path
...
paths
)
throws
Exception
{
return
urlClassLoader
(
systemParent
,
ext
,
store
,
custom
,
dynamic
,
ListTools
.
toList
(
paths
));
}
public
static
URLClassLoader
urlClassLoader
(
boolean
systemParent
,
boolean
ext
,
boolean
store
,
boolean
custom
,
boolean
dynamic
,
List
<
Path
>
paths
)
throws
Exception
{
Set
<
Path
>
set
=
new
HashSet
<>();
if
(
ext
)
{
set
.
addAll
(
dirCfg
(
Config
.
dir_commons_ext
().
toPath
()));
}
if
(
store
)
{
set
.
addAll
(
dirCfg
(
Config
.
dir_store_jars
().
toPath
()));
}
if
(
custom
)
{
set
.
addAll
(
dir
(
Config
.
dir_custom_jars
().
toPath
()));
}
if
(
dynamic
)
{
set
.
addAll
(
dir
(
Config
.
dir_dynamic_jars
().
toPath
()));
}
set
.
addAll
(
paths
);
if
(
systemParent
)
{
return
URLClassLoader
.
newInstance
(
toURL
(
set
),
ClassLoader
.
getSystemClassLoader
());
}
else
{
return
URLClassLoader
.
newInstance
(
toURL
(
set
));
}
}
private
static
URL
[]
toURL
(
Set
<
Path
>
set
)
throws
MalformedURLException
{
URL
[]
urls
=
new
URL
[
set
.
size
()];
int
idx
=
0
;
for
(
Path
p
:
set
)
{
urls
[
idx
++]
=
p
.
toUri
().
toURL
();
}
return
urls
;
}
private
static
List
<
Path
>
dirCfg
(
Path
dir
)
throws
IOException
{
List
<
Path
>
paths
=
new
ArrayList
<>();
Path
cfg
=
dir
.
resolve
(
CFG
);
if
(
Files
.
exists
(
dir
)
&&
Files
.
isDirectory
(
dir
)
&&
Files
.
exists
(
cfg
)
&&
Files
.
isRegularFile
(
cfg
))
{
List
<
String
>
names
=
Files
.
readAllLines
(
cfg
);
try
(
Stream
<
Path
>
stream
=
Files
.
list
(
dir
))
{
stream
.
filter
(
o
->
!(
o
.
getFileName
().
toString
().
equalsIgnoreCase
(
CFG
)
||
o
.
getFileName
().
toString
().
equalsIgnoreCase
(
GIT
))).
forEach
(
o
->
{
if
(
names
.
remove
(
o
.
getFileName
().
toString
()))
{
paths
.
add
(
o
);
}
});
}
}
return
paths
;
}
private
static
List
<
Path
>
dir
(
Path
dir
)
throws
IOException
{
List
<
Path
>
paths
=
new
ArrayList
<>();
if
(
Files
.
exists
(
dir
)
&&
Files
.
isDirectory
(
dir
))
{
try
(
Stream
<
Path
>
stream
=
Files
.
list
(
dir
))
{
stream
.
filter
(
o
->
StringUtils
.
endsWithAny
(
StringUtils
.
lowerCase
(
o
.
getFileName
().
toString
()),
JAR
,
ZIP
))
.
forEach
(
paths:
:
add
);
}
}
return
paths
;
}
}
o2server/x_console/src/main/java/com/x/server/console/InstrumentationAgent.java
0 → 100644
浏览文件 @
ba682a9f
package
com.x.server.console
;
import
java.io.IOException
;
import
java.lang.instrument.Instrumentation
;
import
java.lang.reflect.Method
;
import
java.net.URL
;
import
java.net.URLClassLoader
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.List
;
import
java.util.jar.JarFile
;
import
java.util.stream.Stream
;
public
class
InstrumentationAgent
{
private
static
Instrumentation
INST
;
private
static
final
String
CFG
=
"manifest.cfg"
;
private
static
final
String
GIT
=
".gitignore"
;
public
static
void
agentmain
(
String
args
,
Instrumentation
inst
)
{
INST
=
inst
;
try
{
Path
base
=
getBasePath
();
if
(
Files
.
exists
(
base
.
resolve
(
"custom/jars"
)))
{
load
(
base
,
"custom/jars"
);
}
if
(
Files
.
exists
(
base
.
resolve
(
"dynamic/jars"
)))
{
load
(
base
,
"dynamic/jars"
);
}
load
(
base
,
"store/jars"
);
load
(
base
,
"commons/ext"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
static
void
premain
(
String
args
,
Instrumentation
inst
)
{
INST
=
inst
;
try
{
Path
base
=
getBasePath
();
if
(
Files
.
exists
(
base
.
resolve
(
"custom/jars"
)))
{
load
(
base
,
"custom/jars"
);
}
if
(
Files
.
exists
(
base
.
resolve
(
"dynamic/jars"
)))
{
load
(
base
,
"dynamic/jars"
);
}
load
(
base
,
"store/jars"
);
load
(
base
,
"commons/ext"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
private
static
void
load
(
Path
base
,
String
sub
)
throws
Exception
{
Path
dir
=
base
.
resolve
(
sub
);
Path
cfg
=
dir
.
resolve
(
CFG
);
if
(
Files
.
exists
(
dir
)
&&
Files
.
isDirectory
(
dir
)
&&
Files
.
exists
(
cfg
)
&&
Files
.
isRegularFile
(
cfg
))
{
List
<
String
>
names
=
Files
.
readAllLines
(
cfg
);
if
(
names
.
isEmpty
())
{
throw
new
Exception
(
String
.
format
(
"%s manifest is empty."
,
sub
));
}
try
(
Stream
<
Path
>
stream
=
Files
.
list
(
dir
))
{
stream
.
filter
(
o
->
!(
o
.
getFileName
().
toString
().
equalsIgnoreCase
(
CFG
)
||
o
.
getFileName
().
toString
().
equalsIgnoreCase
(
GIT
))).
forEach
(
o
->
{
try
{
if
(
names
.
remove
(
o
.
getFileName
().
toString
()))
{
// addURLToClassPath(o);
System
.
out
.
println
(
"load jar:"
+
o
.
toString
());
INST
.
appendToSystemClassLoaderSearch
(
new
JarFile
(
o
.
toString
()));
}
else
{
Files
.
delete
(
o
);
System
.
out
.
printf
(
"delete unnecessary file from %s: %s."
,
sub
,
o
.
getFileName
().
toString
());
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
});
}
for
(
String
name
:
names
)
{
System
.
out
.
printf
(
"can not load jar from %s: %s"
,
sub
,
name
);
}
}
else
{
throw
new
Exception
(
String
.
format
(
"invalid directory: %s"
,
sub
));
}
}
private
static
Path
getBasePath
()
throws
Exception
{
Path
path
=
Paths
.
get
(
InstrumentationAgent
.
class
.
getProtectionDomain
().
getCodeSource
().
getLocation
().
toURI
());
Path
version
=
path
.
resolveSibling
(
"version.o2"
);
if
(
Files
.
exists
(
version
)
&&
Files
.
isRegularFile
(
version
))
{
return
version
.
getParent
();
}
throw
new
Exception
(
"can not define o2server base directory."
);
}
private
static
void
addURLToClassPath
(
Path
jarPath
)
{
ClassLoader
classLoader
=
ClassLoader
.
getSystemClassLoader
();
try
{
if
(
classLoader
instanceof
URLClassLoader
)
{
Method
method
=
classLoader
.
getClass
().
getDeclaredMethod
(
"addURL"
,
URL
.
class
);
method
.
setAccessible
(
true
);
method
.
invoke
(
classLoader
,
jarPath
.
toUri
().
toURL
());
}
else
{
Method
method
=
classLoader
.
getClass
().
getDeclaredMethod
(
"appendToClassPathForInstrumentation"
,
String
.
class
);
method
.
setAccessible
(
true
);
method
.
invoke
(
classLoader
,
jarPath
.
toAbsolutePath
().
toString
());
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/form/FormAction.java
浏览文件 @
ba682a9f
...
...
@@ -45,7 +45,6 @@ public class FormAction extends StandardJaxrsAction {
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
result
.
error
(
e
);
}
/* 修改过的方法 */
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
...
...
@@ -65,7 +64,6 @@ public class FormAction extends StandardJaxrsAction {
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
result
.
error
(
e
);
}
/* 修改过的方法 */
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
...
...
@@ -129,8 +127,8 @@ public class FormAction extends StandardJaxrsAction {
@Path
(
"{flag}/application/{applicationFlag}/mobile"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
getWithApplicationMobile
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
@JaxrsParameterDescribe
(
"表单标识"
)
@PathParam
(
"flag"
)
String
flag
,
public
void
getWithApplicationMobile
(
@Suspended
final
AsyncResponse
asyncResponse
,
@
Context
HttpServletRequest
request
,
@
JaxrsParameterDescribe
(
"表单标识"
)
@PathParam
(
"flag"
)
String
flag
,
@JaxrsParameterDescribe
(
"应用标识"
)
@PathParam
(
"applicationFlag"
)
String
applicationFlag
)
{
ActionResult
<
ActionGetWithApplicationMobile
.
Wo
>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
...
...
@@ -142,4 +140,24 @@ public class FormAction extends StandardJaxrsAction {
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"V2根据工作或完成工作标识获取表单,合并关联表单和关联脚本输出."
,
action
=
V2GetWithWorkOrWorkCompleted
.
class
)
@GET
@Path
(
"v2/workorworkcompleted/{workOrWorkCompleted}"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
V2GetWithWorkOrWorkCompleted
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
@JaxrsParameterDescribe
(
"工作或完成工作标识"
)
@PathParam
(
"workOrWorkCompleted"
)
String
workOrWorkCompleted
)
{
ActionResult
<
V2GetWithWorkOrWorkCompleted
.
Wo
>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
V2GetWithWorkOrWorkCompleted
().
execute
(
effectivePerson
,
workOrWorkCompleted
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
}
\ No newline at end of file
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/form/V2GetWithWorkOrWorkCompleted.java
浏览文件 @
ba682a9f
...
...
@@ -2,10 +2,15 @@ package com.x.processplatform.assemble.surface.jaxrs.form;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Optional
;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.project.cache.ApplicationCache
;
import
com.x.base.core.project.cache.Cache.CacheCategory
;
import
com.x.base.core.project.cache.Cache.CacheKey
;
import
com.x.base.core.project.cache.CacheManager
;
import
com.x.base.core.project.exception.ExceptionAccessDenied
;
import
com.x.base.core.project.exception.ExceptionEntityNotExist
;
import
com.x.base.core.project.gson.GsonPropertyObject
;
...
...
@@ -21,8 +26,6 @@ import com.x.processplatform.core.entity.element.Activity;
import
com.x.processplatform.core.entity.element.Form
;
import
com.x.processplatform.core.entity.element.Script
;
import
org.apache.commons.lang3.StringUtils
;
import
net.sf.ehcache.Element
;
class
V2GetWithWorkOrWorkCompleted
extends
BaseAction
{
...
...
@@ -38,10 +41,11 @@ class V2GetWithWorkOrWorkCompleted extends BaseAction {
throw
new
ExceptionAccessDenied
(
effectivePerson
);
}
Wo
wo
=
null
;
String
cacheKey
=
ApplicationCache
.
concreteCacheKey
(
this
.
getClass
(),
workOrWorkCompleted
);
Element
element
=
CACHE
.
get
(
cacheKey
);
if
(
null
!=
element
&&
null
!=
element
.
getObjectValue
())
{
wo
=
(
Wo
)
element
.
getObjectValue
();
CacheCategory
cacheCategory
=
new
CacheCategory
(
Form
.
class
,
Script
.
class
);
CacheKey
cacheKey
=
new
CacheKey
(
this
.
getClass
(),
workOrWorkCompleted
);
Optional
<?>
optional
=
CacheManager
.
get
(
cacheCategory
,
cacheKey
);
if
(
optional
.
isPresent
())
{
wo
=
(
Wo
)
optional
.
get
();
}
else
{
Work
work
=
emc
.
find
(
workOrWorkCompleted
,
Work
.
class
);
if
(
null
!=
work
)
{
...
...
@@ -49,7 +53,7 @@ class V2GetWithWorkOrWorkCompleted extends BaseAction {
}
else
{
wo
=
this
.
workCompleted
(
business
,
emc
.
flag
(
workOrWorkCompleted
,
WorkCompleted
.
class
));
}
C
ACHE
.
put
(
new
Element
(
cacheKey
,
wo
)
);
C
acheManager
.
put
(
cacheCategory
,
cacheKey
,
wo
);
result
.
setData
(
wo
);
}
return
result
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录